summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java3
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTaskImpl.java7
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTaskImpl.java10
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java30
8 files changed, 30 insertions, 28 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
index 275685fe..269e7a2a 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/HeartbeatController.java
@@ -23,9 +23,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
index 4cde51bf..cd3347fe 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/controllers/ScheduleController.java
@@ -21,12 +21,9 @@ package org.onap.dcaegen2.services.prh.controllers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledFuture;
-
import org.onap.dcaegen2.services.prh.configuration.PrhAppConfig;
import org.onap.dcaegen2.services.prh.tasks.ScheduledTasks;
import org.slf4j.Logger;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
index a3c7d1d3..c6879948 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java
@@ -27,7 +27,7 @@ import org.immutables.value.Value;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18
*/
-@Value.Immutable(prehash = true)
+@Value.Immutable
@Gson.TypeAdapters
public interface ConsumerDmaapModel {
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
index e2d9816e..0ef7e4fe 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
@@ -22,7 +22,6 @@ package org.onap.dcaegen2.services.prh.service;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import java.util.Optional;
import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel;
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 1c80d3f9..95352d44 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,22 +20,17 @@
package org.onap.dcaegen2.services.prh.tasks;
+import java.util.Optional;
import org.onap.dcaegen2.services.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.service.AAIProducerClient;
-import org.onap.dcaegen2.services.utils.HttpRequestDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Optional;
-
@Component
public class AAIConsumerTaskImpl extends AAIConsumerTask<AAIClientConfiguration> {
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 a254890f..4a7d9282 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
@@ -24,6 +24,7 @@ import org.onap.dcaegen2.services.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.exceptions.PrhTaskException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel;
import org.onap.dcaegen2.services.service.AAIProducerClient;
@@ -65,10 +66,13 @@ public class AAIProducerTaskImpl extends AAIProducerTask<AAIClientConfiguration,
}
@Override
- public Object execute(Object object) throws AAINotFoundException {
+ public Object execute(Object object) throws PrhTaskException {
logger.trace("Method %M called with arg {}", object);
- //TODO: @Piotr Wielebski
- return publish((ConsumerDmaapModel) object);
+ if (object instanceof ConsumerDmaapModel) {
+ //TODO: @Piotr Wielebski
+ return publish((ConsumerDmaapModel) object);
+ }
+ throw new AAINotFoundException("Incorrect object type");
}
@Override
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
index 7b9fd5db..2329274b 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTask.java
@@ -26,7 +26,7 @@ import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
*/
public abstract class DmaapPublisherTask<T, U> extends Task {
- protected abstract U publish(U message) throws DmaapNotFoundException;
+ protected abstract String publish(U message) throws DmaapNotFoundException;
protected abstract T 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 906bd428..60ab64fd 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,29 +19,31 @@
*/
package org.onap.dcaegen2.services.prh.tasks;
+import com.google.gson.Gson;
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.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.service.producer.DmaapPublisherRequestDetails;
import org.onap.dcaegen2.services.service.producer.ExtendedDmaapProducerHttpClientImpl;
import org.onap.dcaegen2.services.service.producer.ImmutableDmaapPublisherRequestDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
@Component
-public class DmaapPublisherTaskImpl extends DmaapPublisherTask<DmaapPublisherConfiguration, String> {
+public class DmaapPublisherTaskImpl extends
+ DmaapPublisherTask<DmaapPublisherConfiguration, ConsumerDmaapModel> {
private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);
+ private static final Gson gson = new Gson();
private final Config prhAppConfig;
@Autowired
@@ -50,17 +52,25 @@ public class DmaapPublisherTaskImpl extends DmaapPublisherTask<DmaapPublisherCon
}
@Override
- protected String publish(String message) {
- logger.trace("Method %M called with arg {}", message);
+ protected String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException {
+ logger.trace("Method %M called with arg {}", consumerDmaapModel);
ExtendedDmaapProducerHttpClientImpl dmaapProducerHttpClient = new ExtendedDmaapProducerHttpClientImpl(
resolveConfiguration());
- return null;
+ DmaapPublisherRequestDetails dmaapPublisherRequestDetails = new ImmutableDmaapPublisherRequestDetails.Builder()
+ .dmaapAPIPath("events").jsonBody(gson.toJson(consumerDmaapModel)).build();
+ return dmaapProducerHttpClient.getHttpProducerResponse(dmaapPublisherRequestDetails)
+ .filter(x -> !x.isEmpty() && x.equals(String.valueOf(HttpStatus.OK.value())))
+ .orElseThrow(() -> new DmaapNotFoundException("Incorrect response from Dmmap"));
+
}
@Override
public Object execute(Object object) throws PrhTaskException {
- logger.trace("Method %M called with arg {}", object);
- return publish((String) object);
+ if (object instanceof ConsumerDmaapModel) {
+ logger.trace("Method %M called with arg {}", object);
+ return publish((ConsumerDmaapModel) object);
+ }
+ throw new DmaapNotFoundException("Incorrect object type");
}
@Override