summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java10
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java1
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java10
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java4
-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
-rw-r--r--common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java4
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java2
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java3
13 files changed, 58 insertions, 34 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java
index ff0f8dc432..cd3b2a377b 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/WebMvcConfig.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.catalogdb;
import org.onap.logging.filter.spring.LoggingInterceptor;
+import org.onap.logging.filter.spring.StatusLoggingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
- LoggingInterceptor loggingInterceptor;
+ private LoggingInterceptor loggingInterceptor;
+
+ @Autowired
+ private StatusLoggingInterceptor statusLoggingInterceptor;
@Bean
public MappedInterceptor mappedLoggingInterceptor() {
return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor);
}
+ @Bean
+ public MappedInterceptor mappedStatusLoggingInterceptor() {
+ return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor);
+ }
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
index e1dc4cab66..3a14b2ff84 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/MSORequestDBApplication.java
@@ -41,7 +41,6 @@ import net.javacrumbs.shedlock.spring.ScheduledLockConfigurationBuilder;
* @since Version 1.0
*
*/
-
@SpringBootApplication(scanBasePackages = {"org.onap.so", "org.onap.logging.filter"})
@EnableScheduling
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
index c0dfbe08ef..9135d31ac3 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/application/WebMvcConfig.java
@@ -22,6 +22,7 @@ package org.onap.so.adapters.requestsdb.application;
import org.onap.logging.filter.spring.LoggingInterceptor;
+import org.onap.logging.filter.spring.StatusLoggingInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
@@ -34,11 +35,18 @@ import org.springframework.web.servlet.handler.MappedInterceptor;
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
- LoggingInterceptor loggingInterceptor;
+ private LoggingInterceptor loggingInterceptor;
+
+ @Autowired
+ private StatusLoggingInterceptor statusLoggingInterceptor;
@Bean
public MappedInterceptor mappedLoggingInterceptor() {
return new MappedInterceptor(new String[] {"/**"}, loggingInterceptor);
}
+ @Bean
+ public MappedInterceptor mappedStatusLoggingInterceptor() {
+ return new MappedInterceptor(new String[] {"/**"}, statusLoggingInterceptor);
+ }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
index b621759b59..ae9316cfdf 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
@@ -42,6 +42,7 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
@@ -173,7 +174,8 @@ public class VnfmServiceProviderConfiguration {
private void removeSpringClientFilter(final RestTemplate restTemplate) {
ListIterator<ClientHttpRequestInterceptor> interceptorIterator = restTemplate.getInterceptors().listIterator();
while (interceptorIterator.hasNext()) {
- if (interceptorIterator.next() instanceof SOSpringClientFilter) {
+ ClientHttpRequestInterceptor interceptor = interceptorIterator.next();
+ if (interceptor instanceof SOSpringClientFilter || interceptor instanceof SpringClientPayloadFilter) {
interceptorIterator.remove();
}
}
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();
}
diff --git a/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java b/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java
index 5e2a51a56f..c4609f0336 100644
--- a/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java
+++ b/common/src/test/java/org/onap/so/externaltasks/logging/AuditMDCSetupTest.java
@@ -12,6 +12,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.logging.filter.base.MDCSetup;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.logger.MdcConstants;
import org.slf4j.MDC;
@@ -22,6 +23,9 @@ public class AuditMDCSetupTest {
@Mock
private ExternalTask externalTask;
+ @Mock
+ private MDCSetup mdcSet;
+
@Spy
@InjectMocks
private AuditMDCSetup mdcSetup;
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 5ea0d3c54a..99c1d1ea72 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -32,6 +32,7 @@ import javax.annotation.PostConstruct;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
@@ -158,6 +159,7 @@ public class RequestsDbClient {
return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory)
.setRestTemplateConfigurer(restTemplate -> {
restTemplate.getInterceptors().add((new SOSpringClientFilter()));
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
restTemplate.getInterceptors().add((request, body, execution) -> {
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index fcafe90405..0486494c53 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
import org.onap.logging.filter.base.Constants;
+import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
@@ -368,6 +369,7 @@ public class CatalogDbClient {
ClientFactory clientFactory =
Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> {
restTemplate.getInterceptors().add((new SOSpringClientFilter()));
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
restTemplate.getInterceptors().add((request, body, execution) -> {
@@ -417,6 +419,7 @@ public class CatalogDbClient {
ClientFactory clientFactory = Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory)
.setRestTemplateConfigurer(restTemplate -> {
restTemplate.getInterceptors().add((new SOSpringClientFilter()));
+ restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
restTemplate.getInterceptors().add((request, body, execution) -> {