summaryrefslogtreecommitdiffstats
path: root/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java')
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
index 0b76ccaa..1772104a 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/service/consumer/ExtendedDmaapConsumerHttpClientImpl.java
@@ -53,7 +53,7 @@ public class ExtendedDmaapConsumerHttpClientImpl {
private final String dmaapContentType;
- ExtendedDmaapConsumerHttpClientImpl(DmaapConsumerConfiguration configuration) {
+ public ExtendedDmaapConsumerHttpClientImpl(DmaapConsumerConfiguration configuration) {
this.closeableHttpClient = new DmaapHttpClientImpl(configuration).getHttpClient();
this.dmaapHostName = configuration.dmaapHostName();
this.dmaapProtocol = configuration.dmaapProtocol();
@@ -108,38 +108,31 @@ public class ExtendedDmaapConsumerHttpClientImpl {
}
private URI createDmaapConsumerExtendedURI() {
- URI extendedURI = null;
-
- final URIBuilder uriBuilder = new URIBuilder()
+ try {
+ return new URIBuilder()
.setScheme(dmaapProtocol)
.setHost(dmaapHostName)
.setPort(dmaapPortNumber)
- .setPath(createRequestPath());
-
- try {
- extendedURI = uriBuilder.build();
- logger.info("Building extended URI: {}", extendedURI);
+ .setPath(createRequestPath()).build();
} catch (URISyntaxException e) {
- logger.error("Exception while building extended URI: {}", e);
+ throw new RuntimeException("Exception while building extended URI: {}", e);
}
-
- return extendedURI;
}
private ResponseHandler<Optional<String>> dmaapConsumerResponseHandler() {
- return httpResponse -> {
+ return httpResponse -> {
final int responseCode = httpResponse.getStatusLine().getStatusCode();
logger.info("Status code of operation: {}", responseCode);
final HttpEntity responseEntity = httpResponse.getEntity();
- if (HttpUtils.isSuccessfulResponseCode(responseCode) ) {
+ if (HttpUtils.isSuccessfulResponseCode(responseCode)) {
logger.info("HTTP response successful.");
final String dmaapResponse = EntityUtils.toString(responseEntity);
return Optional.of(dmaapResponse);
} else {
String dmaapResponse = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
logger.error("HTTP response not successful : {}", dmaapResponse);
- return Optional.of("" + responseCode);
+ return Optional.of(String.valueOf(responseCode));
}
};
}