diff options
Diffstat (limited to 'csarvalidation/src/main/java/org/onap')
3 files changed, 13 insertions, 19 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java index 0d7306f..f1c1a1e 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java @@ -65,16 +65,16 @@ public class CsarValidator { LOG.debug("CSAR extracted sucessfully."); } } catch (Exception e1) { - - //deleteDirectory(); - LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1); + LOG.error("INVALID_CSAR_CONTENT" + ":" + "CSAR %s is not a valid CSAR/ZIP file! " +ErrorCodes.INVALID_CSAR_CONTENT, e1); + throw new ValidationException(ErrorCodes.INVALID_CSAR_CONTENT); } try { vsl = new ValidatorSchemaLoader(); } catch (Exception e) { - e.printStackTrace(); + LOG.error("SCHEMA_LOAD_ERROR" + ":" + "CSAR schema is not loaded correctly! " +ErrorCodes.SCHEMA_LOAD_ERROR, e); + throw new ValidationException(ErrorCodes.SCHEMA_LOAD_ERROR); } } /** @@ -85,7 +85,6 @@ public class CsarValidator { boolean vsm = validateCsarMeta(); - // boolean vtm = validateToscaMeta__(); boolean vtm = validateAndScanToscaMeta(); boolean vms = validateMainService(); @@ -201,7 +200,7 @@ public class CsarValidator { return true; } } catch (Exception e) { - LOG.error("Parsing error"); + LOG.error("PARSE_ERROR" + ":" + "TOSCA metadata not parsed properly! " +ErrorCodes.PARSE_ERROR, e); } return false; @@ -219,7 +218,6 @@ public class CsarValidator { { String[] splitPath = value.split("/"); mrfCsarEntry = csarFiles.get(splitPath[splitPath.length - 1]); - // csarEntry = csarFiles.get(subValue); } else { //Hack to support non-compliant "Entry-Definitions:" format mrfCsarEntry = csarFiles.get(value); @@ -245,7 +243,7 @@ public class CsarValidator { String key = "metadata"; - // Infuture load from the respective file template/schema + // In future load from the respective file template/schema List<String> mListMetadata = Arrays.asList("vnf_product_name", "vnf_provider_id", "vnf_package_version", "vnf_release_data_time"); @@ -343,7 +341,8 @@ public class CsarValidator { * * @return true if csar meta data validation is successful */ - private static boolean validateToscaMeta(String cfile) { + @SuppressWarnings({ "unchecked", "static-access" }) + private static boolean validateToscaMeta(String cfile) { if (StringUtils.isEmpty(cfile)) { return false; @@ -358,7 +357,7 @@ public class CsarValidator { try { toscaMeta = (Map<String, ?>) yaml.load(new FileInputStream(file)); } catch (FileNotFoundException e) { - e.printStackTrace(); + LOG.error("CSAR_TOSCA_LOAD" + ":" + "TOSCA metadata is not loaded by Yaml! " +ErrorCodes.FILE_IO, e); } return toscaMeta.keySet().containsAll((vsl.getToscaMeta().keySet())); } diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ErrorCodes.java b/csarvalidation/src/main/java/org/onap/validation/csar/ErrorCodes.java index 162f61d..473f764 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/ErrorCodes.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/ErrorCodes.java @@ -32,7 +32,8 @@ public enum ErrorCodes { RESOURCE_MISSING(213), PARSE_ERROR(214), JSON_MAPPING_FAILED(215), - JSON_GENERATION_ERROR(216); + JSON_GENERATION_ERROR(216), + SCHEMA_LOAD_ERROR(217); private final int number; diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java index aa68cfb..488e151 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java @@ -20,15 +20,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; -import java.net.URISyntaxException; -import java.net.URL; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.*; -import java.util.stream.Stream; - import org.apache.commons.io.FilenameUtils; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.scanner.ScannerException; @@ -62,7 +55,8 @@ public class ValidatorSchemaLoader { } - private boolean loadResources() throws FileNotFoundException { + @SuppressWarnings("unchecked") + private boolean loadResources() throws FileNotFoundException { ClassLoader classLoader = getClass().getClassLoader(); |