<commit_before>package org.unitime.timetable.action;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;
import org.unitime.commons.User;
import org.unitime.commons.web.Web;
import org.unitime.timetable.form.EventAddForm;

public class EventAddAction extends Action {

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */	
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		EventAddForm myForm = (EventAddForm) form;
		
		String op = myForm.getOp();
		if (request.getParameter("op2")!=null && request.getParameter("op2").length()>0)
			op = request.getParameter("op2");
		
		if (op!=null && !"SessionChanged".equals(op)) {
			myForm.loadDates(request);
		}
		
        if ("Show Scheduled Events".equals(op)) {
        	ActionMessages errors = myForm.validate(mapping, request);
        	if (!errors.isEmpty()) {
        		saveErrors(request, errors);
        	} else {
        		System.out.println("Event dates:"+myForm.getMeetingDates());
        	}
        }

        if ("Show Availability".equals(op)) {
        	ActionMessages errors = myForm.validate(mapping, request);
        	if (!errors.isEmpty()) {
        		saveErrors(request, errors);
        	} /*else {
        		System.out.println("Event dates:"+myForm.getMeetingDates());
        	}*/
        }        
		
//        System.out.println(">>> "+op+" <<<");
		
		HttpSession webSession = request.getSession();
		User user = Web.getUser(webSession);
			
		if (!Web.isLoggedIn(webSession)) {
			throw new Exception("Access Denied.");
		}			
		
        return mapping.findForward("show");
	}
}

<commit_msg>redirect to Event Room Availability screen (+ some work in progress)<commit_after>package org.unitime.timetable.action;

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

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessages;
import org.unitime.commons.web.Web;
import org.unitime.timetable.form.EventAddForm;

/**
 * @author <NAME>
 */
public class EventAddAction extends Action {

	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */	
	public ActionForward execute(
			ActionMapping mapping,
			ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws Exception {

//Collect initial info - form & model
		EventAddForm myForm = (EventAddForm) form;

/*        EventModel model = (EventModel)request.getSession().getAttribute("Event.model");
        if (model==null) {
            model = new EventModel();
            request.getSession().setAttribute("Event.model", model);
        }
*/		

//		myForm.load(request.getSession());
        
//Verification of user being logged in
		if (!Web.isLoggedIn( request.getSession() )) {
            throw new Exception ("Access Denied.");
        }		

//Operations
		String op = myForm.getOp();
		if (request.getParameter("op2")!=null && request.getParameter("op2").length()>0)
			op = request.getParameter("op2");
		
		// if a different session is selected, display calendar for this new session
		if (op!=null && !"SessionChanged".equals(op)) {
			myForm.loadDates(request);
		}
		
        if ("Show Scheduled Events".equals(op)) {
        	ActionMessages errors = myForm.validate(mapping, request);
        	if (!errors.isEmpty()) {
        		saveErrors(request, errors);
        	} else {
        		System.out.println("Event dates:"+myForm.getMeetingDates());
        		myForm.save(request.getSession());
        	}
        }

        if ("Show Availability".equals(op)) {
        	ActionMessages errors = myForm.validate(mapping, request);
        	if (!errors.isEmpty()) {
        		saveErrors(request, errors);
        	} else {
        		myForm.save(request.getSession());
        		response.sendRedirect(response.encodeURL("eventRoomAvailability.do"));
//        		return mapping.findForward("showEventRoomAvailability");
        	}
        }        
		
//test:        System.out.println(">>> "+op+" <<<");


//set the model        
//        myForm.setModel(model);
//        model.apply(request, myForm);
        
        
//Display the page        
        return mapping.findForward("show");
	}
}


{'fraction_non_alphanumeric': 0.13078512396694214, 'fraction_numerical': 0.001652892561983471, 'mean_word_length': 2.9942244224422443, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 12, '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': '6958472', 'n_tokens_mistral': 1491, 'n_tokens_neox': 1400, 'n_words': 281}