<commit_before>package edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol;

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

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.ModelAndViewDefiningException;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author <NAME>
 */

public class LoginCheckInterceptor extends HandlerInterceptorAdapter {
	private static Log log = LogFactory.getLog(SecureOperation.class);

	public boolean preHandle(HttpServletRequest request,
							HttpServletResponse response,
							Object handler) throws Exception {
		String userName = (String) LocalUser.getInstance();
		if (userName == null) {
			if (log.isDebugEnabled()) log.debug("request url " + request.getRequestURI() + "username in interceptor " + userName);
			ModelAndView mv = new ModelAndView("login");
			throw new ModelAndViewDefiningException(mv);
		}
		return true;
	}
}<commit_msg>changes made for new dispatcher servlet<commit_after>package edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol;

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

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.ModelAndViewDefiningException;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
//import org.springframework.web.servlet.view.RedirectView;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import edu.northwestern.bioinformatics.studycalendar.web.LoginCommand;

/**
 * @author <NAME>
 */;

public class LoginCheckInterceptor extends HandlerInterceptorAdapter {
	private static Log log = LogFactory.getLog(LoginCheckInterceptor.class);

	public boolean preHandle(HttpServletRequest request,
							HttpServletResponse response,
							Object handler) throws Exception {
		String userName = (String) LocalUser.getInstance();
		if (userName == null) {
			if (log.isDebugEnabled()) log.debug("request path " + request.getPathInfo() + " request url " + request.getRequestURI() + " username in interceptor " + userName);
			ModelAndView mv = new ModelAndView("login", "command", new LoginCommand());
			//ModelAndView mv = new ModelAndView(new RedirectView("login", true));
			throw new ModelAndViewDefiningException(mv);
			//response.sendRedirect("login");
			//return false;
			
		}
		return true;
	}
}
{'fraction_non_alphanumeric': 0.10318076027928627, 'fraction_numerical': 0.0, 'mean_word_length': 5.629820051413882, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6546284', 'n_tokens_mistral': 762, 'n_tokens_neox': 699, 'n_words': 150}