summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapConsumerTaskImpl.java8
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java17
2 files changed, 13 insertions, 12 deletions
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 d5cf91d3..dc868b3e 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
@@ -70,15 +70,15 @@ public class DmaapConsumerTaskImpl extends
prhAppConfig.initFileStreamReader();
}
- protected void setDmaapClientConfig() {
- extendedDmaapConsumerHttpClient = resolveClient();
- }
-
@Override
DmaapConsumerConfiguration resolveConfiguration() {
return prhAppConfig.getDmaapConsumerConfiguration();
}
+ protected void setDmaapClientConfig() {
+ extendedDmaapConsumerHttpClient = resolveClient();
+ }
+
@Override
protected ExtendedDmaapConsumerHttpClientImpl resolveClient() {
return new ExtendedDmaapConsumerHttpClientImpl(resolveConfiguration());
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 d03f8061..6450b18a 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
@@ -19,13 +19,12 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
-import com.google.gson.Gson;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
-import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.configuration.AppConfig;
import org.onap.dcaegen2.services.prh.configuration.Config;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
+import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.service.producer.ExtendedDmaapProducerHttpClientImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,8 +40,8 @@ public class DmaapPublisherTaskImpl extends
DmaapPublisherTask<ExtendedDmaapProducerHttpClientImpl, ConsumerDmaapModel, DmaapPublisherConfiguration> {
private static final Logger logger = LoggerFactory.getLogger(DmaapPublisherTaskImpl.class);
- private static final Gson gson = new Gson();
private final Config prhAppConfig;
+ private ExtendedDmaapProducerHttpClientImpl extendedDmaapProducerHttpClient;
@Autowired
public DmaapPublisherTaskImpl(AppConfig prhAppConfig) {
@@ -52,17 +51,15 @@ public class DmaapPublisherTaskImpl extends
@Override
protected String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
logger.trace("Method called with arg {}", consumerDmaapModel);
- ExtendedDmaapProducerHttpClientImpl dmaapProducerHttpClient = new ExtendedDmaapProducerHttpClientImpl(
- resolveConfiguration());
-
- return dmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel)
- .filter(x -> !x.isEmpty() && x.equals(String.valueOf(HttpStatus.OK.value())))
+ return extendedDmaapProducerHttpClient.getHttpProducerResponse(consumerDmaapModel)
+ .filter(response -> !response.isEmpty() && response.equals(String.valueOf(HttpStatus.OK.value())))
.orElseThrow(() -> new DmaapNotFoundException("Incorrect response from Dmaap"));
}
@Override
public Object execute(Object object) throws PrhTaskException {
if (object instanceof ConsumerDmaapModel) {
+ setDmaapClientConfig();
logger.trace("Method called with arg {}", object);
return publish((ConsumerDmaapModel) object);
}
@@ -78,4 +75,8 @@ public class DmaapPublisherTaskImpl extends
protected ExtendedDmaapProducerHttpClientImpl resolveClient() {
return null;
}
+
+ protected void setDmaapClientConfig() {
+ extendedDmaapProducerHttpClient = resolveClient();
+ }
} \ No newline at end of file