summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java2
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java58
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIConsumerTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java2
-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/DmaapPublisherTask.java2
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/DmaapPublisherTaskImpl.java1
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java10
-rw-r--r--prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java18
-rw-r--r--prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java2
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java4
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java2
12 files changed, 54 insertions, 51 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
index 99a4a8b2..aa4630b5 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIConsumerClient.java
@@ -94,7 +94,7 @@ public class AAIConsumerClient {
private ResponseHandler<Optional<String>> aaiResponseHandler() {
return httpResponse -> {
final int responseCode = httpResponse.getStatusLine().getStatusCode();
- logger.trace("Status code of operation: {}", responseCode);
+ logger.info("Status code of operation: {}", responseCode);
final HttpEntity responseEntity = httpResponse.getEntity();
if (HttpUtils.isSuccessfulResponseCode(responseCode) ) {
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
index 4f48c1c3..bb4d145e 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIProducerClient.java
@@ -44,6 +44,8 @@ import java.util.Map;
import java.util.Optional;
public class AAIProducerClient implements AAIExtendedHttpClient {
+
+ private static final String EXCEPTION_MESSAGE = "Exception while executing http client: ";
private Logger logger = LoggerFactory.getLogger(AAIProducerClient.class);
private final CloseableHttpClient closeableHttpClient;
@@ -51,7 +53,7 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
private final String aaiProtocol;
private final Integer aaiHostPortNumber;
private final String aaiPath;
- private final Map<String,String> aaiHeaders;
+ private final Map<String, String> aaiHeaders;
public AAIProducerClient(AAIClientConfiguration aaiClientConfiguration) {
@@ -66,20 +68,15 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
@Override
public Optional<Integer> getHttpResponse(ConsumerDmaapModel consumerDmaapModel) throws
- URISyntaxException {
- try {
- return createRequest(consumerDmaapModel).flatMap(x->{
- try {
- return closeableHttpClient.execute(x, aaiResponseHandler());
- } catch (IOException e) {
- logger.warn("Exception while executing http client: ", e);
- return Optional.empty();
- }
- });
- } catch (URISyntaxException e ) {
- logger.warn("Exception while executing http client: ", e);
- throw e;
- }
+ URISyntaxException {
+ return createRequest(consumerDmaapModel).flatMap(x -> {
+ try {
+ return closeableHttpClient.execute(x, aaiResponseHandler());
+ } catch (IOException e) {
+ logger.warn(EXCEPTION_MESSAGE, e);
+ return Optional.empty();
+ }
+ });
}
private Optional<HttpRequestBase> createRequest(ConsumerDmaapModel consumerDmaapModel) throws URISyntaxException {
@@ -89,16 +86,16 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
private URI createAAIExtendedURI(final String pnfName) throws URISyntaxException {
return new URIBuilder()
- .setScheme(aaiProtocol)
- .setHost(aaiHost)
- .setPort(aaiHostPortNumber)
- .setPath(aaiPath + "/" + pnfName).build();
+ .setScheme(aaiProtocol)
+ .setHost(aaiHost)
+ .setPort(aaiHostPortNumber)
+ .setPath(aaiPath + "/" + pnfName).build();
}
private ResponseHandler<Optional<Integer>> aaiResponseHandler() {
- return (HttpResponse httpResponse) -> {
+ return (HttpResponse httpResponse) -> {
final Integer responseCode = httpResponse.getStatusLine().getStatusCode();
- logger.trace("Status code of operation: {}", responseCode);
+ logger.info("Status code of operation: {}", responseCode);
final HttpEntity responseEntity = httpResponse.getEntity();
if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
@@ -113,19 +110,20 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
}
private Optional<HttpRequestBase> createHttpRequest(URI extendedURI, ConsumerDmaapModel consumerDmaapModel) {
- return Optional.ofNullable(CommonFunctions.createJsonBody(consumerDmaapModel)).filter(x-> !x.isEmpty()).flatMap(myJson -> {
- try {
- return Optional.of(createHttpPatch(extendedURI, myJson));
- } catch (UnsupportedEncodingException e) {
- logger.warn("Exception while executing http client: ", e);
- }
- return Optional.empty();
- });
+ return Optional.ofNullable(CommonFunctions.createJsonBody(consumerDmaapModel)).filter(x -> !x.isEmpty())
+ .flatMap(myJson -> {
+ try {
+ return Optional.of(createHttpPatch(extendedURI, myJson));
+ } catch (UnsupportedEncodingException e) {
+ logger.warn(EXCEPTION_MESSAGE, e);
+ }
+ return Optional.empty();
+ });
}
private HttpPatch createHttpPatch(URI extendedURI, String jsonBody) throws UnsupportedEncodingException {
HttpPatch httpPatch = new HttpPatch(extendedURI);
- httpPatch.setEntity( new StringEntity(jsonBody));
+ httpPatch.setEntity(new StringEntity(jsonBody));
aaiHeaders.forEach(httpPatch::addHeader);
httpPatch.addHeader("Content-Type", "application/merge-patch+json");
return httpPatch;
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 09de5cca..784bc5af 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
@@ -25,7 +25,7 @@ import org.onap.dcaegen2.services.prh.exceptions.AAINotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.service.AAIConsumerClient;
-public abstract class AAIConsumerTask<Request, Response, Conf> extends Task<Request, Response, Conf> {
+public abstract class AAIConsumerTask<R, S, C> extends Task<R, S, C> {
abstract Optional<String> consume(ConsumerDmaapModel message) throws AAINotFoundException;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
index 82362809..c7bde032 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/AAIProducerTask.java
@@ -26,7 +26,7 @@ import org.onap.dcaegen2.services.prh.service.AAIProducerClient;
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
-public abstract class AAIProducerTask<Request, Response, Config> extends Task<Request, Response, Config> {
+public abstract class AAIProducerTask<R, S, C> extends Task<R, S, C> {
abstract ConsumerDmaapModel publish(ConsumerDmaapModel message) throws AAINotFoundException;
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 4bd8731c..fcadc483 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
@@ -26,7 +26,7 @@ import org.onap.dcaegen2.services.prh.service.consumer.ExtendedDmaapConsumerHttp
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/13/18
*/
-abstract class DmaapConsumerTask<Request, Response, Config> extends Task<Request, Response, Config> {
+abstract class DmaapConsumerTask<R, S, C> extends Task<R, S, C> {
abstract ConsumerDmaapModel consume(String message) throws DmaapNotFoundException;
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 ab3e4696..4e95a0d1 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.service.producer.ExtendedDmaapProducerHttp
/**
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 3/23/18
*/
-abstract class DmaapPublisherTask<Request, Response, Config> extends Task<Request, Response, Config> {
+abstract class DmaapPublisherTask<R, S, C> extends Task<R, S, C> {
abstract String publish(ConsumerDmaapModel consumerDmaapModel) throws DmaapNotFoundException;
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 1a8f60fc..8f2541c8 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
@@ -24,7 +24,6 @@ import org.onap.dcaegen2.services.prh.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.prh.service.producer.ExtendedDmaapProducerHttpClientImpl;
import org.slf4j.Logger;
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
index 46e19dad..8aa01446 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/Task.java
@@ -26,7 +26,7 @@ import org.onap.dcaegen2.services.prh.exceptions.PrhTaskException;
*/
-public abstract class Task<Request, Response, Config> {
+public abstract class Task<R, S, C> {
private Task taskProcess;
@@ -34,15 +34,15 @@ public abstract class Task<Request, Response, Config> {
this.taskProcess = task;
}
- public void receiveRequest(Request body) throws PrhTaskException {
+ public void receiveRequest(R body) throws PrhTaskException {
- Response response = execute(body);
+ S response = execute(body);
if (taskProcess != null) {
taskProcess.receiveRequest(response);
}
}
- abstract Response execute(Request object) throws PrhTaskException;
+ abstract S execute(R object) throws PrhTaskException;
- abstract Config resolveConfiguration();
+ abstract C resolveConfiguration();
}
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
index 9e272aae..7b48bd80 100644
--- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
+++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModelForUnitTest.java
@@ -22,21 +22,27 @@ package org.onap.dcaegen2.services.prh.model;
public class ConsumerDmaapModelForUnitTest implements ConsumerDmaapModel {
- private final String PNF_NAME = "NOKnhfsadhff";
- private final String IPv4 = "256.22.33.155";
- private final String IPv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
+ private final String pnfName;
+ private final String ipv4;
+ private final String ipv6;
+ public ConsumerDmaapModelForUnitTest() {
+ this.pnfName = "NOKnhfsadhff";
+ this.ipv4 = "256.22.33.155";
+ this.ipv6 = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
+
+ }
public String getPnfName() {
- return PNF_NAME;
+ return pnfName;
}
public String getIpv4() {
- return IPv4;
+ return ipv4;
}
public String getIpv6() {
- return IPv6;
+ return ipv6;
}
}
diff --git a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
index 6f99f1c7..3981901e 100644
--- a/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
+++ b/prh-commons/src/test/java/org/onap/dcaegen2/services/prh/model/CommonFunctionsTest.java
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
public class CommonFunctionsTest {
private ConsumerDmaapModel model = new ConsumerDmaapModelForUnitTest();
- private String expectedResult = "{\"PNF_NAME\":\"NOKnhfsadhff\",\"IPv4\":\"256.22.33.155\",\"IPv6\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
+ private String expectedResult = "{\"pnfName\":\"NOKnhfsadhff\",\"ipv4\":\"256.22.33.155\",\"ipv6\":\"2001:0db8:85a3:0000:0000:8a2e:0370:7334\"}";
@Test
public void createJsonBody_shouldReturnJsonInString() {
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
index 8d2f82d9..053f1a7d 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
@@ -115,12 +115,12 @@ public class ExtendedDmaapConsumerHttpClientImpl {
final HttpEntity responseEntity = httpResponse.getEntity();
if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
- logger.info("HTTP response successful.");
+ logger.trace("HTTP response successful.");
final String dmaapResponse = EntityUtils.toString(responseEntity);
return Optional.of(dmaapResponse);
} else {
String dmaapResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
- logger.warn("HTTP response not successful : {}", dmaapResponse);
+ logger.trace("HTTP response not successful : {}", dmaapResponse);
return Optional.of(String.valueOf(responseCode));
}
};
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
index 2f96b396..72e70b98 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/ExtendedDmaapProducerHttpClientImpl.java
@@ -123,7 +123,7 @@ public class ExtendedDmaapProducerHttpClientImpl {
return Optional.of("" + responseCode);
} else {
String response = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
- logger.warn("HTTP response not successful : {}", response);
+ logger.trace("HTTP response not successful : {}", response);
return Optional.of("" + responseCode);
}
}