summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java
diff options
context:
space:
mode:
authorAvinashS <avinash.s@huawei.com>2017-09-18 12:55:57 +0000
committerAvinashS <avinash.s@huawei.com>2017-09-18 12:55:57 +0000
commit56c184e1622436654d9f12b1098a8020a6323a3a (patch)
tree67f89f9d4ca05e958c496be103bf91a6e6b4a270 /csarvalidation/src/main/java
parentd77a91e05fe1f2da7059e8cc1a5d41a804691e13 (diff)
Instantiate validation with path
To populate csar files during object creation. Change-Id: I66b5cf8b46f98990240e9cc470eff6a8874f3de0 IssueId: VNFSDK-90 Signed-off-by: AvinashS <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarParser.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CsarParser.java b/csarvalidation/src/main/java/org/onap/validation/csar/CsarParser.java
index 410562c..76a7b11 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarParser.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarParser.java
@@ -41,6 +41,23 @@ public class CsarParser {
private static HashMap<String, HashMap<String, String>> csar = new HashMap<String, HashMap<String, String>>();
private static final CsarUtil cUtil = new CsarUtil();
+
+ public CsarParser(String csarWithPath) {
+
+ try {
+ FileInputStream is = new FileInputStream(csarWithPath);
+ } catch (FileNotFoundException e2) {
+ LOG.error("CSAR %s is not found! ", e2);
+ }
+ try {
+ boolean ret = csarExtract(csarWithPath);
+ if(ret == true) {
+ LOG.debug("CSAR extracted sucessfully.");
+ }
+ } catch (Exception e1) {
+ LOG.error("CSAR %s is not a valid CSAR/ZIP file! ", e1);
+ }
+ }
/*
* pubic static boolean validateCsar(String filePath) {
*
@@ -74,13 +91,15 @@ public class CsarParser {
}
}
- public static boolean csarExtract(String filePath) {
+ private static boolean csarExtract(String filePath) {
try {
String tempfolder = CsarUtil.getUnzipDir(filePath);
csarFiles = CsarUtil.unzip(filePath, tempfolder);
+
} catch (IOException e1) {
LOG.error("CSAR extraction error ! " + e1.getMessage());
+
return false;
}
return true;
@@ -118,22 +137,24 @@ public class CsarParser {
return false;
}
}
-
- }
- reader.close();
+ }
+ reader.close();
+ return true;
}
} catch (IOException e2) {
- e2.printStackTrace();
- return false;
+ LOG.error("Exception cought while validateCsarMeta ! " + e2.getMessage());
+ //e2.printStackTrace();
+
} finally {
if (reader != null) {
try {
reader.close();
+
} catch (IOException e1) {
LOG.error("close reader failed ! " + e1.getMessage());
}
}
- return true;
+
}
}
@@ -145,7 +166,7 @@ public class CsarParser {
String cfile = csarFiles.get(CommonConstants.TOSCA_META);
try {
- if (!cfile.isEmpty() && cfile.contains("/" + CommonConstants.TOSCA_METADATA + "/" + CommonConstants.TOSCA_META)) {
+ if (!cfile.isEmpty() && cfile.contains( System.getProperty("file.separator")+ CommonConstants.TOSCA_METADATA + System.getProperty("file.separator") + CommonConstants.TOSCA_META)) {
String value = checkEntryFor("Entry-Definitions:", cfile);
if (value == null) {