summaryrefslogtreecommitdiffstats
path: root/common/src/main/java/org
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2019-09-10 11:29:42 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-09-10 11:29:42 -0400
commit2ede5f09c9601d543f20d466a21e9e85c29eacc7 (patch)
treeb9b0e7f777b87a390ce4fb9ba870c49aab382bcc /common/src/main/java/org
parent464d3ffa9c373f36747b10a03554d20dfa4a571b (diff)
Integrate Logging Library
Updated SO to use ONAP provided filters and constants to meet logging standards. Removed redundant classes Updated constant references Issue-ID: SO-2301 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia4e3c2b1a4dcb3881aa34d39885c8b2782880d64
Diffstat (limited to 'common/src/main/java/org')
-rw-r--r--common/src/main/java/org/onap/so/client/BaseClient.java4
-rw-r--r--common/src/main/java/org/onap/so/client/HttpClient.java8
-rw-r--r--common/src/main/java/org/onap/so/client/HttpClientFactory.java8
-rw-r--r--common/src/main/java/org/onap/so/client/RestClient.java21
-rw-r--r--common/src/main/java/org/onap/so/client/RestTemplateConfig.java6
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIRestClient.java6
-rw-r--r--common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java6
-rw-r--r--common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java14
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java5
-rw-r--r--common/src/main/java/org/onap/so/client/grm/GRMRestClient.java6
-rw-r--r--common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java6
-rw-r--r--common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java56
-rw-r--r--common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java8
-rw-r--r--common/src/main/java/org/onap/so/logger/LogConstants.java2
-rw-r--r--common/src/main/java/org/onap/so/logger/MdcConstants.java10
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java136
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java173
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java111
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java43
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/PayloadLoggingFilter.java158
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java34
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java44
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java52
-rw-r--r--common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java156
-rw-r--r--common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java132
-rw-r--r--common/src/main/java/org/onap/so/utils/Components.java7
-rw-r--r--common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java10
-rw-r--r--common/src/main/java/org/onap/so/utils/TargetEntities.java27
-rw-r--r--common/src/main/java/org/onap/so/utils/TargetEntity.java59
29 files changed, 244 insertions, 1064 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 d939a33358..d1523a1f96 100644
--- a/common/src/main/java/org/onap/so/client/BaseClient.java
+++ b/common/src/main/java/org/onap/so/client/BaseClient.java
@@ -22,7 +22,7 @@ package org.onap.so.client;
import java.util.ArrayList;
import java.util.List;
-import org.onap.so.logging.jaxrs.filter.SpringClientFilter;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -80,7 +80,7 @@ public class BaseClient<I, O> {
RestTemplate restTemplate = new RestTemplate();
restTemplate
.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
- restTemplate.getInterceptors().add(new SpringClientFilter());
+ restTemplate.getInterceptors().add(new SOSpringClientFilter());
ResponseEntity<O> responseEntity =
restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables);
return responseEntity.getBody();
diff --git a/common/src/main/java/org/onap/so/client/HttpClient.java b/common/src/main/java/org/onap/so/client/HttpClient.java
index 715ba32831..63a4b1cd65 100644
--- a/common/src/main/java/org/onap/so/client/HttpClient.java
+++ b/common/src/main/java/org/onap/so/client/HttpClient.java
@@ -24,22 +24,22 @@ import java.net.URL;
import java.util.Map;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.*;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HttpClient extends RestClient {
protected final Logger log = LoggerFactory.getLogger(HttpClient.class);
- private TargetEntity targetEntity;
+ private ONAPComponents targetEntity;
- HttpClient(URL host, String contentType, TargetEntity targetEntity) {
+ HttpClient(URL host, String contentType, ONAPComponents targetEntity) {
super(host, contentType);
this.targetEntity = targetEntity;
}
@Override
- public TargetEntity getTargetEntity() {
+ public ONAPComponents getTargetEntity() {
return targetEntity;
}
diff --git a/common/src/main/java/org/onap/so/client/HttpClientFactory.java b/common/src/main/java/org/onap/so/client/HttpClientFactory.java
index d02c18ff56..3a8a9ee1bd 100644
--- a/common/src/main/java/org/onap/so/client/HttpClientFactory.java
+++ b/common/src/main/java/org/onap/so/client/HttpClientFactory.java
@@ -21,19 +21,19 @@ package org.onap.so.client;
import java.net.URL;
import javax.ws.rs.core.MediaType;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
public class HttpClientFactory {
- public HttpClient newJsonClient(URL host, TargetEntity targetEntity) {
+ public HttpClient newJsonClient(URL host, ONAPComponents targetEntity) {
return new HttpClient(host, MediaType.APPLICATION_JSON, targetEntity);
}
- public HttpClient newXmlClient(URL host, TargetEntity targetEntity) {
+ public HttpClient newXmlClient(URL host, ONAPComponents targetEntity) {
return new HttpClient(host, MediaType.APPLICATION_XML, targetEntity);
}
- public HttpClient newTextXmlClient(URL host, TargetEntity targetEntity) {
+ public HttpClient newTextXmlClient(URL host, ONAPComponents targetEntity) {
return new HttpClient(host, MediaType.TEXT_XML, targetEntity);
}
}
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 d3a4d444f7..c8d7dc9f5c 100644
--- a/common/src/main/java/org/onap/so/client/RestClient.java
+++ b/common/src/main/java/org/onap/so/client/RestClient.java
@@ -44,11 +44,13 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriBuilder;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.filter.base.ONAPComponentsList;
+import org.onap.logging.filter.base.PayloadLoggingClientFilter;
import org.onap.so.client.policy.CommonObjectMapperProvider;
-import org.onap.so.logging.jaxrs.filter.JaxRsClientLogging;
-import org.onap.so.logging.jaxrs.filter.PayloadLoggingFilter;
+import org.onap.so.logging.jaxrs.filter.SOMetricLogClientFilter;
import org.onap.so.utils.CryptoUtils;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
@@ -71,7 +73,8 @@ public abstract class RestClient {
protected String accept;
protected String contentType;
protected String requestId = "";
- protected JaxRsClientLogging jaxRsClientLogging;
+ protected SOMetricLogClientFilter metricLogClientFilter;
+ protected MDCSetup mdcSetup = new MDCSetup();
protected RestProperties props;
protected RestClient(RestProperties props, Optional<URI> path) {
@@ -179,18 +182,18 @@ public abstract class RestClient {
return ClientBuilder.newBuilder().build();
}
- protected abstract TargetEntity getTargetEntity();
+ protected abstract ONAPComponentsList getTargetEntity();
protected void initializeClient(Client client) {
if (this.enableLogging()) {
- client.register(new PayloadLoggingFilter(this.getMaxPayloadSize()));
+ client.register(new PayloadLoggingClientFilter(this.getMaxPayloadSize()));
}
CommonObjectMapperProvider provider = this.getCommonObjectMapperProvider();
client.register(new JacksonJsonProvider(provider.getMapper()));
- jaxRsClientLogging = new JaxRsClientLogging();
- jaxRsClientLogging.setTargetService(getTargetEntity());
- client.register(jaxRsClientLogging);
+ metricLogClientFilter = new SOMetricLogClientFilter();
+ mdcSetup.setTargetEntity(getTargetEntity());
+ client.register(metricLogClientFilter);
if (!path.isPresent()) {
webTarget = client.target(host.toString());
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 0633ae74c9..5fbc9126cf 100644
--- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
+++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java
@@ -21,7 +21,7 @@
package org.onap.so.client;
import org.onap.so.configuration.rest.HttpComponentsClientConfiguration;
-import org.onap.so.logging.jaxrs.filter.SpringClientFilter;
+import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
@@ -45,7 +45,7 @@ public class RestTemplateConfig {
final RestTemplate restTemplate = new RestTemplate();
restTemplate
.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
- restTemplate.getInterceptors().add(new SpringClientFilter());
+ restTemplate.getInterceptors().add(new SOSpringClientFilter());
return restTemplate;
}
@@ -56,7 +56,7 @@ public class RestTemplateConfig {
httpComponentsClientConfiguration.httpComponentsClientHttpRequestFactory();
final RestTemplate restTemplate =
new RestTemplate(new BufferingClientHttpRequestFactory(clientHttpRequestFactory));
- restTemplate.getInterceptors().add(new SpringClientFilter());
+ restTemplate.getInterceptors().add(new SOSpringClientFilter());
return restTemplate;
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
index b546aaa23e..610ff728e9 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIRestClient.java
@@ -26,7 +26,7 @@ import java.util.Optional;
import org.onap.so.client.ResponseExceptionMapper;
import org.onap.so.client.graphinventory.GraphInventoryPatchConverter;
import org.onap.so.client.graphinventory.GraphInventoryRestClient;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
public class AAIRestClient extends GraphInventoryRestClient {
@@ -38,8 +38,8 @@ public class AAIRestClient extends GraphInventoryRestClient {
}
@Override
- public TargetEntity getTargetEntity() {
- return TargetEntity.AAI;
+ public ONAPComponents getTargetEntity() {
+ return ONAPComponents.AAI;
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
index d6c7072c14..88899a7097 100644
--- a/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
+++ b/common/src/main/java/org/onap/so/client/adapter/rest/AdapterRestClient.java
@@ -29,7 +29,7 @@ import org.onap.so.client.RestClient;
import org.onap.so.client.policy.CommonObjectMapperProvider;
import org.onap.so.client.policy.JettisonStyleMapperProvider;
import org.onap.so.utils.CryptoUtils;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
public class AdapterRestClient extends RestClient {
@@ -46,8 +46,8 @@ public class AdapterRestClient extends RestClient {
}
@Override
- public TargetEntity getTargetEntity() {
- return TargetEntity.OPENSTACK_ADAPTER;
+ public ONAPComponents getTargetEntity() {
+ return ONAPComponents.OPENSTACK_ADAPTER;
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
index 68b4e84448..b0ffb9358c 100644
--- a/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
+++ b/common/src/main/java/org/onap/so/client/dmaap/rest/DMaaPRestClient.java
@@ -22,11 +22,15 @@ package org.onap.so.client.dmaap.rest;
import java.net.URL;
import java.util.Map;
+import java.util.UUID;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.client.RestClient;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.slf4j.MDC;
public class DMaaPRestClient extends RestClient {
+ private static final String SO = "SO";
private final String auth;
private final String key;
@@ -37,8 +41,8 @@ public class DMaaPRestClient extends RestClient {
}
@Override
- public TargetEntity getTargetEntity() {
- return TargetEntity.DMAAP;
+ public ONAPComponents getTargetEntity() {
+ return ONAPComponents.DMAAP;
}
@Override
@@ -46,6 +50,8 @@ public class DMaaPRestClient extends RestClient {
if (auth != null && !auth.isEmpty() && key != null && !key.isEmpty()) {
addBasicAuthHeader(auth, key);
}
+ String onapRequestId = UUID.randomUUID().toString();
+ headerMap.put(ONAPLogConstants.Headers.REQUEST_ID, onapRequestId);
+ headerMap.put(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
}
-
}
diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java
index 434c65da46..babfa14d71 100644
--- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java
+++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryRestClient.java
@@ -28,7 +28,8 @@ import org.onap.so.client.ResponseExceptionMapper;
import org.onap.so.client.RestClientSSL;
import org.onap.so.client.RestProperties;
import org.onap.so.client.policy.CommonObjectMapperProvider;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.filter.base.ONAPComponentsList;
public abstract class GraphInventoryRestClient extends RestClientSSL {
@@ -42,7 +43,7 @@ public abstract class GraphInventoryRestClient extends RestClientSSL {
}
@Override
- public abstract TargetEntity getTargetEntity();
+ public abstract ONAPComponentsList getTargetEntity();
@Override
protected abstract void initializeHeaderMap(Map<String, String> headerMap);
diff --git a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
index 507f1130b5..147f688ea8 100644
--- a/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
+++ b/common/src/main/java/org/onap/so/client/grm/GRMRestClient.java
@@ -25,7 +25,7 @@ import java.net.URI;
import java.util.Map;
import java.util.Optional;
import org.onap.so.client.RestClient;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
public class GRMRestClient extends RestClient {
@@ -37,8 +37,8 @@ public class GRMRestClient extends RestClient {
}
@Override
- public TargetEntity getTargetEntity() {
- return TargetEntity.GRM;
+ public ONAPComponents getTargetEntity() {
+ return ONAPComponents.GRM;
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
index 95bc4282ae..33ece07e3d 100644
--- a/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
+++ b/common/src/main/java/org/onap/so/client/policy/PolicyRestClient.java
@@ -26,7 +26,7 @@ import java.util.Optional;
import javax.ws.rs.core.UriBuilder;
import org.onap.so.client.RestClient;
import org.onap.so.client.policy.entities.PolicyServiceType;
-import org.onap.so.utils.TargetEntity;
+import org.onap.logging.filter.base.ONAPComponents;
public class PolicyRestClient extends RestClient {
@@ -38,8 +38,8 @@ public class PolicyRestClient extends RestClient {
}
@Override
- public TargetEntity getTargetEntity() {
- return TargetEntity.POLICY;
+ public ONAPComponents getTargetEntity() {
+ return ONAPComponents.POLICY;
}
@Override
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
new file mode 100644
index 0000000000..8d30ad35ff
--- /dev/null
+++ b/common/src/main/java/org/onap/so/externaltasks/logging/AuditMDCSetup.java
@@ -0,0 +1,56 @@
+package org.onap.so.externaltasks.logging;
+
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import org.camunda.bpm.client.task.ExternalTask;
+import org.onap.logging.filter.base.MDCSetup;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.logger.MdcConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AuditMDCSetup {
+
+ private MDCSetup mdcSetup = new MDCSetup();
+
+ private static final Logger logger = LoggerFactory.getLogger(AuditMDCSetup.class);
+
+ public void setupMDC(ExternalTask externalTask) {
+ MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
+ ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
+ String msoRequestId = externalTask.getVariable("mso-request-id");
+ if (msoRequestId != null && !msoRequestId.isEmpty()) {
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
+ }
+ MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
+ MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, ONAPComponents.OPENSTACK_ADAPTER.toString());
+ setResponseCode(ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
+ setElapsedTime();
+ mdcSetup.setServerFQDN();
+ logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
+ }
+
+ public void setElapsedTime() {
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME;
+ MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, Long.toString(System.currentTimeMillis() - ZonedDateTime
+ .parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter).toInstant().toEpochMilli()));
+ }
+
+ public void setResponseCode(String code) {
+ MDC.put(MdcConstants.OPENSTACK_STATUS_CODE, code);
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, code);
+ }
+
+ public void clearClientMDCs() {
+ MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
+ MDC.remove(MdcConstants.OPENSTACK_STATUS_CODE);
+ MDC.remove(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP);
+ MDC.remove(ONAPLogConstants.MDCs.ELAPSED_TIME);
+ MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME);
+ }
+}
diff --git a/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java b/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java
index 83b860ff01..2010bc1988 100644
--- a/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java
+++ b/common/src/main/java/org/onap/so/logger/HttpHeadersConstants.java
@@ -21,13 +21,5 @@
package org.onap.so.logger;
public class HttpHeadersConstants {
- public static final String HEADER_FROM_APP_ID = "X-FromAppId";
- public static final String ONAP_PARTNER_NAME = "X-ONAP-PartnerName";
- public static final String HEADER_REQUEST_ID = "X-RequestId";
- public static final String TRANSACTION_ID = "X-TransactionID";
- public static final String ECOMP_REQUEST_ID = "X-ECOMP-RequestID";
- public static final String ONAP_REQUEST_ID = "X-ONAP-RequestID";
- public static final String CLIENT_ID = "X-ClientID";
- public static final String INVOCATION_ID_HEADER = "X-InvocationID";
public static final String REQUESTOR_ID = "X-RequestorID";
}
diff --git a/common/src/main/java/org/onap/so/logger/LogConstants.java b/common/src/main/java/org/onap/so/logger/LogConstants.java
index 30915c6171..3dc0c062c6 100644
--- a/common/src/main/java/org/onap/so/logger/LogConstants.java
+++ b/common/src/main/java/org/onap/so/logger/LogConstants.java
@@ -21,8 +21,6 @@
package org.onap.so.logger;
public class LogConstants {
- public static final String TARGET_ENTITY_HEADER = "X-Target-Entity";
- public static final String UNKNOWN_TARGET_ENTITY = "Unknown-Target-Entity";
public static final String HTTP_URL = "Http-Url";
public static final String URI_BASE = "Uri-Base";
}
diff --git a/common/src/main/java/org/onap/so/logger/MdcConstants.java b/common/src/main/java/org/onap/so/logger/MdcConstants.java
index 33fceb2f0f..4c6672e59f 100644
--- a/common/src/main/java/org/onap/so/logger/MdcConstants.java
+++ b/common/src/main/java/org/onap/so/logger/MdcConstants.java
@@ -21,14 +21,6 @@
package org.onap.so.logger;
public class MdcConstants {
- public static final String INVOCATION_ID = "InvocationID";
- public static final String RESPONSECODE = "ResponseCode";
- public static final String RESPONSEDESC = "ResponseDesc";
- public static final String ECOMP_REQUEST_ID = "X-ECOMP-RequestID";
- public static final String CLIENT_ID = "X-ClientID";
- public static final String PARTNERNAME = "PartnerName";
- public static final String SERVICE_NAME = "ServiceName";
- public static final String STATUSCODE = "StatusCode";
- public static final String ENDTIME = "EndTimestamp";
public static final String ORIGINAL_PARTNER_NAME = "OriginalPartnerName";
+ public static final String OPENSTACK_STATUS_CODE = "OpenstackStatusCode";
}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java
deleted file mode 100644
index 5dbf88d346..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.utils.TargetEntity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.stereotype.Component;
-import javax.annotation.Priority;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseContext;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.Providers;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.UUID;
-
-@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
-@Component
-@Priority(0)
-public class JaxRsClientLogging implements ClientRequestFilter, ClientResponseFilter {
-
- @Context
- private Providers providers;
-
- private static final String TRACE = "trace-#";
- private static final String SO = "SO";
- private static Logger logger = LoggerFactory.getLogger(JaxRsClientLogging.class);
-
- public void setTargetService(TargetEntity targetEntity) {
- MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString());
- }
-
- @Override
- public void filter(ClientRequestContext clientRequest) {
- try {
- setupMDC(clientRequest);
- setupHeaders(clientRequest);
- logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke");
- } catch (Exception e) {
- logger.warn("Error in incoming JAX-RS Inteceptor", e);
- }
- }
-
- private void setupHeaders(ClientRequestContext clientRequest) {
- MultivaluedMap<String, Object> headers = clientRequest.getHeaders();
- headers.add(ONAPLogConstants.Headers.REQUEST_ID, extractRequestID(clientRequest));
- headers.add(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- headers.add(ONAPLogConstants.Headers.PARTNER_NAME, SO);
- }
-
- private void setupMDC(ClientRequestContext clientRequest) {
- MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
- MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getUri().toString());
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
- setInvocationId();
- MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY));
- }
-
- private String extractRequestID(ClientRequestContext clientRequest) {
- String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
- if (requestId == null || requestId.isEmpty() || requestId.equals(TRACE)) {
- requestId = UUID.randomUUID().toString();
- logger.warn("Could not Find Request ID Generating New One: {}", clientRequest.getUri().getPath());
- }
- return requestId;
- }
-
- private void setInvocationId() {
- String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID);
- if (invocationId == null || invocationId.isEmpty())
- invocationId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
- }
-
-
- @Override
- public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
-
- try {
- String statusCode;
- if (Response.Status.Family.familyOf(responseContext.getStatus())
- .equals(Response.Status.Family.SUCCESSFUL)) {
- statusCode = ONAPLogConstants.ResponseStatus.COMPLETED.toString();
- } else {
- statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
- }
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus()));
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
- logger.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn");
- clearClientMDCs();
- } catch (Exception e) {
- logger.warn("Error in outgoing JAX-RS Inteceptor", e);
- }
- }
-
- private void clearClientMDCs() {
- MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY);
- MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
- MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP);
- }
-
-}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java
deleted file mode 100644
index 7e2b603ba6..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.UUID;
-import javax.annotation.Priority;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.ContainerResponseContext;
-import javax.ws.rs.container.ContainerResponseFilter;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.Providers;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.logger.HttpHeadersConstants;
-import org.onap.so.logger.LogConstants;
-import org.onap.so.logger.MdcConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-@Priority(1)
-@Provider
-@Component
-public class JaxRsFilterLogging implements ContainerRequestFilter, ContainerResponseFilter {
-
- protected static Logger logger = LoggerFactory.getLogger(JaxRsFilterLogging.class);
-
- @Context
- private HttpServletRequest httpServletRequest;
-
- @Context
- private Providers providers;
-
- @Autowired
- private MDCSetup mdcSetup;
-
- @Override
- public void filter(ContainerRequestContext containerRequest) {
- try {
- MultivaluedMap<String, String> headers = containerRequest.getHeaders();
- setRequestId(headers);
- containerRequest.setProperty("requestId", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
- setInvocationId(headers);
- setServiceName(containerRequest);
- setMDCPartnerName(headers);
- mdcSetup.setServerFQDN();
- mdcSetup.setClientIPAddress(httpServletRequest);
- mdcSetup.setInstanceUUID();
- mdcSetup.setEntryTimeStamp();
- MDC.put(HttpHeadersConstants.REQUESTOR_ID, headers.getFirst("X-RequestorID"));
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
- MDC.put(LogConstants.URI_BASE, containerRequest.getUriInfo().getBaseUri().toString());
- MDC.put(MdcConstants.ORIGINAL_PARTNER_NAME, MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
- logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
- } catch (Exception e) {
- logger.warn("Error in incoming JAX-RS Inteceptor", e);
- }
- }
-
- @Override
- public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
- throws IOException {
- try {
- setResponseStatusCode(responseContext);
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, payloadMessage(responseContext));
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus()));
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
- MDC.clear();
- } catch (Exception e) {
- MDC.clear();
- logger.warn("Error in outgoing JAX-RS Inteceptor", e);
- }
- }
-
- private void setResponseStatusCode(ContainerResponseContext responseContext) {
- String statusCode;
- if (Response.Status.Family.familyOf(responseContext.getStatus()).equals(Response.Status.Family.SUCCESSFUL)) {
- statusCode = ONAPLogConstants.ResponseStatus.COMPLETED.toString();
- } else {
- statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
- }
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
- }
-
- private String payloadMessage(ContainerResponseContext responseContext) throws IOException {
- String message = "";
- if (responseContext.hasEntity()) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Class<?> entityClass = responseContext.getEntityClass();
- Type entityType = responseContext.getEntityType();
- Annotation[] entityAnnotations = responseContext.getEntityAnnotations();
- MediaType mediaType = responseContext.getMediaType();
- @SuppressWarnings("unchecked")
- MessageBodyWriter<Object> bodyWriter = (MessageBodyWriter<Object>) providers
- .getMessageBodyWriter(entityClass, entityType, entityAnnotations, mediaType);
- bodyWriter.writeTo(responseContext.getEntity(), entityClass, entityType, entityAnnotations, mediaType,
- responseContext.getHeaders(), baos);
- message = message.concat(new String(baos.toByteArray()));
- }
- return message;
- }
-
- private void setRequestId(MultivaluedMap<String, String> headers) {
- String requestId = headers.getFirst(ONAPLogConstants.Headers.REQUEST_ID);
- if (requestId == null || requestId.isEmpty())
- requestId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
- }
-
- private void setInvocationId(MultivaluedMap<String, String> headers) {
- MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, findInvocationId(headers));
- }
-
- private void setMDCPartnerName(MultivaluedMap<String, String> headers) {
- String partnerName = headers.getFirst(ONAPLogConstants.Headers.PARTNER_NAME);
- if (partnerName == null || partnerName.isEmpty())
- partnerName = "";
- MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
- }
-
- private String findInvocationId(MultivaluedMap<String, String> headers) {
- String invocationId = headers.getFirst(ONAPLogConstants.Headers.INVOCATION_ID);
- if (invocationId == null || invocationId.isEmpty())
- invocationId = UUID.randomUUID().toString();
- return invocationId;
- }
-
- private void setServiceName(ContainerRequestContext containerRequest) {
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, containerRequest.getUriInfo().getPath());
- }
-
- private void clearClientMDCs() {
- MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY);
- MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
- }
-
-}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java
deleted file mode 100644
index 607f067ec4..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCSetup.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Map;
-import java.util.UUID;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.Response;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.stereotype.Component;
-
-@Component
-public class MDCSetup {
-
- protected static Logger logger = LoggerFactory.getLogger(MDCSetup.class);
-
- private static final String INSTANCE_UUID = UUID.randomUUID().toString();
-
- public void setInstanceUUID() {
- MDC.put(ONAPLogConstants.MDCs.INSTANCE_UUID, INSTANCE_UUID);
- }
-
- public void setServerFQDN() {
- String serverFQDN = "";
- InetAddress addr = null;
- try {
- addr = InetAddress.getLocalHost();
- serverFQDN = addr.toString();
- } catch (UnknownHostException e) {
- logger.warn("Cannot Resolve Host Name");
- serverFQDN = "";
- }
- MDC.put(ONAPLogConstants.MDCs.SERVER_FQDN, serverFQDN);
- }
-
- public void setClientIPAddress(HttpServletRequest httpServletRequest) {
- String remoteIpAddress = "";
- if (httpServletRequest != null) {
- remoteIpAddress = httpServletRequest.getRemoteAddr();
- }
- MDC.put(ONAPLogConstants.MDCs.CLIENT_IP_ADDRESS, remoteIpAddress);
- }
-
- public void setEntryTimeStamp() {
- MDC.put(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
- }
-
- public void setServiceName(HttpServletRequest request) {
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
- }
-
- public void setRequestId(Map<String, String> headers) {
- String requestId = headers.get(ONAPLogConstants.Headers.REQUEST_ID);
- if (requestId == null || requestId.isEmpty())
- requestId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
- }
-
- public void setInvocationId(Map<String, String> headers) {
- String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID);
- if (invocationId == null || invocationId.isEmpty())
- invocationId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
- }
-
- public void setMDCPartnerName(Map<String, String> headers) {
- String partnerName = headers.get(ONAPLogConstants.Headers.PARTNER_NAME);
- if (partnerName == null || partnerName.isEmpty())
- partnerName = "";
- MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
- }
-
-
- public void setResponseStatusCode(HttpServletResponse response) {
- String statusCode;
- if (Response.Status.Family.familyOf(response.getStatus()).equals(Response.Status.Family.SUCCESSFUL)) {
- statusCode = ONAPLogConstants.ResponseStatus.COMPLETED.toString();
- } else {
- statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
- }
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
- }
-}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java
deleted file mode 100644
index e644f9e030..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-import java.util.Map;
-import org.slf4j.MDC;
-import org.springframework.core.task.TaskDecorator;
-
-public class MDCTaskDecorator implements TaskDecorator {
-
- @Override
- public Runnable decorate(Runnable runnable) {
- Map<String, String> contextMap = MDC.getCopyOfContextMap();
- return () -> {
- try {
- if (contextMap != null) {
- MDC.setContextMap(contextMap);
- runnable.run();
- }
- } finally {
- MDC.clear();
- }
- };
- }
-}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/PayloadLoggingFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/PayloadLoggingFilter.java
deleted file mode 100644
index 21c0b52a91..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/PayloadLoggingFilter.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import javax.annotation.Priority;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.client.ClientResponseContext;
-import javax.ws.rs.client.ClientResponseFilter;
-import javax.ws.rs.ext.Provider;
-import javax.ws.rs.ext.WriterInterceptor;
-import javax.ws.rs.ext.WriterInterceptorContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@Provider
-@Priority(1)
-public class PayloadLoggingFilter implements ClientRequestFilter, ClientResponseFilter, WriterInterceptor {
-
- private static final Logger logger = LoggerFactory.getLogger(PayloadLoggingFilter.class);
- private static final String ENTITY_STREAM_PROPERTY = "LoggingFilter.entityStream";
- private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
- private final int maxEntitySize;
-
- public PayloadLoggingFilter() {
- maxEntitySize = 1024 * 1024;
- }
-
- public PayloadLoggingFilter(int maxPayloadSize) {
- this.maxEntitySize = Integer.min(maxPayloadSize, 1024 * 1024);
- }
-
- private void log(StringBuilder sb) {
- logger.debug(sb.toString());
- }
-
- protected InputStream logInboundEntity(final StringBuilder b, InputStream stream, final Charset charset)
- throws IOException {
- if (!stream.markSupported()) {
- stream = new BufferedInputStream(stream);
- }
- stream.mark(maxEntitySize + 1);
- final byte[] entity = new byte[maxEntitySize + 1];
- final int entitySize = stream.read(entity);
- if (entitySize != -1) {
- b.append(new String(entity, 0, Math.min(entitySize, maxEntitySize), charset));
- }
- if (entitySize > maxEntitySize) {
- b.append("...more...");
- }
- b.append('\n');
- stream.reset();
- return stream;
- }
-
- @Override
- public void filter(ClientRequestContext requestContext) throws IOException {
- if (requestContext.hasEntity()) {
- final OutputStream stream = new LoggingStream(requestContext.getEntityStream());
- requestContext.setEntityStream(stream);
- requestContext.setProperty(ENTITY_STREAM_PROPERTY, stream);
- }
- String method = formatMethod(requestContext);
- log(new StringBuilder("Making " + method + " request to: " + requestContext.getUri() + "\nRequest Headers: "
- + requestContext.getHeaders().toString()));
-
- }
-
- @Override
- public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
- final StringBuilder sb = new StringBuilder();
- if (responseContext.hasEntity()) {
- responseContext.setEntityStream(logInboundEntity(sb, responseContext.getEntityStream(), DEFAULT_CHARSET));
- String method = formatMethod(requestContext);
- log(sb.insert(0, "Response from " + method + ": " + requestContext.getUri() + "\nResponse Headers: "
- + responseContext.getHeaders().toString()));
- }
- }
-
- @Override
- public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
- final LoggingStream stream = (LoggingStream) context.getProperty(ENTITY_STREAM_PROPERTY);
- context.proceed();
- if (stream != null) {
- log(stream.getStringBuilder(DEFAULT_CHARSET));
- }
- }
-
- private class LoggingStream extends FilterOutputStream {
-
- private final StringBuilder sb = new StringBuilder();
- private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- LoggingStream(OutputStream out) {
- super(out);
- }
-
- StringBuilder getStringBuilder(Charset charset) {
- // write entity to the builder
- final byte[] entity = baos.toByteArray();
-
- sb.append(new String(entity, 0, entity.length, charset));
- if (entity.length > maxEntitySize) {
- sb.append("...more...");
- }
- sb.append('\n');
-
- return sb;
- }
-
- @Override
- public void write(final int i) throws IOException {
- if (baos.size() <= maxEntitySize) {
- baos.write(i);
- }
- out.write(i);
- }
- }
-
- private String formatMethod(ClientRequestContext requestContext) {
- String method = requestContext.getHeaderString("X-HTTP-Method-Override");
- if (method == null) {
- method = requestContext.getMethod();
- } else {
- method = requestContext.getMethod() + " (overridden to " + method + ")";
- }
-
- return method;
- }
-}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java
new file mode 100644
index 0000000000..5ae1082464
--- /dev/null
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOAuditLogContainerFilter.java
@@ -0,0 +1,34 @@
+package org.onap.so.logging.jaxrs.filter;
+
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.logger.HttpHeadersConstants;
+import org.onap.so.logger.LogConstants;
+import org.slf4j.MDC;
+import org.springframework.stereotype.Component;
+import org.onap.logging.filter.base.AuditLogContainerFilter;
+
+@Priority(1)
+@Component
+public class SOAuditLogContainerFilter extends AuditLogContainerFilter {
+
+ private static final String ORIGINAL_PARTNER_NAME = "OriginalPartnerName";
+
+ @Override
+ protected void additionalPreHandling(ContainerRequestContext request) {
+ request.setProperty("requestId", MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ MDC.put(ORIGINAL_PARTNER_NAME, MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ String requestorId = request.getHeaders().getFirst("X-RequestorID");
+ if (requestorId != null) {
+ MDC.put(HttpHeadersConstants.REQUESTOR_ID, requestorId);
+ }
+ MDC.put(LogConstants.URI_BASE, request.getUriInfo().getBaseUri().toString());
+ }
+
+ @Override
+ protected void additionalPostHandling(ContainerResponseContext response) {
+ // override to add additional post handling
+ }
+}
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
new file mode 100644
index 0000000000..248e2f00bf
--- /dev/null
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOMetricLogClientFilter.java
@@ -0,0 +1,44 @@
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+
+
+public class SOMetricLogClientFilter extends MetricLogClientFilter {
+
+ protected static Logger logger = LoggerFactory.getLogger(MDCSetup.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());
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus()));
+ logger.info(INVOKE_RETURN, "InvokeReturn");
+ mdcSetup.clearClientMDCs();
+ setOpenStackResponseCode();
+ } catch (Exception e) {
+ logger.warn("Error in JAX-RS request,response client filter", e);
+ }
+ }
+
+ protected void setOpenStackResponseCode() {
+ if (MDC.get(MdcConstants.OPENSTACK_STATUS_CODE) != null) {
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, MDC.get(MdcConstants.OPENSTACK_STATUS_CODE));
+ }
+ }
+}
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
new file mode 100644
index 0000000000..c2b8df37c2
--- /dev/null
+++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SOSpringClientFilter.java
@@ -0,0 +1,52 @@
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.springframework.http.client.ClientHttpRequestInterceptor;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StreamUtils;
+
+@Component
+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=================================================");
+ }
+ 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();
+ setOpenStackResponseCode();
+ }
+
+ protected void setOpenStackResponseCode() {
+ if (MDC.get(MdcConstants.OPENSTACK_STATUS_CODE) != null) {
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, MDC.get(MdcConstants.OPENSTACK_STATUS_CODE));
+ }
+ }
+}
diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java
deleted file mode 100644
index c763dd4374..0000000000
--- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.jaxrs.filter;
-
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.logger.LogConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpRequest;
-import org.springframework.http.client.ClientHttpRequestExecution;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
-import org.springframework.util.StreamUtils;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.List;
-import java.util.UUID;
-import javax.ws.rs.core.Response;
-
-public class SpringClientFilter implements ClientHttpRequestInterceptor {
-
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- private static final String TRACE = "trace-#";
- private static final String SO = "SO";
-
- @Override
- public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
- throws IOException {
- processRequest(request, body);
- ClientHttpResponse response = execution.execute(request, body);
- processResponse(response);
- return response;
- }
-
- private void processRequest(HttpRequest request, byte[] body) throws IOException {
- setInvocationId();
- setupHeaders(request);
- setupMDC(request);
- if (log.isDebugEnabled()) {
- log.debug("===========================request begin================================================");
- log.debug("URI : {}", request.getURI());
- log.debug("Method : {}", request.getMethod());
- log.debug("Headers : {}", request.getHeaders());
- log.debug("Request body: {}", new String(body, "UTF-8"));
- log.debug("==========================request end================================================");
- }
- }
-
- private void setupHeaders(HttpRequest clientRequest) {
- HttpHeaders headers = clientRequest.getHeaders();
- headers.add(ONAPLogConstants.Headers.REQUEST_ID, extractRequestID(clientRequest));
- headers.add(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID));
- headers.add(ONAPLogConstants.Headers.PARTNER_NAME, SO);
- }
-
- private String extractRequestID(HttpRequest clientRequest) {
- String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
- if (requestId == null || requestId.isEmpty() || requestId.equals(TRACE)) {
- requestId = UUID.randomUUID().toString();
- log.warn("Could not Find Request ID Generating New One: {}", clientRequest.getURI());
- }
- return requestId;
- }
-
- private void setupMDC(HttpRequest clientRequest) {
- MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP,
- ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT));
- MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getURI().toString());
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
- MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, extractTargetEntity(clientRequest));
- }
-
- private String extractTargetEntity(HttpRequest clientRequest) {
- HttpHeaders headers = clientRequest.getHeaders();
- String headerTargetEntity = null;
- List<String> headerTargetEntityList = headers.get(LogConstants.TARGET_ENTITY_HEADER);
- if (headerTargetEntityList != null && !headerTargetEntityList.isEmpty())
- headerTargetEntity = headerTargetEntityList.get(0);
- String targetEntity = MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY);
- if (targetEntity != null && !targetEntity.isEmpty()) {
- return targetEntity;
- } else if (headerTargetEntity != null && !headerTargetEntity.isEmpty()) {
- targetEntity = headerTargetEntity;
- } else {
- targetEntity = LogConstants.UNKNOWN_TARGET_ENTITY;
- log.warn("Could not Target Entity: {}", clientRequest.getURI());
- }
- return targetEntity;
- }
-
- private void setInvocationId() {
- String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID);
- if (invocationId == null || invocationId.isEmpty())
- invocationId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
- }
-
-
- private void processResponse(ClientHttpResponse response) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("============================response begin==========================================");
- log.debug("Status code : {}", response.getStatusCode());
- log.debug("Status text : {}", response.getStatusText());
- log.debug("Headers : {}", response.getHeaders());
- log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
- log.debug("=======================response end=================================================");
- }
- String statusCode;
- if (Response.Status.Family.familyOf(response.getRawStatusCode()).equals(Response.Status.Family.SUCCESSFUL)) {
- statusCode = ONAPLogConstants.ResponseStatus.COMPLETED.toString();
- } else {
- statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
- }
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(response.getRawStatusCode()));
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, "");
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
- log.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn");
- clearClientMDCs();
- }
-
- private void clearClientMDCs() {
- MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION);
- MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY);
- MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME);
- MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME);
- MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP);
- }
-}
diff --git a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java
deleted file mode 100644
index fa5a5d5da4..0000000000
--- a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.logging.spring.interceptor;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.UUID;
-import java.util.stream.Collectors;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.Providers;
-import org.onap.logging.ref.slf4j.ONAPLogConstants;
-import org.onap.so.logging.jaxrs.filter.MDCSetup;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-import org.springframework.web.servlet.ModelAndView;
-import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
-@Component
-public class LoggingInterceptor extends HandlerInterceptorAdapter {
-
- Logger logger = LoggerFactory.getLogger(LoggingInterceptor.class);
-
- @Autowired
- private MDCSetup mdcSetup;
-
- @Context
- private Providers providers;
-
- @Override
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
- throws Exception {
-
- Map<String, String> headers = Collections.list((request).getHeaderNames()).stream()
- .collect(Collectors.toMap(h -> h, request::getHeader));
- setRequestId(headers);
- setInvocationId(headers);
- setServiceName(request);
- setMDCPartnerName(headers);
- mdcSetup.setClientIPAddress(request);
- mdcSetup.setEntryTimeStamp();
- mdcSetup.setInstanceUUID();
- mdcSetup.setServerFQDN();
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString());
- logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
- if (logger.isDebugEnabled())
- logRequestInformation(request);
- return true;
- }
-
- protected void logRequestInformation(HttpServletRequest request) {
- Map<String, String> headers = Collections.list((request).getHeaderNames()).stream()
- .collect(Collectors.toMap(h -> h, request::getHeader));
-
- logger.debug("===========================request begin================================================");
- logger.debug("URI : {}", request.getRequestURI());
- logger.debug("Method : {}", request.getMethod());
- logger.debug("Headers : {}", headers);
- logger.debug("==========================request end================================================");
-
- }
-
- @Override
- public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
- ModelAndView modelAndView) throws Exception {
- setResponseStatusCode(response);
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION, "");
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(response.getStatus()));
- logger.info(ONAPLogConstants.Markers.EXIT, "Exiting.");
- MDC.clear();
- }
-
- protected void setResponseStatusCode(HttpServletResponse response) {
- String statusCode;
- if (Response.Status.Family.familyOf(response.getStatus()).equals(Response.Status.Family.SUCCESSFUL)) {
- statusCode = ONAPLogConstants.ResponseStatus.COMPLETED.toString();
- } else {
- statusCode = ONAPLogConstants.ResponseStatus.ERROR.toString();
- }
- MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode);
- }
-
- protected void setServiceName(HttpServletRequest request) {
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI());
- }
-
- protected void setRequestId(Map<String, String> headers) {
- String requestId = headers.get(ONAPLogConstants.Headers.REQUEST_ID.toLowerCase());
- if (requestId == null || requestId.isEmpty())
- requestId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
- }
-
- protected void setInvocationId(Map<String, String> headers) {
- String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID.toLowerCase());
- if (invocationId == null || invocationId.isEmpty())
- invocationId = UUID.randomUUID().toString();
- MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId);
- }
-
- protected void setMDCPartnerName(Map<String, String> headers) {
- String partnerName = headers.get(ONAPLogConstants.Headers.PARTNER_NAME.toLowerCase());
- if (partnerName == null || partnerName.isEmpty())
- partnerName = "";
- MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME, partnerName);
- }
-
-
-}
diff --git a/common/src/main/java/org/onap/so/utils/Components.java b/common/src/main/java/org/onap/so/utils/Components.java
new file mode 100644
index 0000000000..0713723264
--- /dev/null
+++ b/common/src/main/java/org/onap/so/utils/Components.java
@@ -0,0 +1,7 @@
+package org.onap.so.utils;
+
+import org.onap.logging.filter.base.ONAPComponentsList;
+
+public enum Components implements ONAPComponentsList {
+ OPENSTACK, UNKNOWN;
+}
diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
index 349767fc5b..a2aed638fe 100644
--- a/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
+++ b/common/src/main/java/org/onap/so/utils/ExternalTaskUtils.java
@@ -33,14 +33,4 @@ public abstract class ExternalTaskUtils {
}
return seq;
}
-
- protected void setupMDC(ExternalTask externalTask) {
- logger.info(ONAPLogConstants.Markers.ENTRY, "Entering");
- String msoRequestId = externalTask.getVariable("mso-request-id");
- if (msoRequestId != null && !msoRequestId.isEmpty()) {
- MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, msoRequestId);
- }
- MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, externalTask.getTopicName());
- }
-
}
diff --git a/common/src/main/java/org/onap/so/utils/TargetEntities.java b/common/src/main/java/org/onap/so/utils/TargetEntities.java
deleted file mode 100644
index 67016a1fa9..0000000000
--- a/common/src/main/java/org/onap/so/utils/TargetEntities.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.utils;
-
-import java.io.Serializable;
-
-public interface TargetEntities extends Serializable {
-
-}
diff --git a/common/src/main/java/org/onap/so/utils/TargetEntity.java b/common/src/main/java/org/onap/so/utils/TargetEntity.java
deleted file mode 100644
index 3a3ec91d2f..0000000000
--- a/common/src/main/java/org/onap/so/utils/TargetEntity.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.utils;
-
-import java.util.EnumSet;
-
-public enum TargetEntity implements TargetEntities {
- OPENSTACK_ADAPTER,
- BPMN,
- GRM,
- AAI,
- DMAAP,
- POLICY,
- CATALOG_DB,
- REQUEST_DB,
- VNF_ADAPTER,
- SDNC_ADAPTER,
- SNIRO,
- SDC,
- EXTERNAL,
- MULTICLOUD,
- OOF,
- SDNC,
- SO,
- UNKNOWN,
- OPENSTACK;
-
- private static final String PREFIX = "SO";
-
- public static EnumSet<TargetEntity> getSOInternalComponents() {
- return EnumSet.of(OPENSTACK_ADAPTER, BPMN, CATALOG_DB, REQUEST_DB, VNF_ADAPTER, SDNC_ADAPTER);
- }
-
- @Override
- public String toString() {
- if (getSOInternalComponents().contains(this))
- return TargetEntity.PREFIX + "." + this.name();
- else
- return this.name();
- }
-}