summaryrefslogtreecommitdiffstats
path: root/profiles/http/src
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-07 21:49:34 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-07 21:49:34 +0530
commitd9742adbfee81f25fb83a517353fd2810ce41c91 (patch)
treeb4385c554030a74ed8946e2d7f9ce50d50e43466 /profiles/http/src
parentf6c8240d32fadd879127644c54bd5c62413319ce (diff)
Add context to multipart http profile
Issue-ID: CLI-129 Change-Id: I0ae68064e776607cacc1985bd02df04c918e0d08 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles/http/src')
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java31
1 files changed, 19 insertions, 12 deletions
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;
}