import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import javax.validation.constraints.NotEmpty;
import lombok.Getter;
import org.oransc.policyagent.exceptions.ServiceException;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import reactor.core.publisher.Flux;
@EnableConfigurationProperties
-@ConfigurationProperties("app")
+@ConfigurationProperties()
public class ApplicationConfig {
@NotEmpty
- private String filepath;
+ @Getter
+ @Value("${app.filepath}")
+ private String localConfigurationFilePath;
+
+ @Value("${app.webclient.trust-store-used}")
+ private boolean sslTrustStoreUsed = false;
+
+ @Value("${app.webclient.trust-store-password}")
+ private String sslTrustStorePassword = "";
+
+ @Value("${app.webclient.trust-store}")
+ private String sslTrustStore = "";
private Map<String, RicConfig> ricConfigs = new HashMap<>();
+
@Getter
- private Properties dmaapPublisherConfig;
+ private String dmaapConsumerTopicUrl;
+
@Getter
- private Properties dmaapConsumerConfig;
+ private String dmaapProducerTopicUrl;
private Map<String, ControllerConfig> controllerConfigs = new HashMap<>();
- public String getLocalConfigurationFilePath() {
- return this.filepath;
- }
-
- /*
- * Do not remove, used by framework!
- */
- public synchronized void setFilepath(String filepath) {
- this.filepath = filepath;
- }
-
public synchronized Collection<RicConfig> getRicConfigs() {
return this.ricConfigs.values();
}
+ public WebClientConfig getWebClientConfig() {
+ return ImmutableWebClientConfig.builder() //
+ .isTrustStoreUsed(this.sslTrustStoreUsed) //
+ .trustStore(this.sslTrustStore) //
+ .trustStorePassword(this.sslTrustStorePassword) //
+ .build();
+ }
+
public synchronized ControllerConfig getControllerConfig(String name) throws ServiceException {
ControllerConfig controllerConfig = this.controllerConfigs.get(name);
if (controllerConfig == null) {
ApplicationConfigParser.ConfigParserResult parserResult) {
Collection<RicConfigUpdate> modifications = new ArrayList<>();
- this.dmaapPublisherConfig = parserResult.dmaapPublisherConfig();
- this.dmaapConsumerConfig = parserResult.dmaapConsumerConfig();
this.controllerConfigs = parserResult.controllerConfigs();
+ this.dmaapConsumerTopicUrl = parserResult.dmaapConsumerTopicUrl();
+ this.dmaapProducerTopicUrl = parserResult.dmaapProducerTopicUrl();
+
Map<String, RicConfig> newRicConfigs = new HashMap<>();
for (RicConfig newConfig : parserResult.ricConfigs()) {
RicConfig oldConfig = this.ricConfigs.get(newConfig.name());
+ this.ricConfigs.remove(newConfig.name());
if (oldConfig == null) {
newRicConfigs.put(newConfig.name(), newConfig);
modifications.add(new RicConfigUpdate(newConfig, RicConfigUpdate.Type.ADDED));
- this.ricConfigs.remove(newConfig.name());
} else if (!newConfig.equals(oldConfig)) {
modifications.add(new RicConfigUpdate(newConfig, RicConfigUpdate.Type.CHANGED));
newRicConfigs.put(newConfig.name(), newConfig);
- this.ricConfigs.remove(newConfig.name());
} else {
newRicConfigs.put(oldConfig.name(), oldConfig);
}