From 0688c66229fe1bfb1d7d8920705b019d5cfeb17f Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 10 Jul 2020 18:05:46 +0800 Subject: TCAGen2 java upgrade Issue-ID: DCAEGEN2-2285 Signed-off-by: Kai Lu Change-Id: I1a7b3db68141ed8648fe47865f39dea22f0d999c --- .../spring/ConfigBindingServiceEnvironmentPostProcessor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'dcae-analytics/dcae-analytics-web/src') 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 d286d10..8798b4e 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 @@ -229,8 +229,13 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment Optional configServiceJsonOptional; JsonElement jsonConfig = jsonObject.get(ConfigBindingServiceConstants.CONFIG); + 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.CONFIG) + .getAsJsonObject().get(ConfigBindingServiceConstants.TCAPOLICY).toString(); } else { configServiceJsonOptional = Optional.of(jsonObject.toString()); } @@ -239,7 +244,9 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment // values Map configPropertiesMap = configServiceJsonOptional .map(new JsonStringToMapFunction(configServicePropertiesKey)).orElse(Collections.emptyMap()); - + if (policies != null) { + configPropertiesMap.put(ConfigBindingServiceConstants.CONFIG_POLICIES, policies); + } if (configPropertiesMap.isEmpty()) { logger.warn("No properties found in config binding service"); @@ -264,7 +271,7 @@ public class ConfigBindingServiceEnvironmentPostProcessor implements Environment .info("Adding property from config service in spring context: {} -> {}", key, value)); MutablePropertySources sources = env.getPropertySources(); addJsonPropertySource(sources, new MapPropertySource(configServicePropertiesKey, filterKeyMap)); - + } return configServiceJsonOptional.get(); } -- cgit 1.2.3-korg