diff options
author | AvinashS <avinash.s@huawei.com> | 2017-10-27 14:28:04 +0530 |
---|---|---|
committer | AvinashS <avinash.s@huawei.com> | 2017-10-27 14:28:04 +0530 |
commit | ebad8195f97ed97498e4c4ddbecf3599380f1e5a (patch) | |
tree | ceb595ebc0afb11801ab7bd3486afd0a9a4f2fd1 /csarvalidation/src/main | |
parent | ada0d9333251c26daf4869a3b33407658430ab18 (diff) |
Code cleanup
Removing logs, adding logs,
indentation
Change-Id: Ia85e742f5178ddc25af79e2c73f7a7b6aaa2c2e3
IssueId: VNFSDK-117
Signed-off-by: AvinashS <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation/src/main')
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(); |