summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java
diff options
context:
space:
mode:
authorVictor Gao <victor.gao@huawei.com>2018-09-18 15:47:28 +0800
committerVictor Gao <victor.gao@huawei.com>2018-09-18 15:47:28 +0800
commit9bf2adc131ee671165a4b1e63adf531bd811645a (patch)
tree550ca6e33f7f54a0540413e6228532c4a6d7f44e /csarvalidation/src/main/java
parent0f315324a3978c7573984b61ae2e517e5c5f7953 (diff)
Implement requirement r02454
Change-Id: Icac494bda73069fb5435600e7d5144c584a692b6 Issue-ID: VNFSDK-175 Signed-off-by: Victor Gao <victor.gao@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java4
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java41
2 files changed, 44 insertions, 1 deletions
diff --git a/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java b/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
index 29c4bdf..5f4e053 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CommonConstants.java
@@ -45,6 +45,10 @@ public class CommonConstants {
public static final String MAINSERV_TEMPLATE = "MainServiceTemplate.yaml";
+ public static final String TOSCA_SWIMAGE = "tosca.artifacts.nfv.SwImage";
+
+ public static final String TOSCA_IMAGE = "tosca.artifacts.Deployment.Image";
+
public static final String CSAR_SUFFIX = ".csar";
public static final String HTTP_HEADER_CONTENT_RANGE = "Content-Range";
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 88cd0e0..d27aa5a 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/CsarValidator.java
@@ -108,6 +108,8 @@ public class CsarValidator {
String vms = validateMainService();
+ //String r02454 = r02454();
+
if((CommonConstants.SUCCESS_STR != vsm) && (CommonConstants.SUCCESS_STR != vms)) {
return vsm + " OR " + vms;
@@ -116,7 +118,11 @@ public class CsarValidator {
if(CommonConstants.SUCCESS_STR != vtm) {
return vtm;
}
-
+/*
+ if (CommonConstants.SUCCESS_STR != r02454) {
+ return r02454;
+ }
+*/
return CommonConstants.SUCCESS_STR;
}
@@ -291,12 +297,45 @@ public class CsarValidator {
if(!Paths.get(MAINSERV_TEMPLATE).isAbsolute()) {
mainservTemplate = csarFiles.get(FilenameUtils.getName(mainservTemplate));
}
+
if(StringUtils.isEmpty(mainservTemplate)) {
return "MainServiceTemplate does not exist in the package";
}
return CommonConstants.SUCCESS_STR;
}
+ /*
+ * @Author: Victor Gao
+ * @Description:
+ * @Date: 2018/9/18
+ * @Param: [filePath]
+ * @return: boolean
+ **/
+ public static String r02454() {
+ String mainservTemplate = MAINSERV_TEMPLATE;
+ mainservTemplate = csarFiles.get(FilenameUtils.getName(mainservTemplate));
+
+ //TODO: Fixme R3 only check the existence of swImage filed inside VNFD.
+ File file = new File(mainservTemplate);
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
+ String tempString = null;
+ while ((tempString = reader.readLine()) != null) {
+ if (tempString.contains((CommonConstants.TOSCA_SWIMAGE))) {
+ return CommonConstants.SUCCESS_STR;
+ }
+ }
+ } catch(IOException e2) {
+ return ("CSAR_META_VALIDATION" + ":" + "Exception caught while validateCsarMeta ! " + ErrorCodes.FILE_IO
+ + e2);
+ }
+
+ if(StringUtils.isEmpty(mainservTemplate)) {
+ return "Can not find the swImage inside Mainservicetemplate";
+ }
+
+ return "Can not find the swImage inside Mainservicetemplate";
+ }
+
private static String checkEntryFor(String fileWithPath, String attribute) throws IOException {
List<String> lines = Files.readAllLines(Paths.get(fileWithPath), UTF_8);