diff options
author | Dan Timoney <dtimoney@att.com> | 2021-10-29 15:04:35 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-10-29 15:04:41 -0400 |
commit | 1267516ac4ce6402a0d175328563d5557fd59c96 (patch) | |
tree | 0ed5d136977ea47f531412fd02941d627e35f03e /plugins | |
parent | 9bdc825f7b9c1689aae71fcb01bf08aa6bcba995 (diff) |
Sync local changes to support GRA microservice
Sync changes made downstream to support GRA microservice
Issue-ID: CCSDK-3504
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I854b5437c4a60023bd161e3625e08ff6e0771945
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java index 60d43df7a..80d263730 100644 --- a/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java +++ b/plugins/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/JsonParser.java @@ -25,6 +25,9 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.apache.commons.lang3.StringUtils; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; @@ -118,9 +121,27 @@ public final class JsonParser { Object o = wm.get(key); wm.remove(key); - if (o instanceof Boolean || o instanceof Number || o instanceof String) { + if (o instanceof Boolean || o instanceof Number ) { mm.put(key, o.toString()); log.info("Added property: {} : {}", key, o.toString()); + } else if (o instanceof String) { + String value = o.toString(); + Pattern p = Pattern.compile("\\$\\{(\\w+)((?:\\:\\-)([^\\}]*))?\\}"); + Matcher m = p.matcher(value); + + StringBuffer sb = new StringBuffer(); + while (m.find()) { + String envVarName = null == m.group(1) ? m.group(2) : m.group(1); + String envVarDefault = null == m.group(3) ? "" : m.group(3); + String envVarValue = System.getenv(envVarName); + + m.appendReplacement(sb, + null == envVarValue ? Matcher.quoteReplacement(envVarDefault) : Matcher.quoteReplacement(envVarValue)); + } + m.appendTail(sb); + value = sb.toString(); + mm.put(key, value); + log.info("Added property: {} : {}", key, value); } else if (o instanceof JSONObject) { JSONObject jo = (JSONObject) o; Iterator<String> i = jo.keys(); |