diff options
author | AvinashS <avinash.s@huawei.com> | 2017-10-13 15:12:29 +0530 |
---|---|---|
committer | AvinashS <avinash.s@huawei.com> | 2017-10-13 15:12:29 +0530 |
commit | 0cd1abfbaf9ab74d294be36d863d6813f0243489 (patch) | |
tree | ab43a581c3b24ba1fef8d5d1f1ea0c184b0a407b /csarvalidation/src/main/java/org | |
parent | 20b01aa1fb3d83ccaf7c0918cd722da4b26c038f (diff) |
Code cleanup
Change-Id: I02bac5f387273965a622723654895a27202f1182
IssueId: VNFSDK-108
Signed-off-by: AvinashS <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java/org')
4 files changed, 43 insertions, 37 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java index f915168..850ccdd 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarUtil.java @@ -23,17 +23,12 @@ import java.io.File; import java.io.FileOutputStream; import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; import java.util.HashMap; import java.util.Enumeration; -import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -145,7 +140,11 @@ public class CsarUtil { } } - + /** + * + * @param filePath + * @return HashMap<String, String> + */ public static HashMap<String, String> csarExtract(String filePath) { try { 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 57870be..24969e7 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java @@ -21,7 +21,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.*; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import static java.nio.charset.StandardCharsets.*; import java.util.*; @@ -42,11 +41,16 @@ public class CsarValidator { // Map of packageId and CSAR files private static HashMap<String, HashMap<String, String>> csar = new HashMap<String, HashMap<String, String>>(); private static String MAINSERV_TEMPLATE; - - public CsarValidator(String packageId, String csarWithPath) { - - try { - FileInputStream is = new FileInputStream(csarWithPath); + /** + * + * @param packageId + * @param csarWithPath + * @throws IOException + */ + public CsarValidator(String packageId, String csarWithPath) throws IOException { + + try(FileInputStream is = new FileInputStream(csarWithPath)) { + } catch (FileNotFoundException e2) { LOG.error("CSAR %s is not found! " +ErrorCodes.RESOURCE_MISSING); throw new ValidationException(ErrorCodes.RESOURCE_MISSING); @@ -63,15 +67,11 @@ public class CsarValidator { //deleteDirectory(); LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1); } - - - try { - // vsl = new ValidatorSchemaLoader(); - } catch (Exception e) { - e.printStackTrace(); - } } - + /** + * + * @return true if all validations are successful + */ public static boolean validateCsar() { boolean vsm = validateCsarMeta(); @@ -87,7 +87,12 @@ public class CsarValidator { //In future return the status handler object instead. return false; } - + + /** + * + * @param csarWithPath + * @return true if csar integrity validation is successful + */ public static boolean validateCsarIntegrity(String csarWithPath) { try { @@ -106,7 +111,10 @@ public class CsarValidator { return false; } } - + /** + * + * @return true if csar meta data validation is successful + */ public static boolean validateCsarMeta() { String cfile = csarFiles.get(CommonConstants.CSAR_META); @@ -153,7 +161,10 @@ public class CsarValidator { return false; } - + /** + * + * @return true csar tosca meta validation is successful + */ public static boolean validateToscaMeta() { String cfile = csarFiles.get(CommonConstants.TOSCA_META); @@ -192,7 +203,10 @@ public class CsarValidator { } return false; } - + /** + * + * @return true csar validation is successful + */ public static boolean validateMainService() { String key = "metadata"; @@ -201,7 +215,8 @@ public class CsarValidator { List<String> mListMetadata = Arrays.asList("vnf_product_name", "vnf_provider_id", "vnf_package_version", "vnf_release_data_time"); - boolean mfResult = CheckEntryFor(CommonConstants.MAINSERV_MANIFEST, mListMetadata, key); + @SuppressWarnings("unused") + boolean mfResult = CheckEntryFor(CommonConstants.MAINSERV_MANIFEST, mListMetadata, key); String mrfFile = MAINSERV_TEMPLATE; if(!Paths.get(mrfFile).isAbsolute()){ mrfFile = csarFiles.get(FilenameUtils.getName(mrfFile)); @@ -224,8 +239,10 @@ public class CsarValidator { return null; } - private static boolean CheckEntryFor(String cFile, List<String> attributes, String key) { - String tFileWithPath; + @SuppressWarnings("unchecked") + private static boolean CheckEntryFor(String cFile, List<String> attributes, String key) { + @SuppressWarnings("unused") + String tFileWithPath; if (! Paths.get(cFile).isAbsolute()) { cFile = csarFiles.get(FilenameUtils.getName(cFile)); @@ -270,7 +287,6 @@ public class CsarValidator { .filter(attributes::contains) .collect(Collectors.toList()); - // System.out.println(result); if (lResult.size() == 0) { return false; } diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java index c1b10fa..16faf2d 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/FileUtil.java @@ -23,18 +23,11 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.io.Resources; - -import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.zip.ZipEntry; import java.util.zip.ZipFile; diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java b/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java index 804b632..5a3230b 100644 --- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java +++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidationException.java @@ -15,8 +15,6 @@ */ package org.onap.validation.csar; -import java.io.PrintStream; -import java.io.PrintWriter; import java.util.Map; import java.util.TreeMap; |