From 5c7797aeec86fa06aa1a128f57eaf596e0fe482d Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 23 Mar 2018 12:55:51 +0530 Subject: Ignore null on console Issue-ID: CLI-104 Change-Id: I8fbe6c64355fbd27ef87c2c86ef6b5e8498e99a4 Signed-off-by: Kanagaraj Manickam k00365106 --- main/src/main/java/org/onap/cli/main/OnapCli.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/src/main/java/org/onap/cli/main/OnapCli.java b/main/src/main/java/org/onap/cli/main/OnapCli.java index e70c7186..3ba75711 100644 --- a/main/src/main/java/org/onap/cli/main/OnapCli.java +++ b/main/src/main/java/org/onap/cli/main/OnapCli.java @@ -86,7 +86,7 @@ public class OnapCli { } private void print(Throwable throwable) { - this.print(throwable.getMessage()); + this.print(throwable.getMessage() != null ? throwable.getMessage() : ""); LOG.error(throwable.getMessage(), throwable); } -- cgit 1.2.3-korg From 2717e5498e7fd64fe53aabfa98de4930cb27ab3a Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 23 Mar 2018 12:56:27 +0530 Subject: Ignore invalid schemas Issue-ID: CLI-105 Change-Id: Ie8684832dacb8ce9726737ddb38373001d0f1f14 Signed-off-by: Kanagaraj Manickam k00365106 --- .../main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java | 5 +++++ 1 file changed, 5 insertions(+) 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 2b3cf941..1732772e 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 @@ -246,6 +246,11 @@ public class OnapCommandDiscoveryUtils { schema.setSchemaURI(resource.getURI().toString()); Object obj = resourceMap.get(OPEN_CLI_SCHEMA_VERSION); + if (obj == null) { + OnapCommandUtils.LOG.info("Invalid Schema yaml " + schema.getSchemaURI()); + continue; + } + schema.setVersion(obj.toString()); if (!schema.getVersion().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION_VALUE_1_0)) { -- cgit 1.2.3-korg From 7247c4f691efcb104fea7287ac9df541125655ee Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 23 Mar 2018 13:15:14 +0530 Subject: Add validation for sample file schema Issue-ID: CLI-105 Change-Id: I748662f8f3760d9b38f1920bfadf82a210ddc3de Signed-off-by: Kanagaraj Manickam k00365106 --- .../java/org/onap/cli/fw/conf/OnapCommandConstants.java | 3 +++ .../org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java index c2bfc1d5..6f1741e5 100644 --- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java +++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java @@ -45,6 +45,7 @@ public class OnapCommandConstants { //schema public static final String OPEN_CLI_SCHEMA_VERSION = "open_cli_schema_version"; public static final String OPEN_CLI_SCHEMA_VERSION_VALUE_1_0 = "1.0"; + public static final String NAME = "name"; public static final String DESCRIPTION = "description"; @@ -148,6 +149,8 @@ public class OnapCommandConstants { public static final String SAMPLE_GEN_ENABLED = "cli.sample.gen.enable"; public static final String SAMPLE_GEN_TARGET_FOLDER = "cli.sample.gen.target"; + public static final String OPEN_CLI_SAMPLE_VERSION = "open_cli_sample_version"; + public static final String OPEN_CLI_SAMPLE_VERSION_VALUE_1_0 = "1.0"; public static final String VERIFY_SAMPLES_DIRECTORY = "open-cli-sample"; public static final String VERIFY_SAMPLES_FILE_PATTERN = VERIFY_SAMPLES_DIRECTORY + YAML_PATTERN; public static final String VERIFY_SAMPLES_MOCK_PATTERN = VERIFY_SAMPLES_DIRECTORY + JSON_PATTERN; 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 1732772e..d0789d74 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 @@ -303,6 +303,22 @@ public class OnapCommandDiscoveryUtils { private static void updateSchemaInfoWithSample(Resource sampleResourse, List schemaInfos) throws OnapCommandInvalidSchema, IOException { Map infoMap = loadSchema(sampleResourse); + + if (infoMap == null) { + return; + } + + Object sampleVersion = infoMap.get(OPEN_CLI_SAMPLE_VERSION); + if (sampleVersion == null) { + OnapCommandUtils.LOG.info("Invalid Sample yaml " + sampleResourse.getURI().toString()); + return; + } + + if (!sampleVersion.toString().equalsIgnoreCase(OnapCommandConstants.OPEN_CLI_SAMPLE_VERSION_VALUE_1_0)) { + OnapCommandUtils.LOG.info("Unsupported Sample version found " + sampleResourse.getURI().toString()); + return; + } + String cmdName = (String) infoMap.get(OnapCommandConstants.VERIFY_CMD_NAME); String version = (String) infoMap.get(OnapCommandConstants.VERIFY_CMD_VERSION); -- cgit 1.2.3-korg