diff options
author | Steve Smokowski <ss835w@att.com> | 2020-10-22 15:14:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-10-22 15:14:52 +0000 |
commit | 66ee1cc378b5a93a4ca225fe5bf31729cf762ffd (patch) | |
tree | 4bb903ff93240020f6363f41372bc6f6f0f85140 | |
parent | e343c3d7c55e841f85de58ed0dc8f4650d356715 (diff) | |
parent | 7a2c68f4a2a0d297749bda79d2697de468c9cf6d (diff) |
Merge "so does not capture the vnf name"
4 files changed, 22 insertions, 6 deletions
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 index 9552755544..85925e2725 100644 --- 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 @@ -2,13 +2,16 @@ package org.onap.so.logging.jaxrs.filter; import javax.annotation.Priority; import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerResponseContext; import javax.ws.rs.container.PreMatching; +import javax.ws.rs.core.MultivaluedMap; +import org.onap.logging.filter.base.AuditLogContainerFilter; +import org.onap.logging.filter.base.Constants; 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) @PreMatching @@ -27,4 +30,17 @@ public class SOAuditLogContainerFilter extends AuditLogContainerFilter { } MDC.put(LogConstants.URI_BASE, request.getUriInfo().getBaseUri().toString()); } + + @Override + protected void additionalPostHandling(ContainerResponseContext response) { + MultivaluedMap<String, Object> responseHeaders = response.getHeaders(); + String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); + responseHeaders.add(ONAPLogConstants.Headers.REQUEST_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.HEADER_REQUEST_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, requestId); + responseHeaders.add(Constants.HttpHeaders.ECOMP_REQUEST_ID, requestId); + responseHeaders.add(ONAPLogConstants.Headers.PARTNER_NAME, getProperty(Constants.Property.PARTNER_NAME)); + responseHeaders.add(ONAPLogConstants.Headers.INVOCATION_ID, + MDC.get(ONAPLogConstants.MDCs.SERVER_INVOCATION_ID)); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java index b921f5beea..64774430cc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/common/ResponseBuilder.java @@ -50,10 +50,6 @@ public class ResponseBuilder { .header(CommonConstants.X_PATCH_VERSION, apiPatchVersion) .header(CommonConstants.X_LATEST_VERSION, latestVersion); - if (StringUtils.isNotBlank(requestId)) { - builder.header(CommonConstants.X_TRANSACTION_ID, requestId); - } - return builder.entity(jsonResponse).build(); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 33d86a2cc6..d43bbb6ea0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -1498,6 +1498,8 @@ public class ServiceInstancesTest extends BaseTest { sendRequest(inputStream("/VfModuleNoModelType.json"), uri, HttpMethod.POST, headers); // ActualRecord assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); + assertEquals("32807a28-1a14-4b88-b7b3-2950918aa76d", + response.getHeaders().get(ONAPLogConstants.Headers.REQUEST_ID).get(0)); } @Test diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java index 1917ee592f..db9f45e3ac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestrationTest.java @@ -31,6 +31,7 @@ import javax.ws.rs.core.MediaType; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.http.HttpEntity; @@ -212,6 +213,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest { .withStatus(HttpStatus.SC_OK))); headers.set("Accept", MediaType.APPLICATION_JSON); headers.set("Content-Type", MediaType.APPLICATION_JSON); + headers.set(ONAPLogConstants.Headers.REQUEST_ID, "e0e0e749-c9e2-48c3-8c4c-d51bf65a86c9"); HttpEntity<String> entity = new HttpEntity<>("", headers); UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(path) + "/v1"); @@ -226,7 +228,7 @@ public class CloudResourcesOrchestrationTest extends BaseTest { assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0)); assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0)); assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0)); - assertEquals("90c56827-1c78-4827-bc4d-6afcdb37a51f", response.getHeaders().get("X-TransactionID").get(0)); + assertEquals("e0e0e749-c9e2-48c3-8c4c-d51bf65a86c9", response.getHeaders().get("X-TransactionID").get(0)); } @Test |