blob: 5ae10824648f66150877fffa8b4ad54ccb6b9f81 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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
}
}
|