summaryrefslogtreecommitdiffstats
path: root/prh-aai-client/src/main/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-08-22 12:57:54 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-08-22 12:59:13 +0200
commit640c573821ac2a90a73244c558f209b5c4eb42d5 (patch)
treea1c924b8e6d1b0cefb23e45d12bce372d9f93266 /prh-aai-client/src/main/java
parent14df4b094cc2701b10d5b93274e5d890e1967b53 (diff)
Fix for logging:
- removal of authentication in Dmaap client - improvement of logging in the DmaaP's & AAI's clients - Dmaap Topic upgraded according to VES 7.0 spec - correction in tasks scheduling Change-Id: Ie0b153b5544c69be54718460247dcd1d83f6ebe2 Issue-ID: DCAEGEN2-721 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-aai-client/src/main/java')
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java13
-rw-r--r--prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java13
2 files changed, 17 insertions, 9 deletions
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
index 2b156936..d79e245a 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/AaiReactiveWebClient.java
@@ -41,6 +41,7 @@ public class AaiReactiveWebClient {
/**
* Creating AaiReactiveWebClient.
+ *
* @param configuration - configuration object
* @return AaiReactiveWebClient
*/
@@ -58,18 +59,18 @@ public class AaiReactiveWebClient {
*/
public WebClient build() {
return WebClient.builder()
- .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders))
- .filter(basicAuthentication(aaiUserName, aaiUserPassword))
- .filter(logRequest())
- .filter(logResponse())
- .build();
+ .defaultHeaders(httpHeaders -> httpHeaders.setAll(aaiHeaders))
+ .filter(basicAuthentication(aaiUserName, aaiUserPassword))
+ .filter(logRequest())
+ .filter(logResponse())
+ .build();
}
private ExchangeFilterFunction logRequest() {
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
logger.info("Request: {} {}", clientRequest.method(), clientRequest.url());
clientRequest.headers()
- .forEach((name, values) -> values.forEach(value -> logger.info("{}={}",name, value)));
+ .forEach((name, values) -> values.forEach(value -> logger.info("{}={}", name, value)));
return Mono.just(clientRequest);
});
}
diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
index b43c2164..ff5d4bb7 100644
--- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
+++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/AaiProducerReactiveHttpClient.java
@@ -27,6 +27,8 @@ import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.services.prh.config.AaiClientConfiguration;
import org.onap.dcaegen2.services.prh.exceptions.AaiRequestException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.client.WebClient;
@@ -40,6 +42,7 @@ public class AaiProducerReactiveHttpClient {
private final String aaiProtocol;
private final Integer aaiHostPortNumber;
private final String aaiBasePath;
+ private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
@@ -61,7 +64,9 @@ public class AaiProducerReactiveHttpClient {
* @return status code of operation
*/
public Mono<Integer> getAaiProducerResponse(Mono<ConsumerDmaapModel> consumerDmaapModelMono) {
- return consumerDmaapModelMono.flatMap(this::patchAaiRequest);
+ return consumerDmaapModelMono
+ .doOnNext(consumerDmaapModel -> logger.info("Sending PNF model to AAI {}", consumerDmaapModel))
+ .flatMap(this::patchAaiRequest);
}
public AaiProducerReactiveHttpClient createAaiWebClient(WebClient webClient) {
@@ -77,10 +82,12 @@ public class AaiProducerReactiveHttpClient {
.retrieve()
.onStatus(
HttpStatus::is4xxClientError,
- clientResponse -> Mono.error(new AaiRequestException("HTTP 400"))
+ clientResponse -> Mono
+ .error(new AaiRequestException("AaiProducer HTTP " + clientResponse.statusCode()))
)
.onStatus(HttpStatus::is5xxServerError,
- clientResponse -> Mono.error(new AaiRequestException("HTTP 500")))
+ clientResponse -> Mono
+ .error(new AaiRequestException("AaiProducer HTTP " + clientResponse.statusCode())))
.bodyToMono(Integer.class);
} catch (URISyntaxException e) {
return Mono.error(e);