From b970a7b46fac32e626acfa23b1e2de9b22da7ff7 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Wed, 1 Apr 2020 19:58:23 +0000 Subject: SliPluginUtils jsonStringToCtx fix Support null values in jsonStringToCtx in Slipluginutils Issue-ID: CCSDK-2250 Signed-off-by: Smokowski, Kevin (ks6305) Change-Id: I3316fa9e80c9e684fc27d83356bbfad9b1151992 --- .../org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sliPluginUtils/provider/src/main/java') diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java index ce0f50800..60bb4fd31 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliPluginUtils.java @@ -70,6 +70,7 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { private static final String LOG_MSG="extracting list from context memory"; private static final String LOG_MSG1="removing elements from list"; private static final String LENGTH="_length"; + public static final String CTX_NULL_VALUE=""; // ========== CONSTRUCTORS ========== @@ -846,7 +847,11 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { if(!root.endsWith(".")){ root = root + "."; } - ctx.setAttribute(root + key, entry.getValue().getAsString()); + if(entry.getValue().isJsonNull()) { + ctx.setAttribute(root + key, CTX_NULL_VALUE); + }else { + ctx.setAttribute(root + key, entry.getValue().getAsString()); + } } } } @@ -861,6 +866,8 @@ public class SliPluginUtils implements SvcLogicJavaPlugin { handleJsonArray(key, element.getAsJsonArray(), ctx, prefix); } else if (element.isJsonObject()) { writeJsonObject(element.getAsJsonObject(), ctx, prefix + "."); + } else if (element.isJsonNull()) { + ctx.setAttribute(prefix, CTX_NULL_VALUE); } else if (element.isJsonPrimitive()) { ctx.setAttribute(prefix, element.getAsString()); } -- cgit 1.2.3-korg