X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fconfig%2Fsdc%2FSdcControllersConfiguration.java;h=b21c75f2ab17c65c7442b051bcb01ca64f09e50a;hb=cdfe48cf32c83f3e0a3921499cd6c494a4b40107;hp=0f75d46e75da31801da3580bb4acae1321fbb305;hpb=3e118724141917299ad3e2f535544500b5c459b0;p=clamp.git diff --git a/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java b/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java index 0f75d46e..b21c75f2 100644 --- a/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java @@ -25,16 +25,18 @@ package org.onap.clamp.clds.config.sdc; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.JsonNode; +import com.google.gson.JsonObject; import java.io.IOException; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import javax.annotation.PostConstruct; import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException; -import org.onap.clamp.clds.util.JacksonUtils; +import org.onap.clamp.clds.util.JsonUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; @@ -59,13 +61,13 @@ public class SdcControllersConfiguration { /** * The root of the JSON. */ - private JsonNode jsonRootNode; + private JsonObject jsonRootNode; @PostConstruct public void loadConfiguration() throws IOException { Resource resource = appContext.getResource(sdcControllerFile); // Try to load json tree - jsonRootNode = JacksonUtils.getObjectMapperInstance().readValue(resource.getInputStream(), JsonNode.class); + jsonRootNode = JsonUtils.GSON.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), JsonObject.class); } public SdcSingleControllerConfiguration getSdcSingleControllerConfiguration(String controllerName) { @@ -80,8 +82,9 @@ public class SdcControllersConfiguration { public Map getAllDefinedControllers() { Map result = new HashMap<>(); if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) { - jsonRootNode.get(CONTROLLER_SUBTREE_KEY).fields().forEachRemaining(entry -> result.put(entry.getKey(), - new SdcSingleControllerConfiguration(entry.getValue(), entry.getKey()))); + jsonRootNode.get(CONTROLLER_SUBTREE_KEY).getAsJsonObject().entrySet().forEach( + entry -> result.put(entry.getKey(), + new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey()))); } else { throw new SdcParametersException( CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile);