X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Fconfiguration%2FApplicationConfig.java;h=5d7d5d98a982e61372ff248af2a8f081554a935f;hb=7ab83b874b5118ce9bbbbcab2c010c1d5f17ba98;hp=3b4f8104b377b5dd31daa89b20e5ac37dc77b861;hpb=4f602854561a08e754eb0c4ba9327bf49b0e63d7;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfig.java b/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfig.java index 3b4f8104..5d7d5d98 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfig.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/configuration/ApplicationConfig.java @@ -27,7 +27,6 @@ import java.util.Map; import java.util.Properties; import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import lombok.Getter; @@ -42,37 +41,18 @@ public class ApplicationConfig { @NotEmpty private String filepath; - @NotEmpty - private String a1ControllerBaseUrl; - - @NotEmpty - private String a1ControllerUsername; - - @NotEmpty - private String a1ControllerPassword; - private Map ricConfigs = new HashMap<>(); @Getter private Properties dmaapPublisherConfig; @Getter private Properties dmaapConsumerConfig; + private Map controllerConfigs = new HashMap<>(); + public String getLocalConfigurationFilePath() { return this.filepath; } - public synchronized String getA1ControllerBaseUrl() { - return this.a1ControllerBaseUrl; - } - - public synchronized String getA1ControllerUsername() { - return this.a1ControllerUsername; - } - - public synchronized String getA1ControllerPassword() { - return this.a1ControllerPassword; - } - /* * Do not remove, used by framework! */ @@ -80,29 +60,24 @@ public class ApplicationConfig { this.filepath = filepath; } - public synchronized void setA1ControllerBaseUrl(String a1ControllerBaseUrl) { - this.a1ControllerBaseUrl = a1ControllerBaseUrl; - } - - public synchronized void setA1ControllerUsername(String a1ControllerUsername) { - this.a1ControllerUsername = a1ControllerUsername; - } - - public synchronized void setA1ControllerPassword(String a1ControllerPassword) { - this.a1ControllerPassword = a1ControllerPassword; - } - public synchronized Collection getRicConfigs() { return this.ricConfigs.values(); } - public RicConfig getRic(String ricName) throws ServiceException { - for (RicConfig ricConfig : getRicConfigs()) { - if (ricConfig.name().equals(ricName)) { - return ricConfig; - } + public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException { + ControllerConfig controllerConfig = this.controllerConfigs.get(name); + if (controllerConfig == null) { + throw new ServiceException("Could not find controller config: " + name); + } + return controllerConfig; + } + + public synchronized RicConfig getRic(String ricName) throws ServiceException { + RicConfig ricConfig = this.ricConfigs.get(ricName); + if (ricConfig == null) { + throw new ServiceException("Could not find ric configuration: " + ricName); } - throw new ServiceException("Could not find ric: " + ricName); + return ricConfig; } public static class RicConfigUpdate { @@ -121,15 +96,16 @@ public class ApplicationConfig { } } - public synchronized Flux setConfiguration(@NotNull Collection ricConfigs, - Properties dmaapPublisherConfig, Properties dmaapConsumerConfig) { + public synchronized Flux setConfiguration( + ApplicationConfigParser.ConfigParserResult parserResult) { Collection modifications = new ArrayList<>(); - this.dmaapPublisherConfig = dmaapPublisherConfig; - this.dmaapConsumerConfig = dmaapConsumerConfig; + this.dmaapPublisherConfig = parserResult.dmaapPublisherConfig(); + this.dmaapConsumerConfig = parserResult.dmaapConsumerConfig(); + this.controllerConfigs = parserResult.controllerConfigs(); Map newRicConfigs = new HashMap<>(); - for (RicConfig newConfig : ricConfigs) { + for (RicConfig newConfig : parserResult.ricConfigs()) { RicConfig oldConfig = this.ricConfigs.get(newConfig.name()); if (oldConfig == null) { newRicConfigs.put(newConfig.name(), newConfig);