summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src/main/java/org/onap
diff options
context:
space:
mode:
authorAvinashS <avinash.s@huawei.com>2017-11-02 11:31:34 +0000
committerAvinashS <avinash.s@huawei.com>2017-11-02 11:33:37 +0000
commit3bbbadc34cb19b20209a84ec36453fd4b3a73bd1 (patch)
tree26c0a9011eb5d3f7ba722294f58589cafa6e8147 /csarvalidation/src/main/java/org/onap
parent821363de13b07538ad455424ee4cd142c5bd1a6d (diff)
Validate against as per defined
attributes Fix CSIT with runtime context path check. Change-Id: Ie5210606bddf589d93608f25eb04856b1a3b7517 Issue-Id: VNFSDK-118 Signed-off-by: AvinashS <avinash.s@huawei.com>
Diffstat (limited to 'csarvalidation/src/main/java/org/onap')
-rw-r--r--csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java34
1 files changed, 15 insertions, 19 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 215700d..7d9c8c1 100644
--- a/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
+++ b/csarvalidation/src/main/java/org/onap/validation/csar/ValidatorSchemaLoader.java
@@ -26,6 +26,9 @@ import java.util.*;
import org.apache.commons.io.FilenameUtils;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.scanner.ScannerException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.Path;
public class ValidatorSchemaLoader {
@@ -62,22 +65,14 @@ public class ValidatorSchemaLoader {
private boolean loadResources() throws FileNotFoundException {
try {
- if(System.getProperty("os.name").contains("win")) {
- schema_folder = "schema\\";
- }
- else {
- schema_folder = "schema/";
- }
-
- ClassLoader classLoader = getClass().getClassLoader();
- final InputStream is = classLoader.getResourceAsStream(schema_folder);
- final InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
- final BufferedReader br = new BufferedReader(isr);
-
- br.lines().filter(Objects::nonNull)
- .forEach((String e) -> {
-
- File file = new File(getClass().getClassLoader().getResource(schema_folder+ e.toString()).getFile());
+ String schema_folder = getClass().getResource("../../../../schema").getPath();
+
+ Files.walk(Paths.get(schema_folder))
+ .filter(Files::isRegularFile)
+ .forEach((Path e) -> {
+
+ File file = e.toFile();
+
if (!file.isDirectory() && (
FilenameUtils.isExtension(file.getName(), "yaml") ||
FilenameUtils.isExtension(file.getName(), "mf") ||
@@ -116,10 +111,11 @@ public class ValidatorSchemaLoader {
break;
}
}
- schemaFileList.add(e);
+ schemaFileList.add(e.toAbsolutePath().toString());
});
- } catch (NullPointerException e) {
- LOG.error("Schema files/folder access error"+e);
+
+ } catch (NullPointerException | IOException err) {
+ LOG.error("Schema files/folder access error"+err);
}
return true;