package it.mice.voila.runtime.springmvc.interceptors;

import it.mice.voila.runtime.web.util.SessionUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

public class SessionCleanUpInterceptor extends HandlerInterceptorAdapter {
	Log log = LogFactory.getLog(SessionCleanUpInterceptor.class);
	public static final String RESET_SESSION_PARM_NAME = "resetSession";
	
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {

		String value = request.getParameter(RESET_SESSION_PARM_NAME);
		if ("true".equals(value)) {
			SessionUtil.resetSession(request.getSession());
		}
		return true;
	}
}
