aboutsummaryrefslogtreecommitdiffstats
path: root/prh-aai-client/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'prh-aai-client/src/main/java/org')
-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);