<commit_before>package edu.iu.grid.oim.model;

import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
import org.apache.log4j.Logger;

import com.divrep.DivRepPage;
import com.divrep.DivRepRoot;

import edu.iu.grid.oim.lib.Authorization;
import edu.iu.grid.oim.lib.AuthorizationException;
import edu.iu.grid.oim.lib.StaticConfig;

//provides easy access to various object that are user specific
public class UserContext {
    static Logger log = Logger.getLogger(UserContext.class);  
    private DivRepRoot divrep_root;
    private String divrep_pageid = null;
	private DivRepPage divrep_pageroot = null;
	
	private Authorization auth = new Authorization();
	//private Connection connection;
	
	private URL request_url;
	private String secure_url; //counter part for request_url in https (same if request_url is secure already)
	//private String guesthome_url;
	
	private HttpSession session;
	private String remote_addr;
	
	//let's lookup once per user request (not session)
    private DataSource oimds;

	//stores the reason for current transaction (used for log table)
	//why should this work? because *usually* all update within a session occurs under common purpose.
	private String comment;
	public void setComment(String _comment) { comment = _comment; }
	public String getComment() { return comment; }
	public String getRemoteAddr() { return remote_addr; }
	public HttpSession getSession() { return session; }
	
	public UserContext(HttpServletRequest request) throws AuthorizationException
	{	
		//don't store request object because it can get stale really fast... (was causing issue when divrep tries to get session from it)
		//request = _request;	
		
		session = request.getSession();
		auth = new Authorization(request);

		//parse request_url
		try {
			log.debug(request.getRequestURL());
			log.debug(request.getRequestURI());
			request_url = new URL(request.getRequestURL().toString() + "?" + request.getQueryString());
		} catch (MalformedURLException e) {<commit_msg>added check for invalidated session.<commit_after>package edu.iu.grid.oim.model;

import java.net.MalformedURLException;
import java.net.URL;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
import org.apache.log4j.Logger;

import com.divrep.DivRepPage;
import com.divrep.DivRepRoot;

import edu.iu.grid.oim.lib.Authorization;
import edu.iu.grid.oim.lib.AuthorizationException;
import edu.iu.grid.oim.lib.StaticConfig;

//provides easy access to various object that are user specific
public class UserContext {
    static Logger log = Logger.getLogger(UserContext.class);  
    private DivRepRoot divrep_root;
    private String divrep_pageid = null;
	private DivRepPage divrep_pageroot = null;
	
	private Authorization auth = new Authorization();
	//private Connection connection;
	
	private URL request_url;
	private String secure_url; //counter part for request_url in https (same if request_url is secure already)
	//private String guesthome_url;
	
	private HttpSession session;
	private String remote_addr;
	
	//let's lookup once per user request (not session)
    private DataSource oimds;

	//stores the reason for current transaction (used for log table)
	//why should this work? because *usually* all update within a session occurs under common purpose.
	private String comment;
	public void setComment(String _comment) { comment = _comment; }
	public String getComment() { return comment; }
	public String getRemoteAddr() { return remote_addr; }
	public HttpSession getSession() { return session; }
	
	public UserContext(HttpServletRequest request) throws AuthorizationException
	{	
		//don't store request object because it can get stale really fast... (was causing issue when divrep tries to get session from it)
		//request = _request;	
		
		if(request.isRequestedSessionIdValid()) {
			session = request.getSession();
		}
		auth = new Authorization(request);

		//parse request_url
		try {
			log.debug(request.getRequestURL());
			log.debug(request.getRequestURI());
			request_url = new URL(request.getRequestURL().toString() + "?" + request.getQueryString());
		} catch (MalformedURLException e) {
{'fraction_non_alphanumeric': 0.08919382504288165, 'fraction_numerical': 0.0004288164665523156, 'mean_word_length': 4.809464508094645, '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': '3302044', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1312, 'n_words': 415}