<commit_before>
package edu.wustl.query.action;

import java.util.List;

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 edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.query.factory.AbstractQueryUIManagerFactory;
import edu.wustl.query.actionForm.CategorySearchForm;
import edu.wustl.query.util.global.Constants;
import edu.wustl.query.util.querysuite.AbstractQueryUIManager;

/**
 * Action class to load the data required for GetCountPopUp.jsp (Used to show the Count of QueryResults)
 * @author pallavi_mistry
 *
 */
public class GetCountPopUpAction extends Action
{

	/**
	 * Sets the Project list and currently selected project in the form
	 * @param mapping mapping
	 * @param form form
	 * @param request request
	 * @param response response
	 * @throws Exception Exception
	 * @return ActionForward actionForward
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		CategorySearchForm categorySearchForm = (CategorySearchForm) form;

		//get the userId from session data bean
		SessionDataBean sessionData = (SessionDataBean) request.getSession().getAttribute(
				Constants.SESSION_DATA);
		HttpSession session = request.getSession();
		Long userId = sessionData.getUserId();
		if (userId == null)
		{
			userId = Long.valueOf((1));
		}
			

		//Retrieve the Project list
		AbstractQueryUIManager qUIManager = AbstractQueryUIManagerFactory
				.getDefaultAbstractUIQueryManager();
		List<NameValueBean> projectList = qUIManager.getObjects(userId);
		if (projectList != null)
		{
			categorySearchForm.setProjectsNameValueBeanList(projectList);
		}

		//retrieve the Selected Project from the GetCounts.jsp
		String selectedProject = (String)session.getAttribute(
				Constants.SELECTED_PROJECT);
		categorySearchForm.setCurrentSelectedProject(selectedProject);
		boolean hasSecurePrivilege = true;
		session.removeAttribute(Constants.HAS_SECURE_PRIVILEGE);
        if (!selectedProject.equals("") && Long.valueOf(selectedProject) > 0)
        {
        	hasSecurePrivilege = qUIManager.hasSecurePrivilege(request);
        }
         session.setAttribute(Constants.HAS_SECURE_PRIVILEGE,hasSecurePrivilege);
		//		request.setAttribute(Constants.SELECTED_PROJECT,selectedProject);

		return mapping.findForward(edu.wustl.query.util.global.Constants.SUCCESS);<commit_msg>changes for bug:11926 (showing count=0 for recent queries if privilege de-identified)<commit_after>
package edu.wustl.query.action;

import java.util.List;

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 edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.beans.SessionDataBean;
import edu.wustl.common.query.factory.AbstractQueryUIManagerFactory;
import edu.wustl.query.actionForm.CategorySearchForm;
import edu.wustl.query.util.global.Constants;
import edu.wustl.query.util.querysuite.AbstractQueryUIManager;

/**
 * Action class to load the data required for GetCountPopUp.jsp (Used to show the Count of QueryResults)
 * @author pallavi_mistry
 *
 */
public class GetCountPopUpAction extends Action
{

	/**
	 * Sets the Project list and currently selected project in the form
	 * @param mapping mapping
	 * @param form form
	 * @param request request
	 * @param response response
	 * @throws Exception Exception
	 * @return ActionForward actionForward
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) throws Exception
	{
		CategorySearchForm categorySearchForm = (CategorySearchForm) form;

		//get the userId from session data bean
		SessionDataBean sessionData = (SessionDataBean) request.getSession().getAttribute(
				Constants.SESSION_DATA);
		HttpSession session = request.getSession();
		Long userId = sessionData.getUserId();
		if (userId == null)
		{
			userId = Long.valueOf((1));
		}
			

		//Retrieve the Project list
		AbstractQueryUIManager qUIManager = AbstractQueryUIManagerFactory
				.getDefaultAbstractUIQueryManager();
		List<NameValueBean> projectList = qUIManager.getObjects(userId);
		if (projectList != null)
		{
			categorySearchForm.setProjectsNameValueBeanList(projectList);
		}

		//retrieve the Selected Project from the GetCounts.jsp
		String selectedProject = (String)session.getAttribute(
				Constants.SELECTED_PROJECT);
		categorySearchForm.setCurrentSelectedProject(selectedProject);
		// set privilege in session based on project id and user id.
		qUIManager.getPrivilege(request);
       	return mapping.findForward(edu.wustl.query.util.global.Constants.SUCCESS);
{'fraction_non_alphanumeric': 0.08794162826420891, 'fraction_numerical': 0.0017281105990783411, 'mean_word_length': 5.164497041420119, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '6645003', 'n_tokens_mistral': 1564, 'n_tokens_neox': 1508, 'n_words': 337}