aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java1
-rw-r--r--framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java9
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java10
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java4
-rw-r--r--main/src/main/java/org/onap/cli/main/OnapCli.java4
-rw-r--r--main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java6
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java29
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java16
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java2
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java1
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java11
-rw-r--r--profiles/snmp/src/test/resources/log4j.properties23
12 files changed, 67 insertions, 49 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
index 019ce5c6..fd1ddbaf 100644
--- a/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
+++ b/framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
@@ -32,7 +32,6 @@ import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandOutputPrintingFailed;
import org.onap.cli.fw.output.OnapCommandPrintDirection;
-import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
diff --git a/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java b/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
index 34dc6b6d..6ea1931a 100644
--- a/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
+++ b/framework/src/main/java/org/onap/cli/fw/registrar/OnapCommandRegistrar.java
@@ -56,7 +56,7 @@ import java.util.Set;
*/
public class OnapCommandRegistrar {
- private static Logger LOG = LoggerFactory.getLogger(OnapCommandRegistrar.class);
+ private static Logger log = LoggerFactory.getLogger(OnapCommandRegistrar.class);
private Map<String, Class<? extends OnapCommand>> registry = new HashMap<>();
@@ -113,10 +113,9 @@ public class OnapCommandRegistrar {
*
* @param name Command Name
* @param cmd Command Class
- * @throws OnapCommandInvalidRegistration Invalid registration exception
* @throws OnapCommandRegistrationProductInfoMissing
*/
- private void register(String name, String version, Class<? extends OnapCommand> cmd) throws OnapCommandInvalidRegistration, OnapCommandRegistrationProductInfoMissing {
+ private void register(String name, String version, Class<? extends OnapCommand> cmd) throws OnapCommandRegistrationProductInfoMissing {
if (version == null || version.isEmpty()) {
throw new OnapCommandRegistrationProductInfoMissing(name);
}
@@ -278,7 +277,7 @@ public class OnapCommandRegistrar {
for (OnapCommandSchemaInfo schema : schemas) {
if (schema.isIgnore()) {
- LOG.info("Ignoring schema " + schema.getSchemaURI());
+ log.info("Ignoring schema " + schema.getSchemaURI());
continue;
}
@@ -288,7 +287,7 @@ public class OnapCommandRegistrar {
} else if (plugins.containsKey(schema.getSchemaProfile())) {
this.register(schema.getCmdName(), schema.getProduct(), plugins.get(schema.getSchemaProfile()));
} else {
- LOG.info("Ignoring schema " + schema.getSchemaURI());
+ log.info("Ignoring schema " + schema.getSchemaURI());
}
}
}
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 b10629f4..26d49650 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
@@ -252,7 +252,7 @@ public class OnapCommandDiscoveryUtils {
try {
resourceMap = loadYaml(resource);
} catch (OnapCommandException e) {
- OnapCommandUtils.LOG.error("Ignores invalid schema " + resource.getURI().toString(), e);
+ OnapCommandUtils.log.error("Ignores invalid schema " + resource.getURI().toString(), e);
continue;
}
@@ -263,14 +263,14 @@ public class OnapCommandDiscoveryUtils {
Object obj = resourceMap.get(OPEN_CLI_SCHEMA_VERSION);
if (obj == null) {
- OnapCommandUtils.LOG.info("Invalid Schema yaml " + schema.getSchemaURI());
+ 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)) {
- OnapCommandUtils.LOG.info("Unsupported Schema version found " + schema.getSchemaURI());
+ OnapCommandUtils.log.info("Unsupported Schema version found " + schema.getSchemaURI());
continue;
}
@@ -331,12 +331,12 @@ public class OnapCommandDiscoveryUtils {
Object sampleVersion = infoMap.get(OPEN_CLI_SAMPLE_VERSION);
if (sampleVersion == null) {
- OnapCommandUtils.LOG.info("Invalid Sample yaml " + sampleResourse.getURI().toString());
+ 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());
+ OnapCommandUtils.log.info("Unsupported Sample version found " + sampleResourse.getURI().toString());
return;
}
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index db89e067..879e6289 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -51,7 +51,7 @@ import com.jayway.jsonpath.JsonPath;
*/
public class OnapCommandUtils {
- static Logger LOG = LoggerFactory.getLogger(OnapCommandUtils.class);
+ static Logger log = LoggerFactory.getLogger(OnapCommandUtils.class);
/**
* Private constructor.
*/
@@ -340,7 +340,7 @@ public class OnapCommandUtils {
* @param to
* @throws OnapCommandException
*/
- public static void copyParamSchemasFrom(OnapCommand from, OnapCommand to) throws OnapCommandException {
+ public static void copyParamSchemasFrom(OnapCommand from, OnapCommand to) {
for (OnapCommandParameter param: from.getParameters()) {
if (!to.getParametersMap().containsKey(param.getName())) {
to.getParameters().add(param);
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 43fa72ed..cf87c19a 100644
--- a/main/src/main/java/org/onap/cli/main/OnapCli.java
+++ b/main/src/main/java/org/onap/cli/main/OnapCli.java
@@ -56,7 +56,7 @@ import java.util.Optional;
*/
public class OnapCli {
- private static Logger LOG = LoggerFactory.getLogger(OnapCli.class);
+ private static Logger log = LoggerFactory.getLogger(OnapCli.class);
private List<String> args = new ArrayList<>();
@@ -87,7 +87,7 @@ public class OnapCli {
private void print(Throwable throwable) {
this.print(throwable.getMessage() != null ? throwable.getMessage() : "");
- LOG.error(throwable.getMessage(), throwable);
+ log.error(throwable.getMessage(), throwable);
}
private String getShortOption(String opt) {
diff --git a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
index 4389a8cc..edacc68b 100644
--- a/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
+++ b/main/src/main/java/org/onap/cli/main/conf/OnapCliConstants.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Huawei Technologies Co., Ltd.
+ * Copyright 2017-18 Huawei Technologies Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,13 +42,13 @@ public final class OnapCliConstants {
public static final String PARAM_INTERACTIVE_USE_MSG = "To set the current product version, more details please check version";
public static final String PARAM_INTERACTIVE_HELP = "help";
public static final String PARAM_INTERACTIVE_HELP_MSG = "To get the help details of supported commands";
- public static final String PARAM_INTERACTIVE_VERSION = "version";
+ public static final String PARAM_INTERACTIVE_VERSION = PARAM_VERSION_LONG;
public static final String PARAM_INTERACTIVE_VERSION_MSG = "To see the version details";
public static final String PARAM_INTERACTIVE_SET = "set";
public static final String PARAM_INTERACTIVE_SET_MSG = "To set the parameter values. Once its set, will be available for all commands in current session.";
public static final String PARAM_INTERACTIVE_UNSET = "unset";
public static final String PARAM_INTERACTIVE_UNSET_MSG = "To unset the parameter value in current session.";
- public static final String PARAM_INTERACTIVE_PROFILE = "profile";
+ public static final String PARAM_INTERACTIVE_PROFILE = PARAM_PROFILE_LONG;
public static final String PARAM_INTERACTIVE_PROFILE_MSG = "Start profiling current settings made of use, set.";
public static final String PARAM_INTERACTIVE_ARG_SPLIT_PATTERN = "\\s+";
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
index f6e58757..f0fe43cd 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
@@ -15,30 +15,29 @@
*/
package org.onap.cli.fw.http.mock;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.dreamhead.moco.HttpServer;
-import com.github.dreamhead.moco.Moco;
-import com.github.dreamhead.moco.ResponseHandler;
-import com.github.dreamhead.moco.Runner;
+import static com.github.dreamhead.moco.Runner.runner;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.onap.cli.fw.conf.OnapCommandConfig;
import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandDiscoveryFailed;
import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import org.onap.cli.fw.http.conf.OnapCommandHttpConstants;
-import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils;
import org.springframework.core.io.Resource;
import org.yaml.snakeyaml.Yaml;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.github.dreamhead.moco.Runner.runner;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.dreamhead.moco.HttpServer;
+import com.github.dreamhead.moco.Moco;
+import com.github.dreamhead.moco.ResponseHandler;
+import com.github.dreamhead.moco.Runner;
public class MocoServer {
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index 2cfb5206..1a13819a 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -47,6 +47,8 @@ import net.minidev.json.JSONObject;
public class OnapCommandSchemaHttpLoader {
+ private static final String ATTRIBUTE = "Attribute '";
+
private OnapCommandSchemaHttpLoader() {
// to follow standards !
}
@@ -174,15 +176,15 @@ public class OnapCommandSchemaHttpLoader {
validationMap.put(OnapCommandHttpConstants.AUTH, OnapCommandHttpConstants.AUTH_VALUES);
validationMap.put(OnapCommandHttpConstants.MODE, OnapCommandHttpConstants.MODE_VALUES);
- for (String secKey : validationMap.keySet()) {
- if (serviceMap.containsKey(secKey)) {
- Object obj = serviceMap.get(secKey);
+ for (Map.Entry<String, String> secKey : validationMap.entrySet()) {
+ if (serviceMap.containsKey(secKey.getKey())) {
+ Object obj = serviceMap.get(secKey.getKey());
if (obj == null) {
- errorList.add("Attribute '" + secKey + "' under '" + OnapCommandHttpConstants.SERVICE + "' is empty");
+ errorList.add(ATTRIBUTE + secKey.getKey() + "' under '" + OnapCommandHttpConstants.SERVICE + "' is empty");
} else {
String value = String.valueOf(obj);
- if (!OnapCommandConfig.getCommaSeparatedList(validationMap.get(secKey)).contains(value)) {
- errorList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
+ if (!OnapCommandConfig.getCommaSeparatedList(validationMap.get(secKey.getKey())).contains(value)) {
+ errorList.add(ATTRIBUTE + secKey.getKey() + "' contains invalid value. Valide values are "
+ OnapCommandConfig.getCommaSeparatedList(validationMap.get(key1))); //
}
}
@@ -288,7 +290,7 @@ public class OnapCommandSchemaHttpLoader {
String method = (String) requestMap.get(OnapCommandHttpConstants.METHOD);
if (method != null && !method.isEmpty()) {
if (!OnapCommandConfig.getCommaSeparatedList(OnapCommandHttpConstants.HTTP_METHODS).contains(method.toLowerCase())) {
- errorList.add("Attribute '" + OnapCommandHttpConstants.METHOD + "' under '" + OnapCommandHttpConstants.REQUEST + "' is invalid, correct types are "
+ errorList.add(ATTRIBUTE + OnapCommandHttpConstants.METHOD + "' under '" + OnapCommandHttpConstants.REQUEST + "' is invalid, correct types are "
+ OnapCommandConfig.getCommaSeparatedList(OnapCommandHttpConstants.HTTP_METHODS).toString());
}
} else {
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
index 1ee1b200..ed88b0c6 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
@@ -60,7 +60,7 @@ public class OnapSnmpCommand extends OnapCommand {
super.addDefaultSchemas(OnapCommandSnmpConstants.DEFAULT_PARAMETER_SNMP_FILE_NAME);
}
- private String getAgent() throws OnapCommandException {
+ private String getAgent() {
OnapCommandParameter onapCommandParameter = this.getParametersMap().get(OnapCommandSnmpConstants.SNMP_AGENT);
return (String) onapCommandParameter.getValue();
}
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
index 87b9241f..35d6425e 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
@@ -16,7 +16,6 @@
package org.onap.cli.fw.snmp.exception;
-import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
/**
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
index 87cde127..b2af9ae6 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
@@ -16,19 +16,16 @@
package org.onap.cli.fw.snmp.schema;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import org.onap.cli.fw.conf.OnapCommandConfig;
-import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.onap.cli.fw.snmp.cmd.OnapSnmpCommand;
import org.onap.cli.fw.snmp.conf.OnapCommandSnmpConstants;
import org.onap.cli.fw.utils.OnapCommandUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class OnapCommandSchemaSnmpLoader {
private static List<String> validateSnmpSchemaSection(Map<String, Object> values) {
diff --git a/profiles/snmp/src/test/resources/log4j.properties b/profiles/snmp/src/test/resources/log4j.properties
new file mode 100644
index 00000000..78f32285
--- /dev/null
+++ b/profiles/snmp/src/test/resources/log4j.properties
@@ -0,0 +1,23 @@
+# Copyright 2018 Huawei Technologies Co., Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=ERROR, stdout
+
+log4j.logger.org.onap.cli=DEBUG, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n