From effaf6e52639284b18b2359bde7691c713688407 Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 14 Aug 2020 14:00:56 +0800 Subject: policy upgrade Issue-ID: DCAEGEN2-2198 Signed-off-by: Kai Lu Change-Id: I192bf2b926b1227754235d9646ae744c7d1d15ae --- .../ConfigBindingServiceEnvironmentPostProcessor.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'dcae-analytics/dcae-analytics-web/src/main/java/org') diff --git a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java index b809858..453cd9c 100644 --- a/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java +++ b/dcae-analytics/dcae-analytics-web/src/main/java/org/onap/dcae/analytics/web/spring/ConfigBindingServiceEnvironmentPostProcessor.java @@ -227,32 +227,28 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment */ public String parseTcaConfig(JsonObject jsonObject) { - Optional configServiceJsonOptional; - JsonElement jsonConfig = jsonObject.get(ConfigBindingServiceConstants.CONFIG); + Optional configServiceJsonOptional = Optional.of(jsonObject.toString()); + + JsonElement jsonPolicyConfig = jsonObject.get(ConfigBindingServiceConstants.POLICIES); String policies = null; - if (jsonConfig.getAsJsonObject().get(ConfigBindingServiceConstants.CONFIG) != null) { - configServiceJsonOptional = Optional.of(jsonConfig.toString()); - policies = jsonConfig.getAsJsonObject().get(ConfigBindingServiceConstants.POLICIES) - .getAsJsonObject().getAsJsonArray(ConfigBindingServiceConstants.ITEMS).get(0) - .getAsJsonObject().get(ConfigBindingServiceConstants.TCAPOLICY).toString(); - } else { - configServiceJsonOptional = Optional.of(jsonObject.toString()); + if (jsonPolicyConfig != null) { + policies = jsonPolicyConfig.getAsJsonObject().getAsJsonArray(ConfigBindingServiceConstants.ITEMS).get(0) + .getAsJsonObject().get(ConfigBindingServiceConstants.TCAPOLICY).toString(); } // convert fetch config binding service json string to Map of property key and // values Map configPropertiesMap = configServiceJsonOptional .map(new JsonStringToMapFunction(configServicePropertiesKey)).orElse(Collections.emptyMap()); + if (policies != null) { configPropertiesMap.put(ConfigBindingServiceConstants.POLICY, policies); } if (configPropertiesMap.isEmpty()) { - logger.warn("No properties found in config binding service"); } else { - // remove config service key prefix on spring reserved property key prefixes final Set springKeyPrefixes = ConfigBindingServiceConstants.getSpringReservedPropertiesKeyPrefixes(); -- cgit 1.2.3-korg