From 717f6901b358d06de252ea7a3e4e475746f1fba6 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Tue, 13 Mar 2018 12:55:23 +0530 Subject: remove empty json nodes Issue-ID: CLI-101 Change-Id: I0e091e1289450f4e848933eebf9e6fb6801500a3 Signed-off-by: Kanagaraj Manickam k00365106 --- .../cli/fw/http/schema/OnapCommandSchemaHttpLoader.java | 13 +++++++++++-- .../org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'profiles') 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 973c4ae1..43772e56 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 @@ -133,9 +133,18 @@ public class OnapCommandSchemaHttpLoader { cmd.getInput().setReqQueries(query); break; case OnapCommandHttpConstants.CONTEXT: - Map context = (Map) map.get(key2); + Map context = (Map) map.get(key2); + + for (String key: context.keySet()) { + switch (key) { + case OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES: + Boolean flag = (Boolean) context.get(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES); + cmd.getInput().getContext().put(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES, flag.toString()); + break; + } + } + - cmd.getInput().getContext().putAll(context); break; case OnapCommandHttpConstants.MULTIPART_ENTITY_NAME: Object multipartEntityName = map.get(key2); 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 43a80181..b77b85da 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 @@ -89,7 +89,7 @@ public class OnapCommandHttpUtils { boolean isRemoveEmptyNodes = Boolean.parseBoolean(input.getContext().getOrDefault(OnapCommandHttpConstants.CONTEXT_REMOVE_EMPTY_JSON_NODES, "false")); if (isRemoveEmptyNodes) { - input.setBody(OnapCommandHttpUtils.normalizeJson(input.getBody())); + inp.setBody(OnapCommandHttpUtils.normalizeJson(input.getBody())); } return inp; -- cgit 1.2.3-korg