package tools.descartes.petsupplystore.registryclient.rest;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

public class TrackingFilter implements Filter {

	Logger logger = Logger.getLogger(TrackingFilter.class);
	
	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		BasicConfigurator.configure();
		if (request instanceof HttpServletRequest) {
			HttpServletRequest httpRequest = (HttpServletRequest) request;
			logger.info(httpRequest.getHeader("KiekerTracingInfo"));
		} else {
			logger.error("Something went wrong");
		}
		chain.doFilter(request, response);
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		
	}

}

@@ -385,16 +385,47 @@
 urator;%0A
+import org.apache.log4j.Level;%0A
 import o
@@ -448,16 +448,16 @@
 Logger;%0A
-
 %0Apublic 
@@ -645,42 +645,69 @@
 %7B%0A%09%09
-// TODO Auto-generated method stub
+BasicConfigurator.configure();%0A%09%09logger.setLevel(Level.INFO);
 %0A%09%09%0A
@@ -858,41 +858,8 @@
 n %7B%0A
-%09%09BasicConfigurator.configure();%0A
 %09%09if
@@ -974,20 +974,30 @@
 %0A%09%09%09
-logger.info(
+String trackingInfo = 
 http
@@ -1034,16 +1034,103 @@
 ngInfo%22)
+;%0A%09%09%09if (trackingInfo != null && !trackingInfo.equals(%22%22))%0A%09%09%09%09logger.info(trackingInfo
 );%0A%09%09%7D e

set logger level to Info to avoid http spam