aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java38
1 files changed, 28 insertions, 10 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
index 614eb2a9..4cb95290 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java
@@ -290,12 +290,7 @@ public class OnapCommandDiscoveryUtils {
Map<String, ?> deafultResourceMap;
for (Resource resource : deafultRres) {
- try {
- deafultResourceMap = loadYaml(resource);
- } catch (OnapCommandException e) {
- OnapCommandUtils.log.error("Ignores invalid schema " + resource.getURI().toString(), e);
- continue;
- }
+ deafultResourceMap = loadYaml(resource, true);
if (deafultResourceMap != null && deafultResourceMap.size() > 0) {
//default_input_parameters_http.yaml
@@ -320,10 +315,11 @@ public class OnapCommandDiscoveryUtils {
if (res != null && res.length > 0) {
for (Resource resource : res) {
Map<String, ?> resourceMap;
- try {
+ try { //NOSONAR
resourceMap = loadYaml(resource);
} catch (OnapCommandException e) {
- OnapCommandUtils.log.error("Ignores invalid schema " + resource.getURI().toString(), e);
+ String resourceURI = resource.getURI().toString();
+ OnapCommandUtils.log.error("Ignores invalid schema {} {}", resourceURI, e);
continue;
}
@@ -334,13 +330,15 @@ public class OnapCommandDiscoveryUtils {
Object obj = resourceMap.get(OPEN_CLI_SCHEMA_VERSION);
if (obj == null) {
- OnapCommandUtils.log.info("Invalid Schema yaml {}" + schema.getSchemaURI());
+ String schemaURI = schema.getSchemaURI();
+ OnapCommandUtils.log.info("Invalid Schema yaml {}", schemaURI);
}
else{
schema.setVersion(obj.toString());
if (!schema.getVersion().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION_VALUE_1_0)) {
- OnapCommandUtils.log.info("Unsupported Schema version found {} " + schema.getSchemaURI());
+ String schemaURI = schema.getSchemaURI();
+ OnapCommandUtils.log.info("Unsupported Schema version found {} " + schemaURI);
}
else{
@@ -551,6 +549,26 @@ public class OnapCommandDiscoveryUtils {
/**
* Get schema map.
*
+ * @param resource
+ * resource obj
+ * ignoreInvalidSchema boolean
+ * @return map
+ * @throws OnapCommandInvalidSchema
+ * exception
+ */
+ public static Map<String, ?> loadYaml(Resource resource, boolean ignoreInvalidSchema) throws OnapCommandInvalidSchema, IOException {
+ Map<String, ?> values = null;
+ try {
+ values = loadYaml(resource.getInputStream());
+ } catch (OnapCommandException | IOException e) {
+ OnapCommandUtils.log.error("Ignores invalid schema {} {}", resource.getURI(), e);
+ }
+ return values;
+ }
+
+ /**
+ * Get schema map.
+ *
* @param filePath
* @return map
* @throws OnapCommandInvalidSchema