aboutsummaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-03-27 11:19:57 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-27 11:19:57 +0000
commit4debf9645be8400ac9b6a087b1d9d829f5ee924a (patch)
treebc8c1706e842b3b2ef042553672253082e3e74da /framework
parent1728b94a35c33719e87c664ecc726db4b07dc20c (diff)
parentf3d14df9c66cef6ea1eb84d542fbc47dd6e0d7fc (diff)
Merge changes Iffcf11d8,If61f2f73,I382d6ece,Ib24080e7,Iafbe217a, ...
* changes: CLI: policy-operational-create CLI: policy-list CLI: policy-config-create CLI: policy-push Correct policy auth CLI yaml Macro fails to subsitute map param
Diffstat (limited to 'framework')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java38
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java20
2 files changed, 41 insertions, 17 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 9bdd8a51..b10629f4 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
@@ -16,27 +16,43 @@
package org.onap.cli.fw.utils;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_DIRECTORY;
+import static org.onap.cli.fw.conf.OnapCommandConstants.DATA_PATH_JSON_PATTERN;
+import static org.onap.cli.fw.conf.OnapCommandConstants.DISCOVERY_FILE;
+import static org.onap.cli.fw.conf.OnapCommandConstants.NAME;
+import static org.onap.cli.fw.conf.OnapCommandConstants.OPEN_CLI_SAMPLE_VERSION;
+import static org.onap.cli.fw.conf.OnapCommandConstants.OPEN_CLI_SCHEMA_VERSION;
+import static org.onap.cli.fw.conf.OnapCommandConstants.SCHEMA_DIRECTORY;
+import static org.onap.cli.fw.conf.OnapCommandConstants.SCHEMA_PATH_PATERN;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.ServiceLoader;
+
import org.apache.commons.io.FileUtils;
import org.onap.cli.fw.cmd.OnapCommand;
import org.onap.cli.fw.conf.OnapCommandConfig;
import org.onap.cli.fw.conf.OnapCommandConstants;
-import org.onap.cli.fw.error.*;
-import org.onap.cli.fw.registrar.OnapCommandRegistrar;
+import org.onap.cli.fw.error.OnapCommandDiscoveryFailed;
+import org.onap.cli.fw.error.OnapCommandException;
+import org.onap.cli.fw.error.OnapCommandInstantiationFailed;
+import org.onap.cli.fw.error.OnapCommandInvalidSample;
+import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import org.onap.cli.fw.schema.OnapCommandSchemaInfo;
-import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.yaml.snakeyaml.Yaml;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import static org.onap.cli.fw.conf.OnapCommandConstants.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class OnapCommandDiscoveryUtils {
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 c5ebbc21..accea717 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
@@ -39,6 +39,8 @@ import org.onap.cli.fw.input.OnapCommandParameterType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
/**
@@ -247,18 +249,24 @@ public class OnapCommandUtils {
throw new OnapCommandParameterNotFound(paramName);
}
- String value = params.get(paramName).getValue().toString();
-
OnapCommandParameter param = params.get(paramName);
if (OnapCommandParameterType.ARRAY.equals(param.getParameterType())
- || OnapCommandParameterType.MAP.equals(param.getParameterType())
|| OnapCommandParameterType.JSON.equals(param.getParameterType())
|| OnapCommandParameterType.YAML.equals(param.getParameterType())) {
// ignore the front and back double quotes in json body
- result += line.substring(currentIdx, idxS - 1) + value;
+ result += line.substring(currentIdx, idxS - 1) + params.get(paramName).getValue().toString();
+ currentIdx = idxE + 2;
+ } else if (OnapCommandParameterType.MAP.equals(param.getParameterType())) {
+ try {
+ String value = new ObjectMapper().writeValueAsString(params.get(paramName).getValue());
+ result += line.substring(currentIdx, idxS - 1) + value;
+ } catch (JsonProcessingException e) { // NOSONAR
+ //never occur as map is coverted to json string here
+ }
+
currentIdx = idxE + 2;
- } else {
- result += line.substring(currentIdx, idxS) + value;
+ }else {
+ result += line.substring(currentIdx, idxS) + params.get(paramName).getValue().toString();
currentIdx = idxE + 1;
}
}