summaryrefslogtreecommitdiffstats
path: root/prh-aai-client
diff options
context:
space:
mode:
authorwasala <przemyslaw.wasala@nokia.com>2018-06-13 11:39:14 +0200
committerwasala <przemyslaw.wasala@nokia.com>2018-06-15 11:34:41 +0200
commit5b38b56d8b6a7fca299e0243a7dc91d460f4735c (patch)
treebcdca27ef1443b633d0b540f36bbb593de7fec9d /prh-aai-client
parent3b630ca529d11bf6f158a71898583395e5c3ef75 (diff)
Added simply logs from tasks.
*Logging responsed object from DmaaP *Logging parsed oject from DmaaP *Logging sended object to AAI *Logging sended object and topic To DmaaP Change-Id: I33de0cd751762ac004f9d8a09beee921f4026af6 Issue-ID: DCAEGEN2-545 Signed-off-by: wasala <przemyslaw.wasala@nokia.com>
Diffstat (limited to 'prh-aai-client')
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIClientImpl.java8
-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.java29
3 files changed, 21 insertions, 18 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIClientImpl.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIClientImpl.java
index 5e938528..04652020 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIClientImpl.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AAIClientImpl.java
@@ -41,7 +41,7 @@ import java.security.NoSuchAlgorithmException;
public class AAIClientImpl implements AAIClient {
- private Logger logger = LoggerFactory.getLogger(AAIClientImpl.class);
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private AAIClientConfiguration aaiClientConfig;
@@ -62,10 +62,10 @@ public class AAIClientImpl implements AAIClient {
try {
logger.info("Setting SSL Context for AAI HTTP Client");
httpClientBuilder.setSSLContext(new SSLContextBuilder()
- .loadTrustMaterial(null, acceptingTrustStrategy)
- .build());
+ .loadTrustMaterial(null, acceptingTrustStrategy)
+ .build());
- } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e ) {
+ } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
logger.error("Exception while setting SSL Context for AAI HTTP Client: {}", e);
}
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 dfacc6b1..fafe6e04 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
@@ -42,7 +42,7 @@ import java.util.Optional;
public class AAIConsumerClient {
- private Logger logger = LoggerFactory.getLogger(AAIConsumerClient.class);
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final CloseableHttpClient closeableHttpClient;
private final String aaiHost;
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 f85ac8aa..0c2a12a3 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
@@ -20,6 +20,7 @@
package org.onap.dcaegen2.services.prh.service;
+import java.util.function.Predicate;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPatch;
@@ -46,14 +47,14 @@ 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 static Predicate<String> isEmpty = String::isEmpty;
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
private final CloseableHttpClient closeableHttpClient;
private final String aaiHost;
private final String aaiProtocol;
private final Integer aaiHostPortNumber;
private final String aaiPath;
- private final Map<String,String> aaiHeaders;
+ private final Map<String, String> aaiHeaders;
private final String aaiUserName;
private final String aaiUserPassword;
@@ -96,19 +97,21 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
}
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_MESSAGE, e);
- }
- return Optional.empty();
- });
+ return Optional.ofNullable(CommonFunctions.createJsonBody(consumerDmaapModel)).filter(isEmpty.negate())
+ .flatMap(myJson -> {
+ try {
+ logger.info("AAI: sending json {}", myJson);
+ return Optional.of(createHttpPatch(extendedURI, myJson));
+ } catch (UnsupportedEncodingException e) {
+ logger.warn(EXCEPTION_MESSAGE, e);
+ }
+ return Optional.empty();
+ });
}
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");
httpPatch.addHeader("Authorization", "Basic " + encode());
@@ -117,7 +120,7 @@ public class AAIProducerClient implements AAIExtendedHttpClient {
String encode() throws UnsupportedEncodingException {
return Base64.getEncoder().encodeToString((this.aaiUserName + ":" + this.aaiUserPassword)
- .getBytes("UTF-8"));
+ .getBytes("UTF-8"));
}
Optional<Integer> handleResponse(HttpResponse response) throws IOException {