summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-04-25 19:26:31 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-04-25 19:31:18 +0200
commitc215daf12e5047f7292dfac124a7fac0411b169d (patch)
tree31b53e34f6db8c89404e8c94fe1ae38bd00cd913 /prh-app-server/src/main
parentd7640cf52a678a63698e1a2293e116b350eaa7f7 (diff)
Parsing arguments from cloudify.
*Added functionality for replacing default value from command line tosca template. Change-Id: I5923d9b5192f2f9df026320e1c6c56d4eaf9756a Issue-ID: DCAEGEN2-458 Signed-off-by: wasala <przemyslaw.wasala@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/AppConfig.java146
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java38
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/PrhAppConfig.java39
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java3
6 files changed, 205 insertions, 27 deletions
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
index 85ca5226..76633d26 100644
--- 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
@@ -19,21 +19,157 @@
*/
package org.onap.dcaegen2.services.prh.configuration;
+import java.util.Optional;
import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
+import org.onap.dcaegen2.services.config.ImmutableAAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.ImmutableDmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.config.ImmutableDmaapPublisherConfiguration;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
*/
-public interface AppConfig {
- DmaapConsumerConfiguration getDmaapConsumerConfiguration();
+@Component
+@Configuration
+public class AppConfig extends PrhAppConfig {
- AAIHttpClientConfiguration getAAIHttpClientConfiguration();
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapHostName:}")
+ public String consumerDmmapHostName;
- DmaapPublisherConfiguration getDmaapPublisherConfiguration();
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapPortNumber:}")
+ public Integer consumerDmmapPortNumber;
- void initFileStreamReader();
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapTopicName:}")
+ public String consumerDmmapTopicName;
+
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapProtocol:}")
+ public String consumerDmmapProtocol;
+
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapUserName:}")
+ public String consumerDmmapUserName;
+
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapUserPassword:}")
+ public String consumerDmmapUserPassword;
+
+ @Value("${dmaap.dmaapConsumerConfiguration.dmmapContentType:}")
+ public String consumerDmmapContentType;
+
+ @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.dmmapHostName:}")
+ public String producerDmmapHostName;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapPortNumber:}")
+ public Integer producerDmmapPortNumber;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapTopicName:}")
+ public String producerDmmapTopicName;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapProtocol:}")
+ public String producerDmmapProtocol;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapUserName:}")
+ public String producerDmmapUserName;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapUserPassword:}")
+ public String producerDmmapUserPassword;
+
+ @Value("${dmaap.dmaapProducerConfiguration.dmmapContentType:}")
+ public String producerDmmapContentType;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiHost:}")
+ public String aaiHost;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiHostPortNumber:}")
+ public Integer aaiHostPortNumber;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiProtocol:}")
+ public String aaiProtocol;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiUserName:}")
+ public String aaiUserName;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiUserPassword:}")
+ public String aaiUserPassword;
+
+ @Value("${aai.aaiHttpClientConfiguration.aaiIgnoreSSLCertificateErrors:}")
+ public Boolean aaiIgnoreSSLCertificateErrors;
+
+ @Override
+ public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
+ return new ImmutableDmaapConsumerConfiguration.Builder()
+ .dmaapUserPassword(
+ Optional.ofNullable(consumerDmmapUserPassword).orElse(dmaapConsumerConfiguration.dmaapUserPassword()))
+ .dmaapUserName(
+ Optional.ofNullable(consumerDmmapUserName).orElse(dmaapConsumerConfiguration.dmaapUserName()))
+ .dmaapHostName(
+ Optional.ofNullable(consumerDmmapHostName).orElse(dmaapConsumerConfiguration.dmaapHostName()))
+ .dmaapPortNumber(
+ Optional.ofNullable(consumerDmmapPortNumber).orElse(dmaapConsumerConfiguration.dmaapPortNumber()))
+ .dmaapProtocol(
+ Optional.ofNullable(consumerDmmapProtocol).orElse(dmaapConsumerConfiguration.dmaapProtocol()))
+ .dmaapContentType(
+ Optional.ofNullable(consumerDmmapContentType).orElse(dmaapConsumerConfiguration.dmaapContentType()))
+ .dmaapTopicName(
+ Optional.ofNullable(consumerDmmapTopicName).orElse(dmaapConsumerConfiguration.dmaapTopicName()))
+ .messageLimit(
+ Optional.ofNullable(consumerMessageLimit).orElse(dmaapConsumerConfiguration.messageLimit()))
+ .timeoutMS(Optional.ofNullable(consumerTimeoutMS).orElse(dmaapConsumerConfiguration.timeoutMS()))
+ .consumerGroup(Optional.ofNullable(consumerGroup).orElse(dmaapConsumerConfiguration.consumerGroup()))
+ .consumerId(Optional.ofNullable(consumerId).orElse(dmaapConsumerConfiguration.consumerId()))
+ .build();
+ }
+
+ @Override
+ public AAIHttpClientConfiguration getAAIHttpClientConfiguration() {
+ return new ImmutableAAIHttpClientConfiguration.Builder()
+ .aaiHost(Optional.ofNullable(aaiHost).orElse(aaiHttpClientConfiguration.aaiHost()))
+ .aaiHostPortNumber(
+ Optional.ofNullable(aaiHostPortNumber).orElse(aaiHttpClientConfiguration.aaiHostPortNumber()))
+ .aaiIgnoreSSLCertificateErrors(
+ Optional.ofNullable(aaiIgnoreSSLCertificateErrors)
+ .orElse(aaiHttpClientConfiguration.aaiIgnoreSSLCertificateErrors()))
+ .aaiProtocol(Optional.ofNullable(aaiProtocol).orElse(aaiHttpClientConfiguration.aaiProtocol()))
+ .aaiUserName(
+ Optional.ofNullable(aaiUserName).orElse(aaiHttpClientConfiguration.aaiUserName()))
+ .aaiUserPassword(Optional.ofNullable(
+ aaiUserPassword).orElse(aaiHttpClientConfiguration.aaiUserPassword()))
+ .build();
+ }
+
+ @Override
+ public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
+ return new ImmutableDmaapPublisherConfiguration.Builder()
+ .dmaapContentType(
+ Optional.ofNullable(producerDmmapContentType).orElse(dmaapPublisherConfiguration.dmaapContentType()))
+ .dmaapHostName(
+ Optional.ofNullable(producerDmmapHostName).orElse(dmaapPublisherConfiguration.dmaapHostName()))
+ .dmaapPortNumber(
+ Optional.ofNullable(producerDmmapPortNumber).orElse(dmaapPublisherConfiguration.dmaapPortNumber()))
+ .dmaapProtocol(
+ Optional.ofNullable(producerDmmapProtocol).orElse(dmaapPublisherConfiguration.dmaapProtocol()))
+ .dmaapTopicName(
+ Optional.ofNullable(producerDmmapTopicName).orElse(dmaapPublisherConfiguration.dmaapTopicName()))
+ .dmaapUserName(
+ Optional.ofNullable(producerDmmapUserName).orElse(dmaapPublisherConfiguration.dmaapUserName()))
+ .dmaapUserPassword(
+ Optional.ofNullable(producerDmmapUserPassword).orElse(dmaapPublisherConfiguration.dmaapUserPassword()))
+ .build();
+ }
}
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
new file mode 100644
index 00000000..8dd2bf3b
--- /dev/null
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/configuration/Config.java
@@ -0,0 +1,38 @@
+/*
+ * ============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 org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
+import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
+import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
+
+/**
+ * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/25/18
+ */
+public interface Config {
+
+ DmaapConsumerConfiguration getDmaapConsumerConfiguration();
+
+ AAIHttpClientConfiguration getAAIHttpClientConfiguration();
+
+ DmaapPublisherConfiguration getDmaapPublisherConfiguration();
+
+ 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 2fa35608..8720cf47 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
@@ -51,7 +51,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties
@ConfigurationProperties("app")
-public class PrhAppConfig implements AppConfig {
+public abstract class PrhAppConfig implements Config {
private static final String CONFIG = "configs";
private static final String AAI = "aai";
@@ -63,15 +63,31 @@ public class PrhAppConfig implements AppConfig {
private static final Logger logger = LoggerFactory.getLogger(PrhAppConfig.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
- private AAIHttpClientConfiguration aaiHttpClientConfiguration;
+ AAIHttpClientConfiguration aaiHttpClientConfiguration;
- private DmaapConsumerConfiguration dmaapConsumerConfiguration;
+ DmaapConsumerConfiguration dmaapConsumerConfiguration;
- private DmaapPublisherConfiguration dmaapPublisherConfiguration;
+ DmaapPublisherConfiguration dmaapPublisherConfiguration;
@NotEmpty
private String filepath;
+
+ @Override
+ public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
+ return dmaapConsumerConfiguration;
+ }
+
+ @Override
+ public AAIHttpClientConfiguration getAAIHttpClientConfiguration() {
+ return aaiHttpClientConfiguration;
+ }
+
+ @Override
+ public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
+ return dmaapPublisherConfiguration;
+ }
+
@Override
public void initFileStreamReader() {
@@ -95,7 +111,6 @@ public class PrhAppConfig implements AppConfig {
jsonObject.getAsJsonObject(CONFIG).getAsJsonObject(DMAAP).getAsJsonObject(DMAAP_PRODUCER),
DmaapPublisherConfiguration.class);
}
-
} catch (FileNotFoundException e) {
logger
.error(
@@ -134,18 +149,4 @@ public class PrhAppConfig implements AppConfig {
this.filepath = filepath;
}
- @Override
- public DmaapConsumerConfiguration getDmaapConsumerConfiguration() {
- return dmaapConsumerConfiguration;
- }
-
- @Override
- public AAIHttpClientConfiguration getAAIHttpClientConfiguration() {
- return aaiHttpClientConfiguration;
- }
-
- @Override
- public DmaapPublisherConfiguration getDmaapPublisherConfiguration() {
- return dmaapPublisherConfiguration;
- }
} \ No newline at end of file
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java
index 9a256986..aa452047 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIPublisherTaskImpl.java
@@ -23,6 +23,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.onap.dcaegen2.services.config.AAIHttpClientConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +40,7 @@ public class AAIPublisherTaskImpl extends AAIPublisherTask<AAIHttpClientConfigur
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
- private final AppConfig prhAppConfig;
+ private final Config prhAppConfig;
@Autowired
public AAIPublisherTaskImpl(AppConfig prhAppConfig) {
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 f7cc7e1d..0db49f7c 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
@@ -23,6 +23,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.onap.dcaegen2.services.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.prh.configuration.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,7 +40,7 @@ public class DmaapConsumerTaskImpl extends DmaapConsumerTask<DmaapConsumerConfig
private static final Logger logger = LoggerFactory.getLogger(DmaapConsumerTaskImpl.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
- private final AppConfig prhAppConfig;
+ private final Config prhAppConfig;
@Autowired
public DmaapConsumerTaskImpl(AppConfig prhAppConfig) {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
index 74d08539..072f9c7d 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java
@@ -23,6 +23,7 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import org.onap.dcaegen2.services.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
+import org.onap.dcaegen2.services.prh.configuration.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -38,7 +39,7 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask<DmaapPublisherCon
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
- private final AppConfig prhAppConfig;
+ private final Config prhAppConfig;
@Autowired
public DmaapPublisherTaskImpl(AppConfig prhAppConfig) {