summaryrefslogtreecommitdiffstats
path: root/prh-dmaap-client/src/main/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:44:33 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-09-04 09:44:33 +0200
commita4c979b6de8c1c76f0f12ae2b8dd0e60c3084830 (patch)
tree5fd8eca8889fb37000b834128fdd742dc05664df /prh-dmaap-client/src/main/java
parent3737046ff3c8e032257b257912778403fc058ee0 (diff)
Fixing code issues
1. SonarIssues 2. CheckStyle corrections 3. Empty code deletions 4. Adding AAIHeaders config to cloud configurations Change-Id: Id624c52bc7f57338fad5276fffd9f29b21af2f69 Issue-ID: DCAEGEN2-606 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-dmaap-client/src/main/java')
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java16
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java13
-rw-r--r--prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java6
3 files changed, 11 insertions, 24 deletions
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
index 4327dfbf..d34728ce 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/DMaaPReactiveWebClient.java
@@ -20,7 +20,6 @@
package org.onap.dcaegen2.services.prh.service;
-import org.onap.dcaegen2.services.prh.config.DmaapCustomConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -35,21 +34,6 @@ public class DMaaPReactiveWebClient {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private String dmaaPUserName;
- private String dmaaPUserPassword;
-
- /**
- * Creating DMaaPReactiveWebClient passing to them basic DMaaPConfig.
- *
- * @param dmaapCustomConfig - configuration object
- * @return DMaaPReactiveWebClient
- */
- public DMaaPReactiveWebClient fromConfiguration(DmaapCustomConfig dmaapCustomConfig) {
- this.dmaaPUserName = dmaapCustomConfig.dmaapUserName();
- this.dmaaPUserPassword = dmaapCustomConfig.dmaapUserPassword();
- return this;
- }
-
/**
* Construct Reactive WebClient with appropriate settings.
*
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java
index ab6686db..242214d2 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/consumer/DMaaPConsumerReactiveHttpClient.java
@@ -27,6 +27,7 @@ import static org.onap.dcaegen2.services.prh.model.logging.MdcVariables.X_ONAP_R
import java.net.URI;
import java.net.URISyntaxException;
import java.util.UUID;
+import java.util.function.Consumer;
import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.services.prh.config.DmaapConsumerConfiguration;
import org.slf4j.MDC;
@@ -74,9 +75,7 @@ public class DMaaPConsumerReactiveHttpClient {
return webClient
.get()
.uri(getUri())
- .header(X_ONAP_REQUEST_ID, MDC.get(REQUEST_ID))
- .header(X_INVOCATION_ID, UUID.randomUUID().toString())
- .header(HttpHeaders.CONTENT_TYPE, contentType)
+ .headers(getHeaders())
.retrieve()
.onStatus(HttpStatus::is4xxClientError, clientResponse ->
Mono.error(new RuntimeException("DmaaPConsumer HTTP " + clientResponse.statusCode()))
@@ -89,6 +88,14 @@ public class DMaaPConsumerReactiveHttpClient {
}
}
+ private Consumer<HttpHeaders> getHeaders() {
+ return httpHeaders -> {
+ httpHeaders.set(X_ONAP_REQUEST_ID, MDC.get(REQUEST_ID));
+ httpHeaders.set(X_INVOCATION_ID, UUID.randomUUID().toString());
+ httpHeaders.set(HttpHeaders.CONTENT_TYPE, contentType);
+ };
+ }
+
private String createRequestPath() {
return dmaapTopicName + "/" + consumerGroup + "/" + consumerId;
}
diff --git a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java
index 0b61f9c2..862ad841 100644
--- a/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java
+++ b/prh-dmaap-client/src/main/java/org/onap/dcaegen2/services/prh/service/producer/DMaaPProducerReactiveHttpClient.java
@@ -31,8 +31,6 @@ import java.util.UUID;
import org.apache.http.client.utils.URIBuilder;
import org.onap.dcaegen2.services.prh.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -46,13 +44,12 @@ import reactor.core.publisher.Mono;
*/
public class DMaaPProducerReactiveHttpClient {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
private final String dmaapHostName;
private final Integer dmaapPortNumber;
private final String dmaapProtocol;
private final String dmaapTopicName;
private final String dmaapContentType;
+
private RestTemplate restTemplate;
/**
@@ -81,7 +78,6 @@ public class DMaaPProducerReactiveHttpClient {
HttpEntity<String> request = new HttpEntity<>(createJsonBody(consumerDmaapModelMono), getAllHeaders());
return Mono.just(restTemplate.exchange(getUri(), HttpMethod.POST, request, String.class));
} catch (URISyntaxException e) {
- logger.warn("Exception while evaluating URI");
return Mono.error(e);
}
});