<commit_before>/**
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0 + Health disclaimer. If a copy of the MPL was not distributed with
 * this file, You can obtain one at http://license.openmrs.org
 */
package org.openmrs.module.owa.filter;

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.openmrs.api.context.Context;

/**
 * @author sunbiz
 */
public class OwaFilter implements Filter {
	
	private String openmrsPath;
	
	@Override
	public void init(FilterConfig fc) throws ServletException {
		openmrsPath = fc.getServletContext().getContextPath();
	}
	
	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		String requestURI = request.getRequestURI();
		if (Context.isAuthenticated()) {
			if (requestURI.startsWith(openmrsPath + "/owa")) {
				String newURI = requestURI.replace("/openmrs/owa", "/ms/owa/fileServlet");
				req.getRequestDispatcher(newURI).forward(req, res);
			} else {
				chain.doFilter(req, res);
			}
		} else {
			if (requestURI.startsWith(openmrsPath + "/owa")) {
				String newURI = requestURI.replace("/openmrs/owa", "/ms/owa/redirectServlet");
				req.getRequestDispatcher(newURI).forward(req, res);
			} else {
				chain.doFilter(req, res);
			}
		}
	}
	
	@Override
	public void destroy() {
	}
	
}<commit_msg>Update OwaFilter.java<commit_after>/**
 * This Source Code Form is subject to the terms of the Mozilla Public License,
 * v. 2.0 + Health disclaimer. If a copy of the MPL was not distributed with
 * this file, You can obtain one at http://license.openmrs.org
 */
package org.openmrs.module.owa.filter;

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.openmrs.api.context.Context;

/**
 * @author sunbiz
 */
public class OwaFilter implements Filter {
	
	private String openmrsPath;
	
	@Override
	public void init(FilterConfig fc) throws ServletException {
		openmrsPath = fc.getServletContext().getContextPath();
	}
	
	@Override
	public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) req;
		String requestURI = request.getRequestURI();
		if (Context.isAuthenticated()) {
			if (requestURI.startsWith(openmrsPath + "/owa")) {
				String newURI = requestURI.replace(openmrsPath + "/owa", "/ms/owa/fileServlet");
				req.getRequestDispatcher(newURI).forward(req, res);
			} else {
				chain.doFilter(req, res);
			}
		} else {
			if (requestURI.startsWith(openmrsPath + "/owa")) {
				String newURI = requestURI.replace(openmrsPath + "/owa", "/ms/owa/redirectServlet");
				req.getRequestDispatcher(newURI).forward(req, res);
			} else {
				chain.doFilter(req, res);
			}
		}
	}
	
	@Override
	public void destroy() {
	}
	
}
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.0011926058437686344, 'mean_word_length': 4.473083197389886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1217587', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1008, 'n_words': 255}