From 7a2c68f4a2a0d297749bda79d2697de468c9cf6d Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Wed, 21 Oct 2020 11:29:18 -0400 Subject: so does not capture the vnf name Add requestid to return headers to audit filter Added catch for exceptions from validators Removed unused test file Updated validation unit test Updated transactionId header assertion in failing test Updated assertion as validator order changes Updated assertions to check for requestId Issue-ID: SO-3325 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I246d9e371346639b4c4ea2b99add1d891af96b8e --- .../jaxrs/filter/SOAuditLogContainerFilter.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'common/src') 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 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)); + } } -- cgit 1.2.3-korg