summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-04 17:19:35 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-09-05 12:12:24 +0530
commitb917a4cc7336d1f1b1e51f516e7927fb9227298b (patch)
tree70b75042864e395d0e39c2f7cfa8ae51defdd01a /csarvalidation/src/main/java
parentd8f0e75afc04c13eeb76c2e4612ed099db89d58a (diff)
VTP: Fix validation logic
Fails to validate the metadata. Change-Id: I47d3ead452a3e55f18d7b16d1918727974c19fbc Issue-ID: VNFSDK-305 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java78
1 files changed, 20 insertions, 58 deletions
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 a33fe93..eb9c9da 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
@@ -71,63 +71,29 @@ public class ValidatorSchemaLoader {
}
}
+ private Map<String, ?> readYaml(String fileName) {
+ Yaml yaml = new Yaml();
+ return (Map<String, ?>)yaml.load(this.getClass().getResourceAsStream(fileName));
+ }
+
@SuppressWarnings("unchecked")
private boolean loadResources() throws FileNotFoundException, URISyntaxException {
- URL schemafolder = this.getClass().getClassLoader().getResource("schema");
- try (Stream<Path> paths = Files.walk(Paths.get(schemafolder.toURI()))) {
-
- paths.filter(Files::isRegularFile).forEach((Path e) -> {
-
- File file = e.toFile();
-
- if(!file.isDirectory() && (FilenameUtils.isExtension(file.getName(), "yaml")
- || FilenameUtils.isExtension(file.getName(), "mf")
- || FilenameUtils.isExtension(file.getName(), "meta"))) {
-
- Yaml yaml = new Yaml();
-
- switch(file.getName()) {
- case "TOSCA.meta":
- try {
- toscaMeta = (Map<String, ?>)yaml.load(new FileInputStream(file));
- } catch(ScannerException | FileNotFoundException e1) {
- LOG.error("Schema files %s format is not as per standard prescribed", file.getName(),
- e1);
- }
- break;
- case "CSAR.meta":
- try {
- csarentryd = (Map<String, ?>)yaml.load(new FileInputStream(file));
- } catch(ScannerException | FileNotFoundException e2) {
- LOG.error("Schema files %s format is not as per standard prescribed", file.getName(),
- e2);
- }
- break;
- case "MRF.yaml":
- try {
- mrfYaml = (Map<String, ?>)yaml.load(new FileInputStream(file));
- } catch(ScannerException | FileNotFoundException e2) {
- LOG.error("Schema files %s format is not as per standard prescribed", file.getName(),
- e2);
- }
- break;
- case "MRF.mf":
- try {
- mrfManifest = (Map<String, ?>)yaml.load(new FileInputStream(file));
- } catch(ScannerException | FileNotFoundException e2) {
- LOG.error("Schema files %s format is not as per standard prescribed", file.getName(),
- e2);
- }
- break;
- }
- }
- schemaFileList.add(e.toAbsolutePath().toString());
- });
-
- } catch(NullPointerException | IOException err) {
- LOG.error("Schema files/folder access error" + err);
+ for (String metaFile: new String []{"TOSCA.meta", "CSAR.meta", "MRF.mf" }) {
+ switch(metaFile) {
+ case "TOSCA.meta":
+ toscaMeta = this.readYaml("/schema/" + metaFile);
+ break;
+ case "CSAR.meta":
+ csarentryd = this.readYaml("/schema/" + metaFile);
+ break;
+ case "MRF.yaml":
+ mrfYaml = this.readYaml("/schema/" + metaFile);
+ break;
+ case "MRF.mf":
+ mrfManifest = this.readYaml("/schema/" + metaFile);
+ break;
+ }
}
-
return true;
}
@@ -146,8 +112,4 @@ public class ValidatorSchemaLoader {
public Map<String, ?> getMrfManifest() {
return mrfManifest;
}
-
- public List<String> getSchemaFileList() {
- return schemaFileList;
- }
}