1 package org.onap.aai.interceptors.post;
3 import java.io.IOException;
5 import javax.annotation.Priority;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.ws.rs.container.ContainerRequestContext;
8 import javax.ws.rs.container.ContainerResponseContext;
9 import javax.ws.rs.container.ContainerResponseFilter;
11 import org.onap.aai.interceptors.AAIContainerFilter;
12 import org.onap.aai.logging.LoggingContext;
13 import org.onap.aai.logging.LoggingContext.StatusCode;
14 import org.springframework.beans.factory.annotation.Autowired;
16 import com.att.eelf.configuration.EELFLogger;
17 import com.att.eelf.configuration.EELFManager;
19 @Priority(AAIResponseFilterPriority.RESET_LOGGING_CONTEXT)
20 public class ResetLoggingContext extends AAIContainerFilter implements ContainerResponseFilter {
22 private static final EELFLogger LOGGER = EELFManager.getInstance().getLogger(ResetLoggingContext.class);
25 private HttpServletRequest httpServletRequest;
28 public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
31 this.cleanLoggingContext();
35 private void cleanLoggingContext() {
36 final String responseCode = LoggingContext.responseCode();
37 String url = httpServletRequest.getRequestURL().toString();
39 if (responseCode != null && responseCode.startsWith("ERR.")) {
40 LoggingContext.statusCode(StatusCode.ERROR);
41 LOGGER.error(url + " call failed with responseCode=" + responseCode);
43 LoggingContext.statusCode(StatusCode.COMPLETE);
44 LOGGER.info(url + " call succeeded");
47 LoggingContext.clear();