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/AAIConsumerTask.java6
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java39
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java4
3 files changed, 35 insertions, 14 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
index 5a3afd86..b4b66036 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java
@@ -22,9 +22,9 @@ package org.onap.dcaegen2.services.prh.tasks;
import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
-public abstract class AAIConsumerTask<T> extends Task {
+public abstract class AAIConsumerTask<T, U, V> extends Task {
- protected abstract void consume() throws AAINotFoundException;
+ protected abstract V consume(U message) throws AAINotFoundException;
- protected abstract T resolveConfiguration();
+ protected abstract T resolveClient();
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java
index cbe3d9aa..31af9c80 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java
@@ -20,24 +20,25 @@
package org.onap.dcaegen2.services.prh.tasks;
+import java.io.IOException;
import org.onap.dcaegen2.services.prh.config.AAIClientConfiguration;
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.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
+import org.onap.dcaegen2.services.prh.service.AAIConsumerClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Optional;
-
@Component
-public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIClientConfiguration> {
+public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIConsumerClient, ConsumerDmaapModel, Object> {
private static final Logger logger = LoggerFactory.getLogger(AAIConsumerTaskImpl.class);
private final Config prhAppConfig;
- private Optional<String> response;
+ private AAIConsumerClient aaiConsumerClient;
@Autowired
public AAIConsumerTaskImpl(AppConfig prhAppConfig) {
@@ -45,13 +46,24 @@ public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIClientConfiguration>
}
@Override
- protected void consume() throws AAINotFoundException {
+ protected Object consume(ConsumerDmaapModel consumerDmaapModel) throws AAINotFoundException {
+ logger.trace("Method called with arg {}", consumerDmaapModel);
+ try {
+ return aaiConsumerClient.getHttpResponse(consumerDmaapModel);
+ } catch (IOException e) {
+ logger.warn("Get request not successful", e);
+ throw new AAINotFoundException("Get request not successful");
+ }
}
@Override
public Object execute(Object object) throws AAINotFoundException {
- consume();
- return null;
+ setAAIClientConfig();
+ logger.trace("Method called with arg {}", object);
+ if (object instanceof ConsumerDmaapModel) {
+ return consume((ConsumerDmaapModel) object);
+ }
+ throw new AAINotFoundException("Incorrect object type");
}
@Override
@@ -59,8 +71,17 @@ public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIClientConfiguration>
logger.trace("initConfigs for AAIConsumerTaskImpl not needed/supported");
}
- @Override
- protected AAIClientConfiguration resolveConfiguration() {
+
+ protected void setAAIClientConfig() {
+ aaiConsumerClient = resolveClient();
+ }
+
+ AAIClientConfiguration resolveConfiguration() {
return prhAppConfig.getAAIClientConfiguration();
}
+
+ @Override
+ protected AAIConsumerClient resolveClient() {
+ return new AAIConsumerClient(resolveConfiguration());
+ }
}
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
index 24de3124..5d022f85 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java
@@ -79,11 +79,11 @@ public class AAIProducerTaskImpl extends AAIProducerTask<AAIProducerClient, Cons
logger.trace("initConfigs for AAIProducerTaskImpl not needed/supported");
}
- protected void setAAIClientConfig() {
+ void setAAIClientConfig() {
aaiProducerClient = resolveClient();
}
- protected AAIClientConfiguration resolveConfiguration() {
+ AAIClientConfiguration resolveConfiguration() {
return prhAppConfig.getAAIClientConfiguration();
}