aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/main')
-rw-r--r--common/src/main/java/org/onap/so/client/BaseClient.java2
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java1
-rw-r--r--common/src/main/java/org/onap/so/client/RestTemplateConfig.java3
-rw-r--r--common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java4
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java15
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java33
6 files changed, 28 insertions, 30 deletions
diff --git a/common/src/main/java/org/onap/so/client/BaseClient.java b/common/src/main/java/org/onap/so/client/BaseClient.java
index d1523a1f96..24c83cbcab 100644
--- a/common/src/main/java/org/onap/so/client/BaseClient.java
+++ b/common/src/main/java/org/onap/so/client/BaseClient.java
@@ -22,6 +22,7 @@ package org.onap.so.client;
import java.util.ArrayList;
import java.util.List;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
@@ -81,6 +82,7 @@ public class BaseClient<I, O> {
restTemplate
.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
restTemplate.getInterceptors().add(new SOSpringClientFilter());
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
ResponseEntity<O> responseEntity =
restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables);
return responseEntity.getBody();
diff --git a/common/src/main/java/org/onap/so/client/RestClient.java b/common/src/main/java/org/onap/so/client/RestClient.java
index c8d7dc9f5c..077ba24c2b 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -50,7 +50,6 @@ import org.onap.logging.filter.base.PayloadLoggingClientFilter;
import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.logging.jaxrs.filter.SOMetricLogClientFilter;
import org.onap.so.utils.CryptoUtils;
-import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
index 5fbc9126cf..f8587ff776 100644
--- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
+++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
@@ -20,6 +20,7 @@
package org.onap.so.client;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +47,7 @@ public class RestTemplateConfig {
restTemplate
.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
restTemplate.getInterceptors().add(new SOSpringClientFilter());
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
return restTemplate;
}
@@ -57,6 +59,7 @@ public class RestTemplateConfig {
final RestTemplate restTemplate =
new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory));
restTemplate.getInterceptors().add(new SOSpringClientFilter());
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
return restTemplate;
}
}
diff --git a/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java b/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java
index 8d30ad35ff..9f71e61e1f 100644
--- a/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java
+++ b/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java
@@ -16,10 +16,10 @@ import org.springframework.stereotype.Component;
@Component
public class AuditMDCSetup {
- private MDCSetup mdcSetup = new MDCSetup();
-
private static final Logger logger = LoggerFactory.getLogger(AuditMDCSetup.class);
+ private MDCSetup mdcSetup = new MDCSetup();
+
public void setupMDC(ExternalTask externalTask) {
MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
index 248e2f00bf..22a8d0405a 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
@@ -2,7 +2,6 @@ package org.onap.so.logging.jaxrs.filter;
import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientResponseContext;
-import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.filter.base.MetricLogClientFilter;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.logger.MdcConstants;
@@ -15,21 +14,19 @@ import org.slf4j.MarkerFactory;
public class SOMetricLogClientFilter extends MetricLogClientFilter {
- protected static Logger logger = LoggerFactory.getLogger(MDCSetup.class);
+ protected static Logger logger = LoggerFactory.getLogger(SOMetricLogClientFilter.class);
private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
- private MDCSetup mdcSetup = new MDCSetup();
-
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
try {
- mdcSetup.setLogTimestamp();
- mdcSetup.setElapsedTimeInvokeTimestamp();
- mdcSetup.setResponseStatusCode(responseContext.getStatus());
- mdcSetup.setResponseDescription(responseContext.getStatus());
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ setResponseStatusCode(responseContext.getStatus());
+ setResponseDescription(responseContext.getStatus());
MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus()));
logger.info(INVOKE_RETURN, "InvokeReturn");
- mdcSetup.clearClientMDCs();
+ clearClientMDCs();
setOpenStackResponseCode();
} catch (Exception e) {
logger.warn("Error in JAX-RS request,response client filter", e);
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
index c2b8df37c2..23df408ca5 100644
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
@@ -2,7 +2,6 @@ package org.onap.so.logging.jaxrs.filter;
import java.io.IOException;
import java.nio.charset.Charset;
-import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.filter.spring.SpringClientFilter;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.logger.MdcConstants;
@@ -11,6 +10,7 @@ import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.slf4j.Marker;
import org.slf4j.MarkerFactory;
+import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
@@ -20,27 +20,24 @@ import org.springframework.util.StreamUtils;
public class SOSpringClientFilter extends SpringClientFilter implements ClientHttpRequestInterceptor {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
- private MDCSetup mdcSetup = new MDCSetup();
private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN");
-
- protected void processResponse(ClientHttpResponse response) throws IOException {
- if (logger.isDebugEnabled()) {
- logger.debug("============================response begin==========================================");
- logger.debug("Status code : {}", response.getStatusCode());
- logger.debug("Status text : {}", response.getStatusText());
- logger.debug("Headers : {}", response.getHeaders());
- logger.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
- logger.debug("=======================response end=================================================");
+ @Override
+ protected void post(HttpRequest request, ClientHttpResponse response) {
+ setLogTimestamp();
+ setElapsedTimeInvokeTimestamp();
+ try {
+ setResponseStatusCode(response.getRawStatusCode());
+ int statusCode = response.getRawStatusCode();
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(statusCode));
+ setResponseDescription(statusCode);
+ } catch (IOException e) {
+ logger.error("Unable to get statusCode from response");
}
- mdcSetup.setLogTimestamp();
- mdcSetup.setElapsedTimeInvokeTimestamp();
- mdcSetup.setResponseStatusCode(response.getRawStatusCode());
- int statusCode = response.getRawStatusCode();
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(statusCode));
- mdcSetup.setResponseDescription(statusCode);
+
+
logger.info(INVOKE_RETURN, "InvokeReturn");
- mdcSetup.clearClientMDCs();
+ clearClientMDCs();
setOpenStackResponseCode();
}