summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2019-04-10 14:38:36 +0200
committerpwielebs <piotr.wielebski@nokia.com>2019-04-10 14:58:41 +0200
commit315fbc568d80baa85ad5989b3faae9aa199c3d9c (patch)
tree12268eb5dbf48da3ea7344389fbf7fea25518749 /prh-app-server/src/main
parent74d946d67bb3da606ec8e7633f69963ad06cd568 (diff)
use CBS SDK in PRH (II)
-remove unused classes -fix junit tests -use cbs -patch project version updated Change-Id: I5fb63408b33b07632eab579d028070eb3a025865 Issue-ID: DCAEGEN2-1360 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java6
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java359
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java)11
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java (renamed from prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java)17
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java30
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java5
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java31
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java10
-rw-r--r--prh-app-server/src/main/resources/consul_config.json2
12 files changed, 41 insertions, 434 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
index 6df9c4ac..0d20c39c 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AaiHttpClientConfig.java
@@ -42,7 +42,7 @@ import java.util.function.BiFunction;
@Configuration
public class AaiHttpClientConfig {
@Autowired
- private ConsulConfiguration consulConfiguration;
+ private CbsConfiguration cbsConfiguration;
@Bean
public AaiHttpClient<AaiModel, HttpResponse> getPatchClientFactory() {
@@ -68,8 +68,8 @@ public class AaiHttpClientConfig {
final BiFunction<AaiClientConfiguration, CloudHttpClient, AaiHttpClient<T, U>> factoryMethod) {
return x -> factoryMethod.apply(
- consulConfiguration.getAaiClientConfiguration(),
- new AaiHttpClientFactory(consulConfiguration.getAaiClientConfiguration()).build()
+ cbsConfiguration.getAaiClientConfiguration(),
+ new AaiHttpClientFactory(cbsConfiguration.getAaiClientConfiguration()).build()
).getAaiResponse(x);
}
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
deleted file mode 100644
index 8ac1d9c0..00000000
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/AppConfig.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * PNF-REGISTRATION-HANDLER
- * ================================================================================
- * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.dcaegen2.services.prh.configuration;
-
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Predicate;
-import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
- */
-@Configuration
-@EnableConfigurationProperties
-public class AppConfig extends PrhAppConfig {
-
- private static Predicate<String> isEmpty = String::isEmpty;
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapHostName:}")
- public String consumerDmaapHostName;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapPortNumber:}")
- public Integer consumerDmaapPortNumber;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapTopicName:}")
- public String consumerDmaapTopicName;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapProtocol:}")
- public String consumerDmaapProtocol;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserName:}")
- public String consumerDmaapUserName;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapUserPassword:}")
- public String consumerDmaapUserPassword;
-
- @Value("${dmaap.dmaapConsumerConfiguration.dmaapContentType:}")
- public String consumerDmaapContentType;
-
- @Value("${dmaap.dmaapConsumerConfiguration.consumerId:}")
- public String consumerId;
-
- @Value("${dmaap.dmaapConsumerConfiguration.consumerGroup:}")
- public String consumerGroup;
-
- @Value("${dmaap.dmaapConsumerConfiguration.timeoutMs:}")
- public Integer consumerTimeoutMs;
-
- @Value("${dmaap.dmaapConsumerConfiguration.message-limit:}")
- public Integer consumerMessageLimit;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapHostName:}")
- public String producerDmaapHostName;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapPortNumber:}")
- public Integer producerDmaapPortNumber;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapTopicName:}")
- public String producerDmaapTopicName;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapProtocol:}")
- public String producerDmaapProtocol;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapUserName:}")
- public String producerDmaapUserName;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapUserPassword:}")
- public String producerDmaapUserPassword;
-
- @Value("${dmaap.dmaapProducerConfiguration.dmaapContentType:}")
- public String producerDmaapContentType;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapHostName:}")
- public String updateProducerDmaapHostName;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber:}")
- public Integer updateProducerDmaapPortNumber;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName:}")
- public String updateProducerDmaapTopicName;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol:}")
- public String updateProducerDmaapProtocol;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapUserName:}")
- public String updateProducerDmaapUserName;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword:}")
- public String updateProducerDmaapUserPassword;
-
- @Value("${dmaap.dmaapUpdateProducerConfiguration.dmaapContentType:}")
- public String updateProducerDmaapContentType;
-
- @Value("${aai.aaiClientConfiguration.pnfUrl:}")
- public String pnfUrl;
-
- @Value("${aai.aaiClientConfiguration.aaiHost:}")
- public String aaiHost;
-
- @Value("${aai.aaiClientConfiguration.aaiHostPortNumber:}")
- public Integer aaiPort;
-
- @Value("${aai.aaiClientConfiguration.aaiProtocol:}")
- public String aaiProtocol;
-
- @Value("${aai.aaiClientConfiguration.aaiUserName:}")
- public String aaiUserName;
-
- @Value("${aai.aaiClientConfiguration.aaiUserPassword:}")
- public String aaiUserPassword;
-
- @Value("${aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors:}")
- public Boolean aaiIgnoreSslCertificateErrors;
-
- @Value("${aai.aaiClientConfiguration.aaiBasePath:}")
- public String aaiBasePath;
-
- @Value("${aai.aaiClientConfiguration.aaiPnfPath:}")
- public String aaiPnfPath;
-
- @Value("${aai.aaiClientConfiguration.aaiServiceInstancePath:}")
- public String aaiServiceInstancePath;
-
- @Value("${security.trustStorePath:}")
- public String trustStorePath;
-
- @Value("${security.trustStorePasswordPath:}")
- public String trustStorePasswordPath;
-
- @Value("${security.keyStorePath:}")
- public String keyStorePath;
-
- @Value("${security.keyStorePasswordPath:}")
- public String keyStorePasswordPath;
-
- @Value("${security.enableAaiCertAuth:}")
- public Boolean enableAaiCertAuth;
-
- @Value("${security.enableDmaapCertAuth:}")
- public Boolean enableDmaapCertAuth;
-
- @Override
- public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
- if (noFileConfiguration(dmaapConsumerConfiguration)) {
- return null;
- }
- return new ImmutableDmaapConsumerConfiguration.Builder()
- .dmaapUserPassword(
- Optional.ofNullable(consumerDmaapUserPassword).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapUserPassword()))
- .dmaapUserName(
- Optional.ofNullable(consumerDmaapUserName).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapUserName()))
- .dmaapHostName(
- Optional.ofNullable(consumerDmaapHostName).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapHostName()))
- .dmaapPortNumber(
- Optional.ofNullable(consumerDmaapPortNumber).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapConsumerConfiguration.dmaapPortNumber()))
- .dmaapProtocol(
- Optional.ofNullable(consumerDmaapProtocol).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapProtocol()))
- .dmaapContentType(
- Optional.ofNullable(consumerDmaapContentType).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapContentType()))
- .dmaapTopicName(
- Optional.ofNullable(consumerDmaapTopicName).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.dmaapTopicName()))
- .messageLimit(
- Optional.ofNullable(consumerMessageLimit).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapConsumerConfiguration.messageLimit()))
- .timeoutMs(Optional.ofNullable(consumerTimeoutMs).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapConsumerConfiguration.timeoutMs()))
- .consumerGroup(Optional.ofNullable(consumerGroup).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.consumerGroup()))
- .consumerId(Optional.ofNullable(consumerId).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.consumerId()))
- .trustStorePath(
- Optional.ofNullable(trustStorePath).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.trustStorePath()))
- .trustStorePasswordPath(
- Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.trustStorePasswordPath()))
- .keyStorePath(
- Optional.ofNullable(keyStorePath).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.keyStorePath()))
- .keyStorePasswordPath(
- Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapConsumerConfiguration.keyStorePasswordPath()))
- .enableDmaapCertAuth(
- Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapConsumerConfiguration.enableDmaapCertAuth()))
- .build();
- }
-
- @Override
- public AaiClientConfiguration getAaiClientConfiguration() {
- if (noFileConfiguration(aaiClientConfiguration)) {
- return null;
- }
- return new ImmutableAaiClientConfiguration.Builder()
- .pnfUrl(Optional.ofNullable(pnfUrl).filter(isEmpty.negate()).orElse(aaiClientConfiguration.pnfUrl()))
- .aaiHost(Optional.ofNullable(aaiHost).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiHost()))
- .aaiPort(
- Optional.ofNullable(aaiPort).filter(p -> !p.toString().isEmpty())
- .orElse(aaiClientConfiguration.aaiPort()))
- .aaiIgnoreSslCertificateErrors(
- Optional.ofNullable(aaiIgnoreSslCertificateErrors).filter(p -> !p.toString().isEmpty())
- .orElse(aaiClientConfiguration.aaiIgnoreSslCertificateErrors()))
- .aaiProtocol(
- Optional.ofNullable(aaiProtocol).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiProtocol()))
- .aaiUserName(
- Optional.ofNullable(aaiUserName).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiUserName()))
- .aaiUserPassword(Optional.ofNullable(aaiUserPassword).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.aaiUserPassword()))
- .aaiBasePath(Optional.ofNullable(aaiBasePath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.aaiBasePath()))
- .aaiPnfPath(
- Optional.ofNullable(aaiPnfPath).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiPnfPath()))
- .aaiServiceInstancePath(
- Optional.ofNullable(aaiServiceInstancePath).filter(isEmpty.negate()).orElse(aaiClientConfiguration.aaiServiceInstancePath()))
- .aaiHeaders(aaiClientConfiguration.aaiHeaders())
- .trustStorePath(
- Optional.ofNullable(trustStorePath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.trustStorePath()))
- .trustStorePasswordPath(
- Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.trustStorePasswordPath()))
- .keyStorePath(
- Optional.ofNullable(keyStorePath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.keyStorePath()))
- .keyStorePasswordPath(
- Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate())
- .orElse(aaiClientConfiguration.keyStorePasswordPath()))
- .enableAaiCertAuth(
- Optional.ofNullable(enableAaiCertAuth).filter(p -> !p.toString().isEmpty())
- .orElse(aaiClientConfiguration.enableAaiCertAuth()))
- .build();
- }
-
- @Override
- public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
- if (noFileConfiguration(dmaapPublisherConfiguration)) {
- return null;
- }
- return new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapContentType(
- Optional.ofNullable(producerDmaapContentType).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapContentType()))
- .dmaapHostName(
- Optional.ofNullable(producerDmaapHostName).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapHostName()))
- .dmaapPortNumber(
- Optional.ofNullable(producerDmaapPortNumber).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
- .dmaapProtocol(
- Optional.ofNullable(producerDmaapProtocol).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapProtocol()))
- .dmaapTopicName(
- Optional.ofNullable(producerDmaapTopicName).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapTopicName()))
- .dmaapUserName(
- Optional.ofNullable(producerDmaapUserName).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapUserName()))
- .dmaapUserPassword(
- Optional.ofNullable(producerDmaapUserPassword).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.dmaapUserPassword()))
- .trustStorePath(
- Optional.ofNullable(trustStorePath).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.trustStorePath()))
- .trustStorePasswordPath(
- Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.trustStorePasswordPath()))
- .keyStorePath(
- Optional.ofNullable(keyStorePath).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.keyStorePath()))
- .keyStorePasswordPath(
- Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapPublisherConfiguration.keyStorePasswordPath()))
- .enableDmaapCertAuth(
- Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapPublisherConfiguration.enableDmaapCertAuth()))
- .build();
- }
-
- @Override
- public DmaapPublisherConfiguration getDmaapUpdatePublisherConfiguration() {
- if (noFileConfiguration(dmaapUpdatePublisherConfiguration)) {
- return null;
- }
- return new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapContentType(
- Optional.ofNullable(updateProducerDmaapContentType).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapContentType()))
- .dmaapHostName(
- Optional.ofNullable(updateProducerDmaapHostName).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapHostName()))
- .dmaapPortNumber(
- Optional.ofNullable(updateProducerDmaapPortNumber).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
- .dmaapProtocol(
- Optional.ofNullable(updateProducerDmaapProtocol).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapProtocol()))
- .dmaapTopicName(
- Optional.ofNullable(updateProducerDmaapTopicName).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapTopicName()))
- .dmaapUserName(
- Optional.ofNullable(updateProducerDmaapUserName).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapUserName()))
- .dmaapUserPassword(
- Optional.ofNullable(updateProducerDmaapUserPassword).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.dmaapUserPassword()))
- .trustStorePath(
- Optional.ofNullable(trustStorePath).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.trustStorePath()))
- .trustStorePasswordPath(
- Optional.ofNullable(trustStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.trustStorePasswordPath()))
- .keyStorePath(
- Optional.ofNullable(keyStorePath).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.keyStorePath()))
- .keyStorePasswordPath(
- Optional.ofNullable(keyStorePasswordPath).filter(isEmpty.negate())
- .orElse(dmaapUpdatePublisherConfiguration.keyStorePasswordPath()))
- .enableDmaapCertAuth(
- Optional.ofNullable(enableDmaapCertAuth).filter(p -> !p.toString().isEmpty())
- .orElse(dmaapUpdatePublisherConfiguration.enableDmaapCertAuth()))
- .build();
- }
-
- private boolean noFileConfiguration(Object object) {
- return Objects.isNull(object);
- }
-}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
index 3d58f01e..3ff81e1f 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfiguration.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsConfiguration.java
@@ -22,11 +22,9 @@ package org.onap.dcaegen2.services.prh.configuration;
import com.google.gson.JsonObject;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
-import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsClientFactory;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.api.CbsRequests;
import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.model.EnvProperties;
-import org.onap.dcaegen2.services.sdk.rest.services.cbs.client.providers.CloudConfigurationClient;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.model.logging.RequestDiagnosticContext;
@@ -49,8 +47,8 @@ import java.util.Optional;
@EnableConfigurationProperties
@EnableScheduling
@Primary
-public class ConsulConfiguration extends PrhAppConfig {
- private static final Logger LOGGER = LoggerFactory.getLogger(ConsulConfiguration.class);
+public class CbsConfiguration extends PrhAppConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CbsConfiguration.class);
private AaiClientConfiguration aaiClientCBSConfiguration;
private DmaapPublisherConfiguration dmaapPublisherCBSConfiguration;
private DmaapConsumerConfiguration dmaapConsumerCBSConfiguration;
@@ -83,11 +81,10 @@ public class ConsulConfiguration extends PrhAppConfig {
private void parseCBSConfig(JsonObject jsonObject) {
LOGGER.info("Received application configuration: {}", jsonObject);
- ConsulConfigurationParser consulConfigurationParser = new ConsulConfigurationParser(jsonObject);
+ CbsContentParser consulConfigurationParser = new CbsContentParser(jsonObject);
dmaapPublisherCBSConfiguration = consulConfigurationParser.getDmaapPublisherConfig();
dmaapUpdatePublisherCBSConfiguration = consulConfigurationParser.getDmaapUpdatePublisherConfig();
- aaiClientCBSConfiguration = ImmutableAaiClientConfiguration.copyOf(consulConfigurationParser.getAaiClientConfig())
- .withAaiHeaders(aaiClientConfiguration.aaiHeaders());
+ aaiClientCBSConfiguration = consulConfigurationParser.getAaiClientConfig();
dmaapConsumerCBSConfiguration = consulConfigurationParser.getDmaapConsumerConfig();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
index b05c0324..e6bcda50 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/ConsulConfigurationParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/CbsContentParser.java
@@ -20,6 +20,8 @@
package org.onap.dcaegen2.services.prh.configuration;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.aai.client.config.ImmutableAaiClientConfiguration;
@@ -28,10 +30,12 @@ import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPub
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapPublisherConfiguration;
+import java.util.Map;
+
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 8/21/18
*/
-class ConsulConfigurationParser {
+class CbsContentParser {
private static final String SECURITY_TRUST_STORE_PATH = "security.trustStorePath";
private static final String SECURITY_TRUST_STORE_PASS_PATH = "security.trustStorePasswordPath";
private static final String SECURITY_KEY_STORE_PATH = "security.keyStorePath";
@@ -39,12 +43,13 @@ class ConsulConfigurationParser {
private static final String CONFIG = "config";
private final JsonObject jsonObject;
- ConsulConfigurationParser(JsonObject jsonObject) {
+ CbsContentParser(JsonObject jsonObject) {
this.jsonObject = jsonObject.getAsJsonObject(CONFIG);
}
DmaapPublisherConfiguration getDmaapPublisherConfig() {
return new ImmutableDmaapPublisherConfiguration.Builder()
+ .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.PNF_READY")
.dmaapTopicName(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapTopicName").getAsString())
.dmaapUserPassword(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapUserPassword").getAsString())
.dmaapPortNumber(jsonObject.get("dmaap.dmaapProducerConfiguration.dmaapPortNumber").getAsInt())
@@ -63,7 +68,8 @@ class ConsulConfigurationParser {
DmaapPublisherConfiguration getDmaapUpdatePublisherConfig() {
return new ImmutableDmaapPublisherConfiguration.Builder()
- .dmaapTopicName(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName").getAsString())
+ .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.PNF_READY")
+ .dmaapTopicName(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapTopicName").getAsString())
.dmaapUserPassword(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapUserPassword").getAsString())
.dmaapPortNumber(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapPortNumber").getAsInt())
.dmaapProtocol(jsonObject.get("dmaap.dmaapUpdateProducerConfiguration.dmaapProtocol").getAsString())
@@ -88,7 +94,7 @@ class ConsulConfigurationParser {
.aaiPnfPath(jsonObject.get("aai.aaiClientConfiguration.aaiPnfPath").getAsString())
.aaiServiceInstancePath(jsonObject.get("aai.aaiClientConfiguration.aaiServiceInstancePath").getAsString())
.aaiIgnoreSslCertificateErrors(
- jsonObject.get("aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors").getAsBoolean())
+ jsonObject.get("aai.aaiClientConfiguration.aaiIgnoreSslCertificateErrors").getAsBoolean())
.aaiUserPassword(jsonObject.get("aai.aaiClientConfiguration.aaiUserPassword").getAsString())
.aaiProtocol(jsonObject.get("aai.aaiClientConfiguration.aaiProtocol").getAsString())
.aaiBasePath(jsonObject.get("aai.aaiClientConfiguration.aaiBasePath").getAsString())
@@ -97,11 +103,14 @@ class ConsulConfigurationParser {
.keyStorePath(jsonObject.get(SECURITY_KEY_STORE_PATH).getAsString())
.keyStorePasswordPath(jsonObject.get(SECURITY_KEY_STORE_PASS_PATH).getAsString())
.enableAaiCertAuth(jsonObject.get("security.enableAaiCertAuth").getAsBoolean())
+ .aaiHeaders(new Gson().fromJson(jsonObject.get("aai.aaiClientConfiguration.aaiHeaders"),
+ new TypeToken<Map<String, String>>(){}.getType()))
.build();
}
DmaapConsumerConfiguration getDmaapConsumerConfig() {
return new ImmutableDmaapConsumerConfiguration.Builder()
+ .endpointUrl("http://dmaap-mr:2222/events/unauthenticated.VES_PNFREG_OUTPUT")
.timeoutMs(jsonObject.get("dmaap.dmaapConsumerConfiguration.timeoutMs").getAsInt())
.dmaapHostName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapHostName").getAsString())
.dmaapUserName(jsonObject.get("dmaap.dmaapConsumerConfiguration.dmaapUserName").getAsString())
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
index 88f20205..6363356f 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
@@ -40,5 +40,4 @@ public interface Config {
DmaapPublisherConfiguration getDmaapUpdatePublisherConfiguration();
- void initFileStreamReader();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
index 108a3551..35895abb 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java
@@ -56,8 +56,6 @@ public abstract class PrhAppConfig implements Config {
private static final String AAI = "aai";
private static final String DMAAP = "dmaap";
private static final String AAI_CONFIG = "aaiClientConfiguration";
- private static final String DMAAP_PRODUCER = "dmaapProducerConfiguration";
- private static final String DMAAP_UPDATE_PRODUCER = "dmaapUpdateProducerConfiguration";
private static final String DMAAP_CONSUMER = "dmaapConsumerConfiguration";
private static final String SECURITY = "security";
@@ -69,9 +67,6 @@ public abstract class PrhAppConfig implements Config {
DmaapPublisherConfiguration dmaapUpdatePublisherConfiguration;
- @Value("classpath:prh_endpoints.json")
- private Resource prhEndpoints;
-
@Value("classpath:git_info.json")
private Resource gitInfo;
@@ -105,26 +100,6 @@ public abstract class PrhAppConfig implements Config {
return dmaapUpdatePublisherConfiguration;
}
- @Override
- public void initFileStreamReader() {
- GsonBuilder gsonBuilder = new GsonBuilder();
- ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory);
- JsonParser parser = new JsonParser();
-
- try (InputStream inputStream = prhEndpoints.getInputStream()) {
- JsonElement rootElement = getJsonElement(parser, inputStream);
- if (rootElement.isJsonObject()) {
- deserializeAaiConfiguration(gsonBuilder, rootElement);
- deserializeDmaapConsumerConfiguration(gsonBuilder, rootElement);
- dmaapPublisherConfiguration =
- deserializeDmaapPublisherConfiguration(DMAAP_PRODUCER, gsonBuilder, rootElement);
- dmaapUpdatePublisherConfiguration =
- deserializeDmaapPublisherConfiguration(DMAAP_UPDATE_PRODUCER, gsonBuilder, rootElement);
- }
- } catch (IOException e) {
- LOGGER.warn("Failed to load/parse file", e);
- }
- }
private DmaapPublisherConfiguration deserializeDmaapPublisherConfiguration(
final String dmaapProducerType,
@@ -171,9 +146,4 @@ public abstract class PrhAppConfig implements Config {
return null;
}
}
-
- @VisibleForTesting
- void setPrhEndpoints(Resource prhEndpoints) {
- this.prhEndpoints = prhEndpoints;
- }
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
index eb5b51a1..02691446 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
@@ -75,7 +75,6 @@ public class BbsActionsTaskImpl implements BbsActionsTask {
}
public Mono<ConsumerDmaapModel> execute(ConsumerDmaapModel consumerDmaapModel) {
- config.initFileStreamReader();
JsonObject additionalFields = consumerDmaapModel.getAdditionalFields();
if (additionalFields == null || !additionalFields.has(ATTACHMENT_POINT)) {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
index e3ea8962..3a630a40 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTask.java
@@ -33,8 +33,6 @@ import reactor.core.publisher.Flux;
*/
interface DmaapConsumerTask {
- void initConfigs();
-
Flux<ConsumerDmaapModel> execute(String object) throws SSLException;
DMaaPConsumerReactiveHttpClient resolveClient() throws SSLException;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
index 0d71477c..d3086cbe 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java
@@ -63,11 +63,6 @@ public class DmaapConsumerTaskImpl implements DmaapConsumerTask {
}
@Override
- public void initConfigs() {
- config.initFileStreamReader();
- }
-
- @Override
public Flux<ConsumerDmaapModel> execute(String object) throws SSLException {
DMaaPConsumerReactiveHttpClient dmaaPConsumerReactiveHttpClient = resolveClient();
LOGGER.debug("Method called with arg {}", object);
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
index aae5bc77..72ec0cac 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasks.java
@@ -48,7 +48,7 @@ import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.RESPONSE
@Component
public class ScheduledTasks {
- private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledTasks.class);
private static final Marker INVOKE = MarkerFactory.getMarker("INVOKE");
private final DmaapConsumerTask dmaapConsumerTask;
private final DmaapPublisherTask dmaapReadyProducerTask;
@@ -100,36 +100,36 @@ public class ScheduledTasks {
public void scheduleMainPrhEventTask() {
MdcVariables.setMdcContextMap(mdcContextMap);
try {
- logger.trace("Execution of tasks was registered");
+ LOGGER.trace("Execution of tasks was registered");
CountDownLatch mainCountDownLatch = new CountDownLatch(1);
consumeFromDMaaPMessage()
.doOnError(DmaapEmptyResponseException.class, error ->
- logger.warn("Nothing to consume from DMaaP")
+ LOGGER.warn("Nothing to consume from DMaaP")
)
.flatMap(this::queryAaiForConfiguration)
.flatMap(this::publishToAaiConfiguration)
.doOnError(exception ->
- logger.warn("AAIProducerTask exception has been registered: ", exception))
+ LOGGER.warn("AAIProducerTask exception has been registered: ", exception))
.onErrorResume(resumePrhPredicate(), exception -> Mono.empty())
.flatMap(this::processAdditionalFields)
.doOnError(exception ->
- logger.warn("BBSActionsTask exception has been registered: ", exception))
+ LOGGER.warn("BBSActionsTask exception has been registered: ", exception))
.flatMap(this::publishToDmaapConfigurationWithApache)
.doOnError(exception ->
- logger.warn("DMaaPProducerTask exception has been registered: ", exception))
+ LOGGER.warn("DMaaPProducerTask exception has been registered: ", exception))
.onErrorResume(resumePrhPredicate(), exception -> Mono.empty())
.doOnTerminate(mainCountDownLatch::countDown)
.subscribe(this::onSuccess, this::onError, this::onComplete);
mainCountDownLatch.await();
} catch (InterruptedException e) {
- logger.warn("Interruption problem on countDownLatch ", e);
+ LOGGER.warn("Interruption problem on countDownLatch ", e);
Thread.currentThread().interrupt();
}
}
private void onComplete() {
- logger.info("PRH tasks have been completed");
+ LOGGER.info("PRH tasks have been completed");
}
/**
@@ -139,7 +139,7 @@ public class ScheduledTasks {
private void onSuccess(HttpClientResponse response) {
String statusCode = Integer.toString(response.status().code());
MDC.put(RESPONSE_CODE, statusCode);
- logger.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}",
+ LOGGER.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}",
statusCode);
MDC.remove(RESPONSE_CODE);
}
@@ -147,7 +147,7 @@ public class ScheduledTasks {
private void onSuccess(HttpResponse response) {
String statusCode = Integer.toString(response.getStatusLine().getStatusCode());
MDC.put(RESPONSE_CODE, statusCode);
- logger.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}",
+ LOGGER.info("Prh consumed tasks successfully. HTTP Response code from DMaaPProducer {}",
statusCode);
MDC.remove(RESPONSE_CODE);
}
@@ -155,7 +155,7 @@ public class ScheduledTasks {
private void onError(Throwable throwable) {
if (!(throwable instanceof DmaapEmptyResponseException)) {
- logger.warn("Chain of tasks have been aborted due to errors in PRH workflow", throwable);
+ LOGGER.warn("Chain of tasks have been aborted due to errors in PRH workflow", throwable);
}
}
@@ -163,8 +163,7 @@ public class ScheduledTasks {
return Flux.defer(() -> {
MdcVariables.setMdcContextMap(mdcContextMap);
MDC.put(INSTANCE_UUID, UUID.randomUUID().toString());
- logger.info(INVOKE, "Init configs");
- dmaapConsumerTask.initConfigs();
+ LOGGER.info(INVOKE, "Init configs");
return consumeFromDMaaP();
});
}
@@ -197,7 +196,7 @@ public class ScheduledTasks {
private Mono<State> processAdditionalFields(final State state) {
if (state.ActivationStatus) {
- logger.debug("Re-registration - Logical links won't be updated.");
+ LOGGER.debug("Re-registration - Logical links won't be updated.");
return Mono.just(state);
}
@@ -213,7 +212,7 @@ public class ScheduledTasks {
publishToDmaapConfiguration(final State state) {
try {
if (state.ActivationStatus) {
- logger.debug("Re-registration - Using PNF_UPDATE DMaaP topic.");
+ LOGGER.debug("Re-registration - Using PNF_UPDATE DMaaP topic.");
return dmaapUpdateProducerTask.execute(state.DmaapModel);
}
@@ -227,7 +226,7 @@ public class ScheduledTasks {
publishToDmaapConfigurationWithApache(final State state) {
try {
if (state.ActivationStatus) {
- logger.debug("Re-registration - Using PNF_UPDATE DMaaP topic.");
+ LOGGER.debug("Re-registration - Using PNF_UPDATE DMaaP topic.");
return dmaapUpdateProducerTask.executeWithApache(state.DmaapModel);
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
index e20e25d8..e9c18109 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/ScheduledTasksRunner.java
@@ -28,7 +28,7 @@ import java.util.List;
import java.util.concurrent.ScheduledFuture;
import javax.annotation.PostConstruct;
-import org.onap.dcaegen2.services.prh.configuration.ConsulConfiguration;
+import org.onap.dcaegen2.services.prh.configuration.CbsConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Marker;
@@ -57,15 +57,15 @@ public class ScheduledTasksRunner {
private final TaskScheduler taskScheduler;
private final ScheduledTasks scheduledTask;
- private final ConsulConfiguration consulConfiguration;
+ private final CbsConfiguration cbsConfiguration;
@Autowired
public ScheduledTasksRunner(TaskScheduler taskScheduler,
ScheduledTasks scheduledTask,
- ConsulConfiguration consulConfiguration) {
+ CbsConfiguration cbsConfiguration) {
this.taskScheduler = taskScheduler;
this.scheduledTask = scheduledTask;
- this.consulConfiguration = consulConfiguration;
+ this.cbsConfiguration = cbsConfiguration;
}
/**
@@ -94,7 +94,7 @@ public class ScheduledTasksRunner {
LOGGER.info(ENTRY, "Start scheduling PRH workflow");
if (scheduledPrhTaskFutureList.isEmpty()) {
scheduledPrhTaskFutureList.add(taskScheduler
- .scheduleAtFixedRate(consulConfiguration::runTask, Instant.now(),
+ .scheduleAtFixedRate(cbsConfiguration::runTask, Instant.now(),
Duration.ofMinutes(SCHEDULING_REQUEST_FOR_CONFIGURATION_DELAY)));
scheduledPrhTaskFutureList.add(taskScheduler
.scheduleWithFixedDelay(scheduledTask::scheduleMainPrhEventTask,
diff --git a/prh-app-server/src/main/resources/consul_config.json b/prh-app-server/src/main/resources/consul_config.json
index 7cefd641..2ec0d57c 100644
--- a/prh-app-server/src/main/resources/consul_config.json
+++ b/prh-app-server/src/main/resources/consul_config.json
@@ -1,5 +1,5 @@
{
- "consulHost": "10.42.111.9",
+ "consulHost": "10.42.111.11",
"cbsName": "cbs",
"appName": "dcae-prh"
} \ No newline at end of file