aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2019-03-11 03:03:57 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-11 03:03:57 +0000
commitd4af899cf464a44492e5f558ea4b6819c073decf (patch)
treea6e5195e4587dc428d4bf531268b557962090abc
parent19cfa60bb0773b99125c25efb8e2a58939d42085 (diff)
parent33231902394988e45ab8bfde466ccf023ca227aa (diff)
Merge changes I1498aca2,I0ae68064
* changes: Fix ignore default param while schema-show Add context to multipart http profile
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandDiscoveryUtils.java2
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java31
2 files changed, 20 insertions, 13 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 8c97bd30..34b82212 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
@@ -299,7 +299,7 @@ public class OnapCommandDiscoveryUtils {
if (deafultResourceMap.containsKey(PARAMETERS)) {
List<Object> params = new ArrayList<>();
for (Map<String, ?> p: (List<Map<String, ?>>) deafultResourceMap.get(PARAMETERS)) {
- if (p.keySet().contains(IS_DEFAULT_PARAM) && (Boolean) p.get(IS_DEFAULT_PARAM)) {
+ if (p.keySet().contains(IS_DEFAULT_PARAM) && !((Boolean) p.get(IS_DEFAULT_PARAM))) {
params.add(p);
}
}
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
index 3afb1961..f4a6cee5 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
@@ -66,25 +66,20 @@ public class OnapCommandHttpUtils {
*/
public static HttpInput populateParameters(Map<String, OnapCommandParameter> params, HttpInput input)
throws OnapCommandException {
+
HttpInput inp = new HttpInput();
+
for (OnapCommandParameter param : params.values()) {
if (OnapCommandParameterType.BINARY.equals(param.getParameterType())) {
inp.setBinaryData(true);
break;
}
}
- inp.setMultipartEntityName(input.getMultipartEntityName());
- inp.setBody(OnapCommandUtils.replaceLineFromInputParameters(input.getBody(), params));
-
- if (input.getMultiparts().size() > 0) {
- for (HttpInput.Part part: input.getMultiparts()) {
- part.setContent(OnapCommandUtils.replaceLineFromInputParameters(part.getContent(), params));
- }
- }
- inp.setMultiparts(input.getMultiparts());
inp.setUri(OnapCommandUtils.replaceLineFromInputParameters(input.getUri(), params));
+
inp.setMethod(input.getMethod().toLowerCase());
+
for (String h : input.getReqHeaders().keySet()) {
String value = input.getReqHeaders().get(h);
inp.getReqHeaders().put(h, OnapCommandUtils.replaceLineFromInputParameters(value, params));
@@ -97,10 +92,22 @@ public class OnapCommandHttpUtils {
boolean isRemoveEmptyNodes = Boolean.parseBoolean(input.getContext().getOrDefault(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES, "false"));
- if (isRemoveEmptyNodes) {
- inp.setBody(OnapCommandHttpUtils.normalizeJson(inp.getBody()));
- }
+ if (input.getMultiparts().size() > 0) {
+ for (HttpInput.Part part: input.getMultiparts()) {
+ part.setContent(OnapCommandUtils.replaceLineFromInputParameters(part.getContent(), params));
+ if (isRemoveEmptyNodes) {
+ part.setContent(OnapCommandHttpUtils.normalizeJson(part.getContent()));
+ }
+ }
+ inp.setMultiparts(input.getMultiparts());
+ } else {
+ inp.setMultipartEntityName(input.getMultipartEntityName());
+ inp.setBody(OnapCommandUtils.replaceLineFromInputParameters(input.getBody(), params));
+ if (isRemoveEmptyNodes) {
+ inp.setBody(OnapCommandHttpUtils.normalizeJson(inp.getBody()));
+ }
+ }
return inp;
}