summaryrefslogtreecommitdiffstats
path: root/csarvalidation
diff options
context:
space:
mode:
authorAvinash S <avinash.s@huawei.com>2018-03-07 10:49:41 +0000
committerAvinash S <avinash.s@huawei.com>2018-03-07 11:25:21 +0000
commit3b98cea01fc44f7fc0d18fc03acd24b487e595ec (patch)
tree7e8e5ff001c59ec6a01c72021f633db4e02624c5 /csarvalidation
parent39c2bace10aa22928ce114b8ec18f516185df74b (diff)
Fix sonar issues for VNFSDK Validation
Sonar blocker fix Issue-ID: VNFSDK-219 Change-Id: Ib581a95eba891b6d1b02ce5a1c3d1a24c44aed80 Signed-off-by: Avinash S <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java47
1 files changed, 28 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 a286665..8b6be13 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
@@ -30,16 +30,16 @@ import org.yaml.snakeyaml.Yaml;
public class CsarValidator {
- private static final Logger LOG = LoggerFactory.getLogger(CsarValidator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CsarValidator.class);
//Schema files
static private ValidatorSchemaLoader vsl;
// Map of CSAR file and un-zipped file indices
- static private HashMap<String, String> csarFiles;
+ static private HashMap<String, String> csarFiles;
// Map of packageId and CSAR files
- private static HashMap<String, HashMap<String, String>> csar = new HashMap<String, HashMap<String, String>>();
+ private static HashMap<String, HashMap<String, String>> csar = new HashMap<String, HashMap<String, String>>();
private static String MAINSERV_TEMPLATE = CommonConstants.MAINSERV_TEMPLATE;
private static String MAINSERV_MANIFEST;
@@ -104,22 +104,31 @@ public class CsarValidator {
*/
public static boolean validateCsarIntegrity(String csarWithPath) {
- try {
- RandomAccessFile raf = new RandomAccessFile(csarWithPath, "r");
- long n = raf.readInt();
- raf.close();
-
- // Check for the CSAR's integrity
- if (n != 0x504B0304) {
- LOG.error("CSAR %s is not a valid CSAR/ZIP file! ");
- return false;
- }
- return true;
- } catch (IOException e1) {
- LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1);
- return false;
- }
- }
+ try {
+ RandomAccessFile raf = new RandomAccessFile(csarWithPath, "r");
+ try {
+ long n = raf.readInt();
+
+ // Check for the CSAR's integrity
+ if (n != 0x504B0304) {
+ LOG.error("CSAR %s contents are not a valid! ");
+ return false;
+ }
+ return true;
+ } catch (FileNotFoundException e1) {
+ LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1);
+ return false;
+ }
+ finally {
+ raf.close();
+ return true;
+ }
+ }
+ catch (IOException e1) {
+ LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1);
+ return false;
+ }
+ }
/**
*