X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fconfiguration%2FApplicationConfigParser.java;h=c69c39d4025d372ca8269f6258f6c8d480a36a41;hb=9c86f9c3b94494d587e7ae7a61effe6515f11159;hp=c21af83981088c2b53164bcf53adf72ef6e7aea7;hpb=a538ca7e0b840e8dc20e85c1864697823ad96ae0;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfigParser.java b/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfigParser.java index c21af839..c69c39d4 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfigParser.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfigParser.java @@ -20,18 +20,18 @@ package org.oransc.policyagent.configuration; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; -import java.util.Vector; import javax.validation.constraints.NotNull; @@ -45,12 +45,8 @@ public class ApplicationConfigParser { private static final String CONFIG = "config"; - private static Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // - @Getter - private Vector ricConfigs; + private List ricConfigs; @Getter private Properties dmaapPublisherConfig = new Properties(); @Getter @@ -72,14 +68,30 @@ public class ApplicationConfigParser { } - private Vector parseRics(JsonObject config) throws ServiceException { - Vector result = new Vector(); + private List parseRics(JsonObject config) throws ServiceException { + List result = new ArrayList<>(); for (JsonElement ricElem : getAsJsonArray(config, "ric")) { - result.add(gson.fromJson(ricElem.getAsJsonObject(), ImmutableRicConfig.class)); + JsonObject ricAsJson = ricElem.getAsJsonObject(); + ImmutableRicConfig ricConfig = ImmutableRicConfig.builder() // + .name(ricAsJson.get("name").getAsString()) // + .baseUrl(ricAsJson.get("baseUrl").getAsString()) // + .managedElementIds(parseManagedElementIds(ricAsJson.get("managedElementIds").getAsJsonArray())) // + .build(); + result.add(ricConfig); } return result; } + private List parseManagedElementIds(JsonArray asJsonObject) { + Iterator iterator = asJsonObject.iterator(); + List managedElementIds = new ArrayList<>(); + while (iterator.hasNext()) { + managedElementIds.add(iterator.next().getAsString()); + + } + return managedElementIds; + } + private static JsonElement get(JsonObject obj, String memberName) throws ServiceException { JsonElement elem = obj.get(memberName); if (elem == null) {