diff options
author | pwielebs <piotr.wielebski@nokia.com> | 2018-04-21 16:51:20 +0200 |
---|---|---|
committer | pwielebs <piotr.wielebski@nokia.com> | 2018-04-23 15:07:22 +0200 |
commit | a274374b520aad75c99cdce7f4f9ebc31ce74343 (patch) | |
tree | d537e1747184cf7688c7db48bcc91fdc84482817 /prh-aai-client/src | |
parent | 1fb9130cd488228574b49e078148e4bcf1a7a5a8 (diff) |
DmaaP http clients added
Change-Id: I1acc7e2a46b81b0af9a3b23982582c9e0053ffa1
Issue-ID: DCAEGEN2-451
Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-aai-client/src')
-rw-r--r-- | prh-aai-client/src/main/java/org/onap/dcaegen2/services/service/AAIExtendedHttpClientImpl.java | 25 |
1 files changed, 11 insertions, 14 deletions
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); + } } |