summaryrefslogtreecommitdiffstats
path: root/plugins/restapi-call-node/provider/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/restapi-call-node/provider/src/main/java')
-rwxr-xr-xplugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java3
-rw-r--r--plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java12
2 files changed, 11 insertions, 4 deletions
diff --git a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
index 5756d4e58..4236055dc 100755
--- a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
+++ b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
@@ -613,8 +613,9 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
}
String var1 = template.substring(i1 + 2, i2);
+ boolean keepEmpty = var1.startsWith("~");
String value1 = format == Format.XML ? XmlJsonUtil.getXml(mm, var1) : XmlJsonUtil.getJson(mm, var1);
- if (value1 == null) {
+ if (value1 == null || (value1.trim().length() == 0 && !keepEmpty)) {
// delete the whole element (line)
int i3 = template.lastIndexOf('\n', i1);
if (i3 < 0) {
diff --git a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
index 9870221d7..d6ef7463a 100644
--- a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
+++ b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/XmlJsonUtil.java
@@ -51,6 +51,12 @@ public final class XmlJsonUtil {
}
public static String getJson(Map<String, String> varmap, String var) {
+ boolean keepEmpty = false;
+ if (var.startsWith("~")) {
+ var = var.substring(1);
+ keepEmpty = true;
+ }
+
boolean escape = true;
if (var.startsWith("'")) {
var = var.substring(1);
@@ -64,7 +70,7 @@ public final class XmlJsonUtil {
}
Object o = createStructure(varmap, var);
- return generateJson(o, escape, quotes);
+ return generateJson(o, escape, quotes, keepEmpty);
}
private static Object createStructure(Map<String, String> flatmap, String var) {
@@ -286,11 +292,11 @@ public final class XmlJsonUtil {
return null;
}
- private static String generateJson(Object o, boolean escape, boolean quotes) {
+ private static String generateJson(Object o, boolean escape, boolean quotes, boolean keepEmpty) {
if (o == null) {
return null;
}
- if (o instanceof String && ((String) o).length() == 0) {
+ if (o instanceof String && ((String) o).length() == 0 && !keepEmpty) {
return null;
}