diff options
Diffstat (limited to 'prh-aai-client')
-rw-r--r-- | prh-aai-client/pom.xml | 1 | ||||
-rw-r--r-- | prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java | 25 |
2 files changed, 11 insertions, 15 deletions
diff --git a/prh-aai-client/pom.xml b/prh-aai-client/pom.xml index 4f5e1867..1b2b1991 100644 --- a/prh-aai-client/pom.xml +++ b/prh-aai-client/pom.xml @@ -105,7 +105,6 @@ <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> - <version>2.16.0</version> <scope>test</scope> </dependency> </dependencies> diff --git a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java index 85c8caba..2e6aa9e6 100644 --- a/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java +++ b/prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java @@ -65,24 +65,13 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient { } @Override - public Optional<String> getHttpResponse(HttpRequestDetails httpRequestDetails) { + public Optional<String> getHttpResponse(HttpRequestDetails requestDetails) { Optional<String> extendedDetails = Optional.empty(); - - final URI extendedURI = createAAIExtendedURI(httpRequestDetails.aaiAPIPath(), - httpRequestDetails.queryParameters()); - final HttpRequestBase request = createHttpRequest(extendedURI, httpRequestDetails); - - if (request == null) { - return Optional.empty(); - } - - for (Map.Entry<String, String> headersEntry : httpRequestDetails.headers().entrySet()) { - request.addHeader(headersEntry.getKey(), headersEntry.getValue()); - } + Optional<HttpRequestBase> request = createRequest(requestDetails); try { - extendedDetails = closeableHttpClient.execute(request, aaiResponseHandler()); + extendedDetails = closeableHttpClient.execute(request.get(), aaiResponseHandler()); } catch (IOException e) { logger.error("Exception while executing HTTP request: {}", e); } @@ -191,4 +180,12 @@ public class AAIExtendedHttpClientImpl implements AAIExtendedHttpClient { private Boolean isPatchRequestValid(RequestVerbs requestVerb, Optional<String> jsonBody) { return requestVerb == RequestVerbs.PATCH && jsonBody.isPresent(); } + + private Optional<HttpRequestBase> createRequest(HttpRequestDetails requestDetails) { + + final URI extendedURI = createAAIExtendedURI(requestDetails.aaiAPIPath(), requestDetails.queryParameters()); + HttpRequestBase request = createHttpRequest(extendedURI, requestDetails); + requestDetails.headers().forEach(request::addHeader); + return Optional.of(request); + } } |