<commit_before>/**
 * <p>Title: UserAction Class>
 * <p>Description:	This class initializes the fields in the User Add/Edit webpage.</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 * Created on Mar 22, 2005
 */

package edu.wustl.catissuecore.action;

import java.util.List;
import java.util.Map;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.wustl.catissuecore.actionForm.UserForm;
import edu.wustl.catissuecore.bizlogic.AssignPrivilegePageBizLogic;
import edu.wustl.catissuecore.bizlogic.BizLogicFactory;
import edu.wustl.catissuecore.bizlogic.UserBizLogic;
import edu.wustl.catissuecore.domain.CancerResearchGroup;
import edu.wustl.catissuecore.domain.Department;
import edu.wustl.catissuecore.domain.Institution;
import edu.wustl.catissuecore.domain.User;
import edu.wustl.catissuecore.multiRepository.bean.SiteUserRolePrivilegeBean;
import edu.wustl.catissuecore.util.CaTissuePrivilegeUtility;
import edu.wustl.catissuecore.util.MSRUtil;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.catissuecore.util.global.DefaultValueManager;
import edu.wustl.common.action.SecureAction;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.cde.CDEManager;
import edu.wustl.common.security.PrivilegeManager;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.common.util.logger.Logger;

/**
 * This class initializes the fields in the User Add/Edit webpage.
 * @author gautam_shetty
 */
public class UserAction extends SecureAction
{

    /**
     * Overrides the execute method of Action class.
     * Sets the various fields in User Add/Edit webpage.
     * */
    protected ActionForward executeSecureAction(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        
    	//Gets the value of the operation parameter.
        String operation =request.getParameter(Constants.OPERATION);
        String pageOf = (String)request.getParameter(Constants.PAGEOF);
        String reqPath = (String)request.getParameter(Constants.REQ_PATH);
        String submittedFor=(String)request.getAttribute(Constants.SUBMITTED_FOR);
        String openInCPFrame=(String)request.getParameter(Constants.OPEN_PAGE_IN_CPFRAME);
        UserForm userForm=(UserForm)form;
        
        
      
        MSRUtil msrUtil=new MSRUtil();
    //    final AssignPrivilegePageBizLogic apBizLogic= msrUtil.getAssignPrivilegePageBizLogic();
	//	final List<NameValueBean> siteList = apBizLogic.getSiteList(false);
	//	request.setAttribute(Constants.SITELIST, siteList);
	//	request.setAttribute("siteListforJSP", Constants.SITELIST);
        if(operation.equalsIgnoreCase(Constants.ADD))
        {
        	HttpSession session=request.getSession();
        	session.removeAttribute("rowIdBeanMapForUserPage");
        }
        
        String formName,prevPage=null,nextPage=null;
        boolean roleStatus=false;
		if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))
		{
			Long identifier = (Long)request.getAttribute(Constants.PREVIOUS_PAGE);
			request.setAttribute("prevPageId", identifier);
			prevPage = Constants.USER_DETAILS_SHOW_ACTION+"?"+Constants.SYSTEM_IDENTIFIER+"="+identifier;
			identifier = (Long)request.getAttribute(Constants.NEXT_PAGE);
			nextPage = Constants.USER_DETAILS_SHOW_ACTION+"?"+Constants.SYSTEM_IDENTIFIER+"="+identifier;
		    request.setAttribute("nextPageId", identifier);
		     
		}
		if (!pageOf.equals(Constants.PAGEOF_APPROVE_USER))
		{
			if(operation.equals(Constants.EDIT) && (userForm.getCsmUserId()!=null))
			{
				if(userForm.getCsmUserId().longValue()==0)
				{
					UserBizLogic bizLogic = (UserBizLogic) BizLogicFactory.getInstance().getBizLogic(Constants.USER_FORM_ID);
					String sourceObjName = User.class.getName();
					String[] selectColName = {"csmUserId"};
					String[] whereColName = {"id"};
					String[] whereColCond = {"="};
					Object[] whereColVal = {userForm.getId()};

					List regList = bizLogic.retrieve(sourceObjName, selectColName, whereColName, whereColCond, whereColVal,Constants.AND_JOIN_CONDITION);
					if (regList != null && !regList.isEmpty())
					{
						Object obj = (Object) regList.get(0);
						Long id = (Long) obj;
						userForm.setCsmUserId(id);
					}
				}
			}
		}
        if (operation.equals(Constants.EDIT))
        {
        	setUserPrivileges(request.getSession(),userForm.getId());
			if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))
			{
				formName = Constants.APPROVE_USER_EDIT_ACTION;
			}
			else if (pageOf.equals(Constants.PAGEOF_USER_PROFILE))
			{
				formName = Constants.USER_EDIT_PROFILE_ACTION;
			}
			else
			{
            	formName = Constants.USER_EDIT_ACTION;
			}
          }
        else
        {
			if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))<commit_msg>MSR changes for S6<commit_after>/**
 * <p>Title: UserAction Class>
 * <p>Description:	This class initializes the fields in the User Add/Edit webpage.</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 * Created on Mar 22, 2005
 */

package edu.wustl.catissuecore.action;

import java.util.List;
import java.util.Map;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.wustl.catissuecore.actionForm.UserForm;
import edu.wustl.catissuecore.bizlogic.AssignPrivilegePageBizLogic;
import edu.wustl.catissuecore.bizlogic.BizLogicFactory;
import edu.wustl.catissuecore.bizlogic.UserBizLogic;
import edu.wustl.catissuecore.domain.CancerResearchGroup;
import edu.wustl.catissuecore.domain.Department;
import edu.wustl.catissuecore.domain.Institution;
import edu.wustl.catissuecore.domain.User;
import edu.wustl.catissuecore.multiRepository.bean.SiteUserRolePrivilegeBean;
import edu.wustl.catissuecore.util.CaTissuePrivilegeUtility;
import edu.wustl.catissuecore.util.MSRUtil;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.catissuecore.util.global.DefaultValueManager;
import edu.wustl.common.action.SecureAction;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.bizlogic.IBizLogic;
import edu.wustl.common.cde.CDEManager;
import edu.wustl.common.security.PrivilegeManager;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.common.util.logger.Logger;

/**
 * This class initializes the fields in the User Add/Edit webpage.
 * @author gautam_shetty
 */
public class UserAction extends SecureAction
{

    /**
     * Overrides the execute method of Action class.
     * Sets the various fields in User Add/Edit webpage.
     * */
    protected ActionForward executeSecureAction(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        
    	//Gets the value of the operation parameter.
        String operation =request.getParameter(Constants.OPERATION);
        String pageOf = (String)request.getParameter(Constants.PAGEOF);
        String reqPath = (String)request.getParameter(Constants.REQ_PATH);
        String submittedFor=(String)request.getAttribute(Constants.SUBMITTED_FOR);
        String openInCPFrame=(String)request.getParameter(Constants.OPEN_PAGE_IN_CPFRAME);
        UserForm userForm=(UserForm)form;
        
        
      
        MSRUtil msrUtil=new MSRUtil();
    //    final AssignPrivilegePageBizLogic apBizLogic= msrUtil.getAssignPrivilegePageBizLogic();
	//	final List<NameValueBean> siteList = apBizLogic.getSiteList(false);
	//	request.setAttribute(Constants.SITELIST, siteList);
	//	request.setAttribute("siteListforJSP", Constants.SITELIST);
        if(operation.equalsIgnoreCase(Constants.ADD))
        {
        	HttpSession session=request.getSession();
        	session.removeAttribute("rowIdBeanMapForUserPage");
        }
        
        String formName,prevPage=null,nextPage=null;
        boolean roleStatus=false;
		if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))
		{
			Long identifier = (Long)request.getAttribute(Constants.PREVIOUS_PAGE);
			request.setAttribute("prevPageId", identifier);
			prevPage = Constants.USER_DETAILS_SHOW_ACTION+"?"+Constants.SYSTEM_IDENTIFIER+"="+identifier;
			identifier = (Long)request.getAttribute(Constants.NEXT_PAGE);
			nextPage = Constants.USER_DETAILS_SHOW_ACTION+"?"+Constants.SYSTEM_IDENTIFIER+"="+identifier;
		    request.setAttribute("nextPageId", identifier);
		     
		}
		if (!pageOf.equals(Constants.PAGEOF_APPROVE_USER))
		{
			if(operation.equals(Constants.EDIT) && (userForm.getCsmUserId()!=null))
			{
				if(userForm.getCsmUserId().longValue()==0)
				{
					UserBizLogic bizLogic = (UserBizLogic) BizLogicFactory.getInstance().getBizLogic(Constants.USER_FORM_ID);
					String sourceObjName = User.class.getName();
					String[] selectColName = {"csmUserId"};
					String[] whereColName = {"id"};
					String[] whereColCond = {"="};
					Object[] whereColVal = {userForm.getId()};

					List regList = bizLogic.retrieve(sourceObjName, selectColName, whereColName, whereColCond, whereColVal,Constants.AND_JOIN_CONDITION);
					if (regList != null && !regList.isEmpty())
					{
						Object obj = (Object) regList.get(0);
						Long id = (Long) obj;
						userForm.setCsmUserId(id);
					}
				}
			}
		}
        if (operation.equals(Constants.EDIT))
        {
        	if (!pageOf.equals(Constants.PAGEOF_APPROVE_USER))
        	{	
        		setUserPrivileges(request.getSession(),userForm.getId());
        	}
        	
			if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))
			{
				formName = Constants.APPROVE_USER_EDIT_ACTION;
			}
			else if (pageOf.equals(Constants.PAGEOF_USER_PROFILE))
			{
				formName = Constants.USER_EDIT_PROFILE_ACTION;
			}
			else
			{
            	formName = Constants.USER_EDIT_ACTION;
			}
          }
        else
        {
			if (pageOf.equals(Constants.PAGEOF_APPROVE_USER))
{'fraction_non_alphanumeric': 0.1091271725709944, 'fraction_numerical': 0.002184442967043404, 'mean_word_length': 4.13909224011713, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '5560311', 'n_tokens_mistral': 3656, 'n_tokens_neox': 3405, 'n_words': 526}