summaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/main
diff options
context:
space:
mode:
authorshashikanth.vh <shashikanth.vh@huawei.com>2018-10-04 10:40:18 +0530
committerShashikanth VH <shashikanth.vh@huawei.com>2018-10-04 05:44:01 +0000
commit87850a15d93c7a1162d30c129e0dc76cd1b66f94 (patch)
tree0b36c249eb31684a3f0338eadbbf3f0b544bc939 /restapi-call-node/provider/src/main
parent99931b9cae6e0e02cf54060ac0f1199aad92537a (diff)
Add mandatory empty construct to json template
Restapicallnode remove empty parameter from json template, if template mandates empty parameter to be present then it should not be removed. Change-Id: I075e0858f956eb3aff87d2a7387b55caa3310568 Issue-ID: CCSDK-607 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'restapi-call-node/provider/src/main')
-rw-r--r--restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java3
-rw-r--r--restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java11
2 files changed, 10 insertions, 4 deletions
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
index e5503435b..9a89af6b5 100644
--- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
+++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
@@ -392,6 +392,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
throws SvcLogicException {
log.info("Building {} started", format);
long t1 = System.currentTimeMillis();
+ String originalTemplate = template;
template = expandRepeats(ctx, template, 1);
@@ -439,7 +440,7 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
}
String req = format == Format.XML
- ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(ss.toString());
+ ? XmlJsonUtil.removeEmptyStructXml(ss.toString()) : XmlJsonUtil.removeEmptyStructJson(originalTemplate, ss.toString());
if (format == Format.JSON) {
req = XmlJsonUtil.removeLastCommaJson(req);
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
index 8a0ca8d94..4712b4298 100644
--- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
+++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
@@ -272,7 +272,7 @@ public final class XmlJsonUtil {
return sb.toString();
}
- public static String removeEmptyStructJson(String s) {
+ public static String removeEmptyStructJson(String template, String s) {
int k = 0;
while (k < s.length()) {
boolean curly = true;
@@ -304,8 +304,13 @@ public final class XmlJsonUtil {
if (i5 < 0)
i5 = s.length();
- s = s.substring(0, i4) + s.substring(i5);
- k = 0;
+ /*If template mandates empty construct to be present, those should not be removed.*/
+ if ((template != null) && template.contains(s.substring(i4))) {
+ k = i1 + 1;
+ } else {
+ s = s.substring(0, i4) + s.substring(i5);
+ k = 0;
+ }
} else
k = i1 + 1;
} else