summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-08 00:23:11 -0500
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-03-08 10:47:51 -0500
commit50368411fba4fca7efdc5341f9d485ff821eee2c (patch)
treecfae840cf398b41d1e5492ddd6706b58c99e84de /adapters/mso-adapter-utils/src/main
parente4ecd51f615f81fca7567aac583892a32f6a4c3f (diff)
only convert object type json when String
only convert object type json when input is a String Change-Id: I465dfe905f5d85de583b6232640dc4dc13a09c7a Issue-ID: SO-1610 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java20
2 files changed, 18 insertions, 8 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
index f50a6fd1bd..97e1627fd3 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/cloudify/utils/MsoCloudifyUtils.java
@@ -1047,7 +1047,11 @@ public class MsoCloudifyUtils extends MsoCommonUtils implements VduPlugin{
}
} else if (type.equalsIgnoreCase("json")) {
try {
- return JSON_MAPPER.writeValueAsString(inputValue);
+ if (inputValue instanceof String) {
+ return JSON_MAPPER.readTree(inputValue.toString());
+ }
+ //will already marshal to json without intervention
+ return inputValue;
}
catch (Exception e) {
logger.debug("Unable to convert {} to a JsonNode!", inputValue);
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index a0fbd485d1..012c560689 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -38,6 +38,8 @@ import com.woorea.openstack.keystone.Keystone;
import com.woorea.openstack.keystone.model.Access;
import com.woorea.openstack.keystone.model.Authentication;
import com.woorea.openstack.keystone.utils.KeystoneUtils;
+
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -1356,18 +1358,22 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{
}
} else if ("json".equalsIgnoreCase(type)) {
Object jsonObj = inputs.get(key);
- String jsonString;
+ Object json;
try {
- jsonString = JSON_MAPPER.writeValueAsString(jsonObj);
- } catch (JsonProcessingException e) {
+ if (jsonObj instanceof String) {
+ json = JSON_MAPPER.readTree(jsonObj.toString());
+ } else {
+ //will already marshal to json without intervention
+ json = jsonObj;
+ }
+ } catch (IOException e) {
logger.error("failed to map to json, directly converting to string instead", e);
- jsonString = jsonObj.toString();
+ json = jsonObj.toString();
}
if (alias)
- newInputs.put(realName, jsonString);
+ newInputs.put(realName, json);
else
- newInputs.put(key, jsonString);
- //}
+ newInputs.put(key, json);
} else if ("comma_delimited_list".equalsIgnoreCase(type)) {
String commaSeparated = inputs.get(key).toString();
try {