Coverage Report - org.kuali.rice.kew.actionlist.web.ActionListAction
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListAction
0%
0/394
0%
0/252
6.429
ActionListAction$1
0%
0/3
N/A
6.429
ActionListAction$ActionItemComparator
0%
0/22
0%
0/14
6.429
 
 1  
 /*
 2  
  * Copyright 2005-2009 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.actionlist.web;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.Arrays;
 21  
 import java.util.Collection;
 22  
 import java.util.Collections;
 23  
 import java.util.Comparator;
 24  
 import java.util.Iterator;
 25  
 import java.util.LinkedHashMap;
 26  
 import java.util.List;
 27  
 import java.util.Map;
 28  
 
 29  
 import javax.servlet.http.HttpServletRequest;
 30  
 import javax.servlet.http.HttpServletResponse;
 31  
 
 32  
 import org.apache.commons.collections.ComparatorUtils;
 33  
 import org.apache.commons.collections.comparators.ComparableComparator;
 34  
 import org.apache.commons.lang.StringUtils;
 35  
 import org.apache.struts.action.ActionForm;
 36  
 import org.apache.struts.action.ActionForward;
 37  
 import org.apache.struts.action.ActionMapping;
 38  
 import org.apache.struts.action.ActionMessage;
 39  
 import org.apache.struts.action.ActionMessages;
 40  
 import org.displaytag.pagination.PaginatedList;
 41  
 import org.displaytag.properties.SortOrderEnum;
 42  
 import org.displaytag.util.LookupUtil;
 43  
 import org.kuali.rice.core.config.ConfigContext;
 44  
 import org.kuali.rice.core.exception.RiceRuntimeException;
 45  
 import org.kuali.rice.core.util.JSTLConstants;
 46  
 import org.kuali.rice.kew.actionitem.ActionItem;
 47  
 import org.kuali.rice.kew.actionitem.ActionItemActionListExtension;
 48  
 import org.kuali.rice.kew.actionlist.ActionListFilter;
 49  
 import org.kuali.rice.kew.actionlist.ActionToTake;
 50  
 import org.kuali.rice.kew.actionlist.CustomActionListAttribute;
 51  
 import org.kuali.rice.kew.actionlist.PaginatedActionList;
 52  
 import org.kuali.rice.kew.actionlist.service.ActionListService;
 53  
 import org.kuali.rice.kew.actionrequest.Recipient;
 54  
 import org.kuali.rice.kew.actions.ActionSet;
 55  
 import org.kuali.rice.kew.actions.asyncservices.ActionInvocation;
 56  
 import org.kuali.rice.kew.exception.WorkflowException;
 57  
 import org.kuali.rice.kew.preferences.Preferences;
 58  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValueActionListExtension;
 59  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 60  
 import org.kuali.rice.kew.util.KEWConstants;
 61  
 import org.kuali.rice.kew.util.PerformanceLogger;
 62  
 import org.kuali.rice.kew.util.WebFriendlyRecipient;
 63  
 import org.kuali.rice.kew.web.session.UserSession;
 64  
 import org.kuali.rice.kim.bo.Person;
 65  
 import org.kuali.rice.kns.exception.AuthorizationException;
 66  
 import org.kuali.rice.kns.util.GlobalVariables;
 67  
 import org.kuali.rice.kns.web.struts.action.KualiAction;
 68  
 import org.kuali.rice.kns.web.ui.ExtraButton;
 69  
 
 70  
 
 71  
 /**
 72  
  * Action doing Action list stuff
 73  
  *
 74  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 75  
  *
 76  
  */
 77  0
 public class ActionListAction extends KualiAction {
 78  
 
 79  0
         private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListAction.class);
 80  
 
 81  
     private static final String ACTION_LIST_KEY = "actionList";
 82  
     private static final String ACTION_LIST_PAGE_KEY = "actionListPage";
 83  
     private static final String ACTION_LIST_USER_KEY = "actionList.user";
 84  
     private static final String REQUERY_ACTION_LIST_KEY = "requeryActionList";
 85  
 
 86  
     // property names used for errors -- some of these are bogus, as there isn't
 87  
     // really a form whose fields can be highlighted.
 88  
     private static final String ROUTEHEADERID_PROP = "routeHeaderId";
 89  
     private static final String ACTIONREQUESTCD_PROP = "actionRequestCd";
 90  
     private static final String CUSTOMACTIONLIST_PROP = "customActionList";
 91  
     private static final String DOCTITLE_PROP = "docTitle";
 92  
     private static final String ACTIONITEM_PROP = "actionitem";
 93  
     private static final String HELPDESK_ACTIONLIST_USERNAME = "helpDeskActionListUserName";
 94  
 
 95  
     // error keys
 96  
     private static final String ACTIONITEM_ROUTEHEADERID_INVALID_ERRKEY = "actionitem.routeheaderid.invalid";
 97  
     private static final String ACTIONITEM_ACTIONREQUESTCD_INVALID_ERRKEY = "actionitem.actionrequestcd.invalid";
 98  
     private static final String ACTIONLIST_BAD_CUSTOM_ACTION_LIST_ITEMS_ERRKEY = "actionlist.badCustomActionListItems";
 99  
         private static final String ACTIONLIST_BAD_ACTION_ITEMS_ERRKEY = "actionlist.badActionItems";
 100  
         private static final String HELPDESK_LOGIN_EMPTY_ERRKEY = "helpdesk.login.empty";
 101  
         private static final String HELPDESK_LOGIN_INVALID_ERRKEY = "helpdesk.login.invalid";
 102  
 
 103  
 
 104  
         public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
 105  0
             ActionListForm frm = (ActionListForm)actionForm;
 106  0
             request.setAttribute("Constants", new JSTLConstants(KEWConstants.class));
 107  0
             request.setAttribute("preferences", this.getUserSession(request).getPreferences());
 108  0
             frm.setHeaderButtons(getHeaderButtons());
 109  0
             return super.execute(mapping, actionForm, request, response);
 110  
     }
 111  
 
 112  
     private List<ExtraButton> getHeaderButtons(){
 113  0
             List<ExtraButton> headerButtons = new ArrayList<ExtraButton>();
 114  0
             ExtraButton eb = new ExtraButton();
 115  0
             String krBaseUrl = ConfigContext.getCurrentContextConfig().getKRBaseURL();
 116  0
             eb.setExtraButtonSource( krBaseUrl + "/images/tinybutton-preferences.gif");
 117  0
             eb.setExtraButtonOnclick("Preferences.do?returnMapping=viewActionList");
 118  
 
 119  0
             headerButtons.add(eb);
 120  0
             eb = new ExtraButton();
 121  0
             eb.setExtraButtonSource(krBaseUrl + "/images/tinybutton-refresh.gif");
 122  0
             eb.setExtraButtonProperty("methodToCall.start");
 123  
 
 124  0
             headerButtons.add(eb);
 125  0
             eb = new ExtraButton();
 126  0
             eb.setExtraButtonSource(krBaseUrl + "/images/tinybutton-filter.gif");
 127  0
             eb.setExtraButtonOnclick("javascript: window.open('ActionListFilter.do?methodToCall=start');");
 128  0
             headerButtons.add(eb);
 129  
 
 130  
 
 131  0
             return headerButtons;
 132  
     }
 133  
 
 134  
 
 135  
 
 136  
         @Override
 137  
         protected ActionForward defaultDispatch(ActionMapping mapping,
 138  
                         ActionForm form, HttpServletRequest request,
 139  
                         HttpServletResponse response) throws Exception {
 140  0
                 return start(mapping, form, request, response);
 141  
         }
 142  
 
 143  
         public ActionForward start(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
 144  0
         PerformanceLogger plog = new PerformanceLogger();
 145  0
         plog.log("Starting ActionList fetch");
 146  0
         ActionListForm form = (ActionListForm) actionForm;
 147  0
         ActionListService actionListSrv = KEWServiceLocator.getActionListService();
 148  
 
 149  
 
 150  
         // process display tag parameters
 151  0
         Integer page = form.getPage();
 152  0
         String sortCriterion = form.getSort();
 153  0
         SortOrderEnum sortOrder = SortOrderEnum.ASCENDING;
 154  0
         if (form.getDir() != null) {
 155  0
                 sortOrder = parseSortOrder(form.getDir());
 156  
         }
 157  0
         else if ( !StringUtils.isEmpty(getUserSession(request).getSortOrder()))     {
 158  0
                 sortOrder = parseSortOrder(getUserSession(request).getSortOrder());
 159  
      //           System.out.println("Session value for SortOrder "+sortOrder);
 160  
         }
 161  
         // if both the page and the sort criteria are null, that means its the first entry into the page, use defaults
 162  0
         if (page == null && sortCriterion == null) {
 163  0
                 page = Integer.valueOf(1);
 164  0
                 sortCriterion = ActionItemComparator.DOCUMENT_ID;
 165  
         }
 166  0
         else if ( !StringUtils.isEmpty(getUserSession(request).getSortCriteria()))     {
 167  0
                 sortCriterion = getUserSession(request).getSortCriteria();
 168  
      //       System.out.println("Session sortCriterion variables used..."+getUserSession(request).getSortCriteria());
 169  
         }
 170  
         // if the page is still null, that means the user just performed a sort action, pull the currentPage off of the form
 171  0
         if (page == null) {
 172  0
                 page = form.getCurrentPage();
 173  
         }
 174  
 
 175  
         // update the values of the "current" display tag parameters
 176  0
         form.setCurrentPage(page);
 177  0
         if (!StringUtils.isEmpty(sortCriterion)) {
 178  0
                 form.setCurrentSort(sortCriterion);
 179  0
                 form.setCurrentDir(getSortOrderValue(sortOrder));
 180  
         }
 181  
 
 182  
         // reset the default action on the form
 183  0
         form.setDefaultActionToTake("NONE");
 184  
 
 185  0
         boolean freshActionList = true;
 186  
         // retrieve cached action list
 187  0
         List actionList = (List)request.getSession().getAttribute(ACTION_LIST_KEY);
 188  0
         plog.log("Time to initialize");
 189  
         try {
 190  0
             UserSession uSession = getUserSession(request);
 191  0
             String principalId = null;
 192  0
             if (uSession.getActionListFilter() == null) {
 193  0
                 ActionListFilter filter = new ActionListFilter();
 194  0
                 filter.setDelegationType(KEWConstants.DELEGATION_SECONDARY);
 195  0
                 filter.setExcludeDelegationType(true);
 196  0
                 uSession.setActionListFilter(filter);
 197  
             }
 198  
 
 199  
             /* 'forceListRefresh' variable used to signify that the action list filter has changed
 200  
              * any time the filter changes the action list must be refreshed or filter may not take effect on existing
 201  
              * list items... only exception is if action list has not loaded previous and fetching of the list has not
 202  
              * occurred yet
 203  
              */
 204  0
             boolean forceListRefresh = request.getSession().getAttribute(REQUERY_ACTION_LIST_KEY) != null;
 205  0
             if (uSession.getHelpDeskActionListPrincipal() != null) {
 206  0
                     principalId = uSession.getHelpDeskActionListPrincipal().getPrincipalId();
 207  
             } else {
 208  0
                 if (!StringUtils.isEmpty(form.getDocType())) {
 209  0
                     uSession.getActionListFilter().setDocumentType(form.getDocType());
 210  0
                     uSession.getActionListFilter().setExcludeDocumentType(false);
 211  0
                     forceListRefresh = true;
 212  
                 }
 213  0
                 principalId = uSession.getPerson().getPrincipalId();
 214  
             }
 215  
 
 216  0
             Preferences preferences = getUserSession(request).getPreferences();
 217  
 
 218  0
             if (!StringUtils.isEmpty(form.getDelegationId())) {
 219  0
                     if (!KEWConstants.DELEGATION_DEFAULT.equals(form.getDelegationId())) {
 220  
                             // If the user can filter by both primary and secondary delegation, and both drop-downs have non-default values assigned,
 221  
                             // then reset the primary delegation drop-down's value when the primary delegation drop-down's value has remained unaltered
 222  
                             // but the secondary drop-down's value has been altered; but if one of these alteration situations does not apply, reset the
 223  
                             // secondary delegation drop-down.
 224  0
                             if (StringUtils.isNotBlank(form.getPrimaryDelegateId()) && !KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(form.getPrimaryDelegateId())){
 225  0
                                     if (form.getPrimaryDelegateId().equals(request.getParameter("oldPrimaryDelegateId")) &&
 226  
                                                     !form.getDelegationId().equals(request.getParameter("oldDelegationId"))) {
 227  0
                                             form.setPrimaryDelegateId(KEWConstants.PRIMARY_DELEGATION_DEFAULT);
 228  
                                     } else {
 229  0
                                             form.setDelegationId(KEWConstants.DELEGATION_DEFAULT);
 230  
                                     }
 231  0
                             } else if (StringUtils.isNotBlank(uSession.getActionListFilter().getPrimaryDelegateId()) &&
 232  
                                             !KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(uSession.getActionListFilter().getPrimaryDelegateId())) {
 233  
                                     // If the primary delegation drop-down is invisible but a primary delegation filter is in place, and if the secondary delegation
 234  
                                     // drop-down has a non-default value selected, then reset the primary delegation filtering.
 235  0
                                     uSession.getActionListFilter().setPrimaryDelegateId(KEWConstants.PRIMARY_DELEGATION_DEFAULT);
 236  
                             }
 237  
                     }
 238  
                     // Enable the secondary delegation filtering.
 239  0
                            uSession.getActionListFilter().setDelegatorId(form.getDelegationId());
 240  0
                            uSession.getActionListFilter().setExcludeDelegatorId(false);
 241  0
                            actionList = null;
 242  
             }
 243  
 
 244  0
             if (!StringUtils.isEmpty(form.getPrimaryDelegateId())) {
 245  
                     // If the secondary delegation drop-down is invisible but a secondary delegation filter is in place, and if the primary delegation
 246  
                     // drop-down has a non-default value selected, then reset the secondary delegation filtering.
 247  0
                     if (StringUtils.isBlank(form.getDelegationId()) && !KEWConstants.PRIMARY_DELEGATION_DEFAULT.equals(form.getPrimaryDelegateId()) && 
 248  
                                     StringUtils.isNotBlank(uSession.getActionListFilter().getDelegatorId()) &&
 249  
                                                     !KEWConstants.DELEGATION_DEFAULT.equals(uSession.getActionListFilter().getDelegatorId())) {
 250  0
                             uSession.getActionListFilter().setDelegatorId(KEWConstants.DELEGATION_DEFAULT);
 251  
                     }
 252  
                     // Enable the primary delegation filtering.
 253  0
                     uSession.getActionListFilter().setPrimaryDelegateId(form.getPrimaryDelegateId());
 254  0
                     uSession.getActionListFilter().setExcludeDelegatorId(false);
 255  0
                     actionList = null;
 256  
             }
 257  
             
 258  
             // if the user has changed, we need to refresh the action list
 259  0
             if (!principalId.equals((String) request.getSession().getAttribute(ACTION_LIST_USER_KEY))) {
 260  0
                 actionList = null;
 261  
             }
 262  
 
 263  0
             if (isOutboxMode(form, request, preferences)) {
 264  0
                     actionList = new ArrayList(actionListSrv.getOutbox(principalId, uSession.getActionListFilter()));
 265  0
                     form.setOutBoxEmpty(actionList.isEmpty());
 266  
             } else {
 267  0
                 if (actionList == null) {
 268  
                         //clear out old User Option records if they exist
 269  0
                         actionListSrv.refreshActionList(getUserSession(request).getPerson().getPrincipalId());
 270  
                         // fetch the action list
 271  0
                     actionList = new ArrayList(actionListSrv.getActionList(principalId, uSession.getActionListFilter()));
 272  0
                     request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId);
 273  0
                 } else if (forceListRefresh) {
 274  
                         // force a refresh... usually based on filter change or parameter specifying refresh needed
 275  0
                     actionList = new ArrayList(actionListSrv.getActionList(principalId, uSession.getActionListFilter()));
 276  0
                     request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId);
 277  0
                 } else if (actionListSrv.refreshActionList(getUserSession(request).getPerson().getPrincipalId())) {
 278  0
                     actionList = new ArrayList(actionListSrv.getActionList(principalId, uSession.getActionListFilter()));
 279  0
                     request.getSession().setAttribute(ACTION_LIST_USER_KEY, principalId);
 280  
                 } else {
 281  0
                         if (!uSession.isUpdateActionList()) {
 282  0
                                 freshActionList = false;
 283  
                         }
 284  
                 }
 285  0
                 request.getSession().setAttribute(ACTION_LIST_KEY, actionList);
 286  
             }
 287  
             // reset the requery action list key
 288  0
             request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, null);
 289  
 
 290  
             // build the drop-down of delegators
 291  0
             if (KEWConstants.DELEGATORS_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getDelegatorFilter())) {
 292  0
                 Collection delegators = actionListSrv.findUserSecondaryDelegators(principalId);
 293  0
                 form.setDelegators(getWebFriendlyRecipients(delegators));
 294  0
                 form.setDelegationId(uSession.getActionListFilter().getDelegatorId());
 295  
             }
 296  
 
 297  
             // Build the drop-down of primary delegates.
 298  0
             if (KEWConstants.PRIMARY_DELEGATES_ON_ACTION_LIST_PAGE.equalsIgnoreCase(preferences.getPrimaryDelegateFilter())) {
 299  0
                     Collection<Recipient> pDelegates = actionListSrv.findUserPrimaryDelegations(principalId);
 300  0
                     form.setPrimaryDelegates(getWebFriendlyRecipients(pDelegates));
 301  0
                     form.setPrimaryDelegateId(uSession.getActionListFilter().getPrimaryDelegateId());
 302  
             }
 303  
             
 304  0
             form.setFilterLegend(uSession.getActionListFilter().getFilterLegend());
 305  0
             plog.log("Setting attributes");
 306  
 
 307  0
             int pageSize = getPageSize(preferences);
 308  
             // initialize the action list if necessary
 309  0
             if (freshActionList) {
 310  0
                     plog.log("calling initializeActionList");
 311  0
                     initializeActionList(actionList, preferences);
 312  0
                     plog.log("done w/ initializeActionList");
 313  
                     // put this in to resolve EN-112 (http://beatles.uits.indiana.edu:8081/jira/browse/EN-112)
 314  
                 // if the action list gets "refreshed" in between page switches, we need to be sure and re-sort it, even though we don't have sort criteria on the request
 315  0
                     if (sortCriterion == null) {
 316  0
                             sortCriterion = form.getCurrentSort();
 317  0
                             sortOrder = parseSortOrder(form.getCurrentDir());
 318  
                     }
 319  
             }
 320  
             // sort the action list if necessary
 321  0
             if (sortCriterion != null) {
 322  0
                     sortActionList(actionList, sortCriterion, sortOrder);
 323  
             }
 324  
             
 325  0
             plog.log("calling buildCurrentPage");
 326  0
             PaginatedList currentPage = buildCurrentPage(actionList, form.getCurrentPage(), form.getCurrentSort(), 
 327  
                                     form.getCurrentDir(), pageSize, preferences, form);
 328  0
             plog.log("done w/ buildCurrentPage");
 329  0
             request.setAttribute(ACTION_LIST_PAGE_KEY, currentPage);
 330  0
             uSession.actionListUpdated();
 331  0
             uSession.setCurrentPage(form.getCurrentPage());
 332  0
             uSession.setSortCriteria(form.getSort());
 333  0
             uSession.setSortOrder(form.getCurrentDir());
 334  0
             plog.log("finished setting attributes, finishing action list fetch");
 335  0
         } catch (Exception e) {
 336  0
             LOG.error("Error loading action list.", e);
 337  0
         }
 338  
 
 339  0
         LOG.debug("end start ActionListAction");
 340  0
         return mapping.findForward("viewActionList");
 341  
     }
 342  
 
 343  
     private SortOrderEnum parseSortOrder(String dir) throws WorkflowException {
 344  0
             if ("asc".equals(dir)) {
 345  0
                     return SortOrderEnum.ASCENDING;
 346  0
             } else if ("desc".equals(dir)) {
 347  0
                     return SortOrderEnum.DESCENDING;
 348  
             }
 349  0
             throw new WorkflowException("Invalid sort direction: " + dir);
 350  
     }
 351  
 
 352  
     private String getSortOrderValue(SortOrderEnum sortOrder) {
 353  0
             if (SortOrderEnum.ASCENDING.equals(sortOrder)) {
 354  0
                     return "asc";
 355  0
             } else if (SortOrderEnum.DESCENDING.equals(sortOrder)) {
 356  0
                     return "desc";
 357  
             }
 358  0
             return null;
 359  
     }
 360  
 
 361  
     private static final String OUT_BOX_MODE = "_OUT_BOX_MODE";
 362  
 
 363  
     /**
 364  
      * this method is setting 2 props on the {@link ActionListForm} that controls outbox behavior.
 365  
      *  alForm.setViewOutbox("false"); -> this is set by user preferences and the actionlist.outbox.off config prop
 366  
      *  alForm.setShowOutbox(false); -> this is set by user action clicking the ActionList vs. Outbox links.
 367  
      *
 368  
      * @param alForm
 369  
      * @param request
 370  
      * @return boolean indication whether the outbox should be fetched
 371  
      */
 372  
     private boolean isOutboxMode(ActionListForm alForm, HttpServletRequest request, Preferences preferences) {
 373  
 
 374  0
         boolean outBoxView = false;
 375  
 
 376  0
         if (! preferences.isUsingOutbox() || ! ConfigContext.getCurrentContextConfig().getOutBoxOn()) {
 377  0
             request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(false));
 378  0
             alForm.setViewOutbox("false");
 379  0
             alForm.setShowOutbox(false);
 380  0
             return false;
 381  
         }
 382  
 
 383  0
         alForm.setShowOutbox(true);
 384  0
         if (StringUtils.isNotEmpty(alForm.getViewOutbox())) {
 385  0
             if (!Boolean.valueOf(alForm.getViewOutbox())) {
 386  0
                 request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(false));
 387  0
                 outBoxView = false;
 388  
             } else {
 389  0
                 request.getSession().setAttribute(OUT_BOX_MODE, Boolean.valueOf(true));
 390  0
                 outBoxView = true;
 391  
             }
 392  
         } else {
 393  
 
 394  0
             if (request.getSession().getAttribute(OUT_BOX_MODE) == null) {
 395  0
                 outBoxView = false;
 396  
             } else {
 397  0
                 outBoxView = (Boolean) request.getSession().getAttribute(OUT_BOX_MODE);
 398  
             }
 399  
         }
 400  0
         if (outBoxView) {
 401  0
             alForm.setViewOutbox("true");
 402  
         } else {
 403  0
             alForm.setViewOutbox("false");
 404  
         }
 405  0
         return outBoxView;
 406  
     }
 407  
 
 408  
     private void sortActionList(List actionList, String sortName, SortOrderEnum sortOrder) {
 409  0
             if (StringUtils.isEmpty(sortName)) {
 410  0
                     return;
 411  
             }
 412  0
             Comparator comparator = new ActionItemComparator(sortName);
 413  0
             if (SortOrderEnum.DESCENDING.equals(sortOrder)) {
 414  0
                     comparator = ComparatorUtils.reversedComparator(comparator);
 415  
             }
 416  0
             Collections.sort(actionList, comparator);
 417  
             // re-index the action items
 418  0
             int index = 0;
 419  0
             for (Iterator iterator = actionList.iterator(); iterator.hasNext();) {
 420  0
                         ActionItemActionListExtension actionItem = (ActionItemActionListExtension) iterator.next();
 421  0
                         actionItem.setActionItemIndex(Integer.valueOf(index++));
 422  0
                 }
 423  0
     }
 424  
 
 425  
     private void initializeActionList(List actionList, Preferences preferences) throws WorkflowException {
 426  0
             List actionItemProblemIds = new ArrayList();
 427  0
             int index = 0;
 428  0
             generateActionItemErrors(actionList);
 429  0
             for (Iterator iterator = actionList.iterator(); iterator.hasNext();) {
 430  0
                     ActionItemActionListExtension actionItem = (ActionItemActionListExtension)iterator.next();
 431  0
                     if (actionItem.getRouteHeaderId() == null) {
 432  0
                             LOG.error("Somehow there exists an ActionItem with a null document id!  actionItemId=" + actionItem.getActionItemId());
 433  0
                             iterator.remove();
 434  0
                             continue;
 435  
                     }
 436  
                     try {
 437  0
                             actionItem.initialize(preferences);
 438  0
                             DocumentRouteHeaderValueActionListExtension routeHeaderExtension = (DocumentRouteHeaderValueActionListExtension)actionItem.getRouteHeader();
 439  0
                             routeHeaderExtension.setActionListInitiatorPrincipal(routeHeaderExtension.getInitiatorPrincipal());
 440  0
                             actionItem.setActionItemIndex(Integer.valueOf(index));
 441  
                             //set background colors for document statuses
 442  0
                             if (KEWConstants.ROUTE_HEADER_APPROVED_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 443  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorApproved()));
 444  0
                             } else if (KEWConstants.ROUTE_HEADER_CANCEL_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 445  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorCanceled()));
 446  0
                             } else if (KEWConstants.ROUTE_HEADER_DISAPPROVED_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 447  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorDissaproved()));
 448  0
                             } else if (KEWConstants.ROUTE_HEADER_ENROUTE_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 449  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorEnroute()));
 450  0
                             } else if (KEWConstants.ROUTE_HEADER_EXCEPTION_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 451  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorException()));
 452  0
                             } else if (KEWConstants.ROUTE_HEADER_FINAL_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 453  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorFinal()));
 454  0
                             } else if (KEWConstants.ROUTE_HEADER_INITIATED_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 455  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorInitiated()));
 456  0
                             } else if (KEWConstants.ROUTE_HEADER_PROCESSED_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 457  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorProccessed()));
 458  0
                             } else if (KEWConstants.ROUTE_HEADER_SAVED_CD.equalsIgnoreCase(actionItem.getRouteHeader().getDocRouteStatus())) {
 459  0
                                     actionItem.setRowStyleClass((String)KEWConstants.ACTION_LIST_COLOR_PALETTE.get(preferences.getColorSaved()));
 460  
                             }
 461  0
                             index++;
 462  0
                     } catch (Exception e) {
 463  
                             // if there's a problem loading the action item, we don't want to blow out the whole screen but we will remove it from the list
 464  
                             // and display an approriate error message to the user
 465  0
                             LOG.error("Error loading action list for action item " + actionItem.getActionItemId(), e);
 466  0
                             iterator.remove();
 467  0
                             actionItemProblemIds.add(actionItem.getRouteHeaderId());
 468  0
                     }
 469  0
             }
 470  0
             generateActionItemErrors(ACTIONITEM_PROP, ACTIONLIST_BAD_ACTION_ITEMS_ERRKEY, actionItemProblemIds);
 471  0
     }
 472  
 
 473  
     /**
 474  
      * Gets the page size of the Action List.  Uses the user's preferences for page size unless the action list
 475  
      * has been throttled by an application constant, in which case it uses the smaller of the two values.
 476  
      */
 477  
     protected int getPageSize(Preferences preferences) {
 478  0
             return Integer.parseInt(preferences.getPageSize());
 479  
     }
 480  
 
 481  
     protected PaginatedList buildCurrentPage(List actionList, Integer page, String sortCriterion, String sortDirection, 
 482  
                     int pageSize, Preferences preferences, ActionListForm form) throws WorkflowException {
 483  0
             List currentPage = new ArrayList(pageSize);
 484  0
             boolean haveFyis = false;
 485  0
             boolean haveApproves = false;
 486  0
             boolean haveAcknowledges = false;
 487  0
             boolean haveCancels = false;
 488  0
             boolean haveDisapproves = false;
 489  0
             boolean haveCustomActions = false;
 490  0
             boolean haveDisplayParameters = false;
 491  0
             List customActionListProblemIds = new ArrayList();
 492  0
             SortOrderEnum sortOrder = parseSortOrder(sortDirection);
 493  0
             int startIndex = (page.intValue() - 1) * pageSize;
 494  0
             int endIndex = startIndex + pageSize;
 495  0
             generateActionItemErrors(actionList);
 496  0
             for (int index = startIndex; index < endIndex && index < actionList.size(); index++) {
 497  0
                     ActionItemActionListExtension actionItem = (ActionItemActionListExtension)actionList.get(index);
 498  
                     // evaluate custom action list component for mass actions
 499  
                     try {
 500  0
                             boolean itemHasApproves = false;
 501  0
                             boolean itemHasDisapproves = false;
 502  0
                             boolean itemHasCancels = false;
 503  0
                             boolean itemHasAcknowledges = false;
 504  0
                             boolean itemHasFyis = false;
 505  0
                             boolean itemHasCustomActions = false;
 506  0
                             CustomActionListAttribute customActionListAttribute = actionItem.getRouteHeader().getCustomActionListAttribute();
 507  0
                             if (customActionListAttribute != null) {
 508  0
                                     Map customActions = new LinkedHashMap();
 509  0
                                     customActions.put("NONE", "NONE");
 510  0
                                     ActionSet legalActions = customActionListAttribute.getLegalActions(UserSession.getAuthenticatedUser(), actionItem);
 511  0
                                     if (legalActions != null && legalActions.hasApprove() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_APPROVED_CD)) {
 512  0
                                             customActions.put(KEWConstants.ACTION_TAKEN_APPROVED_CD, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
 513  0
                                             itemHasApproves = true;
 514  
                                     }
 515  0
                                     if (legalActions != null && legalActions.hasDisapprove() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_DENIED_CD)) {
 516  0
                                             customActions.put(KEWConstants.ACTION_TAKEN_DENIED_CD, KEWConstants.ACTION_REQUEST_DISAPPROVE_LABEL);
 517  0
                                             itemHasDisapproves = true;
 518  
                                     }
 519  0
                                     if (legalActions != null && legalActions.hasCancel() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_CANCELED_CD)) {
 520  0
                                             customActions.put(KEWConstants.ACTION_TAKEN_CANCELED_CD, KEWConstants.ACTION_REQUEST_CANCEL_REQ_LABEL);
 521  0
                                             itemHasCancels = true;
 522  
                                     }
 523  0
                                     if (legalActions != null && legalActions.hasAcknowledge() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD)) {
 524  0
                                             customActions.put(KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
 525  0
                                             itemHasAcknowledges = true;
 526  
                                     }
 527  0
                                     if (legalActions != null && legalActions.hasFyi() && isActionCompatibleRequest(actionItem, KEWConstants.ACTION_TAKEN_FYI_CD) && KEWConstants.PREFERENCES_YES_VAL.equalsIgnoreCase(preferences.getShowClearFyi())) {
 528  0
                                             customActions.put(KEWConstants.ACTION_TAKEN_FYI_CD, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL);
 529  0
                                             itemHasFyis = true;
 530  
                                     }
 531  0
                                     if (customActions.size() > 1) {
 532  0
                                             actionItem.setCustomActions(customActions);
 533  0
                                             itemHasCustomActions = true;
 534  
                                     }
 535  0
                                     actionItem.setDisplayParameters(customActionListAttribute.getDocHandlerDisplayParameters(UserSession.getAuthenticatedUser(), actionItem));
 536  0
                                     haveApproves = haveApproves || itemHasApproves;
 537  0
                                     haveAcknowledges = haveAcknowledges || itemHasAcknowledges;
 538  0
                                     haveFyis = haveFyis || itemHasFyis;
 539  0
                                     haveDisapproves = haveDisapproves || itemHasDisapproves;
 540  0
                                     haveCancels = haveCancels || itemHasCancels;
 541  0
                                     haveCustomActions = haveCustomActions || itemHasCustomActions;
 542  0
                                     haveDisplayParameters = haveDisplayParameters || (actionItem.getDisplayParameters() != null);
 543  
                             }
 544  0
                     } catch (Exception e) {
 545  
                             // if there's a problem loading the custom action list attribute, let's go ahead and display the vanilla action item
 546  0
                             LOG.error("Problem loading custom action list attribute", e);
 547  0
                             customActionListProblemIds.add(actionItem.getRouteHeaderId());
 548  0
                     }
 549  0
                     currentPage.add(actionItem);
 550  
             }
 551  
 
 552  
             // configure custom actions on form
 553  0
             form.setHasCustomActions(Boolean.valueOf(haveCustomActions));
 554  0
             Map defaultActions = new LinkedHashMap();
 555  0
             defaultActions.put("NONE", "NONE");
 556  0
             if (haveApproves) {
 557  0
                     defaultActions.put(KEWConstants.ACTION_TAKEN_APPROVED_CD, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
 558  0
                     form.setCustomActionList(Boolean.TRUE);
 559  
             }
 560  0
             if (haveDisapproves) {
 561  0
                     defaultActions.put(KEWConstants.ACTION_TAKEN_DENIED_CD, KEWConstants.ACTION_REQUEST_DISAPPROVE_LABEL);
 562  0
                     form.setCustomActionList(Boolean.TRUE);
 563  
             }
 564  0
             if (haveCancels) {
 565  0
                     defaultActions.put(KEWConstants.ACTION_TAKEN_CANCELED_CD, KEWConstants.ACTION_REQUEST_CANCEL_REQ_LABEL);
 566  0
                     form.setCustomActionList(Boolean.TRUE);
 567  
             }
 568  0
             if (haveAcknowledges) {
 569  0
                     defaultActions.put(KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
 570  0
                     form.setCustomActionList(Boolean.TRUE);
 571  
             }
 572  
             //clearing FYI's can be done in any action list not just a customized one
 573  0
             if (haveFyis && KEWConstants.PREFERENCES_YES_VAL.equalsIgnoreCase(preferences.getShowClearFyi())) {
 574  0
                     defaultActions.put(KEWConstants.ACTION_TAKEN_FYI_CD, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL);
 575  
             }
 576  0
             if (defaultActions.size() > 1) {
 577  0
                     form.setDefaultActions(defaultActions);
 578  
             }
 579  
 
 580  0
                    form.setHasDisplayParameters(haveDisplayParameters);
 581  
             
 582  0
             generateActionItemErrors(CUSTOMACTIONLIST_PROP, ACTIONLIST_BAD_CUSTOM_ACTION_LIST_ITEMS_ERRKEY, customActionListProblemIds);
 583  0
             return new PaginatedActionList(currentPage, actionList.size(), page.intValue(), pageSize, "actionList", sortCriterion, sortOrder);
 584  
     }
 585  
 
 586  
     private void generateActionItemErrors(String propertyName, String errorKey, List documentIds) {
 587  0
             if (!documentIds.isEmpty()) {
 588  0
                     String documentIdsString = StringUtils.join(documentIds.iterator(), ", ");
 589  0
                     GlobalVariables.getMessageMap().putError(propertyName, errorKey, documentIdsString);
 590  
             }
 591  0
     }
 592  
     
 593  
     private void generateActionItemErrors(List actionList) {
 594  0
             for (Iterator iterator = actionList.iterator(); iterator.hasNext();) {
 595  0
                     ActionItemActionListExtension actionItem = (ActionItemActionListExtension)iterator.next();
 596  
                     
 597  
                     // removing this check for the time being, it hinders action list performance. (KULRICE-2931)
 598  
 //                    if (KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getRouteHeaderId()) == null) {
 599  
 //                            GlobalVariables.getErrorMap().putError(ROUTEHEADERID_PROP, ACTIONITEM_ROUTEHEADERID_INVALID_ERRKEY,actionItem.getActionItemId()+"");
 600  
 //                    }
 601  
                     
 602  0
                     if(!KEWConstants.ACTION_REQUEST_CODES.containsKey(actionItem.getActionRequestCd())) {
 603  0
                             GlobalVariables.getMessageMap().putError(ACTIONREQUESTCD_PROP,ACTIONITEM_ACTIONREQUESTCD_INVALID_ERRKEY,actionItem.getActionItemId()+"");
 604  
                     }
 605  0
              }
 606  0
     }
 607  
 
 608  
 
 609  
     public ActionForward takeMassActions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 610  0
         ActionListForm actionListForm = (ActionListForm) form;
 611  0
         List actionList = (List) request.getSession().getAttribute(ACTION_LIST_KEY);
 612  0
         if (actionList == null) {
 613  0
             return start(mapping, new ActionListForm(), request, response);
 614  
         }
 615  0
         ActionMessages messages = new ActionMessages();
 616  0
         List invocations = new ArrayList();
 617  0
         int index = 0;
 618  0
         for (Iterator iterator = actionListForm.getActionsToTake().iterator(); iterator.hasNext();) {
 619  0
                 ActionToTake actionToTake = (ActionToTake) iterator.next();
 620  0
                 if (actionToTake != null && actionToTake.getActionTakenCd() != null &&
 621  
                                 !"".equals(actionToTake.getActionTakenCd()) &&
 622  
                                 !"NONE".equalsIgnoreCase(actionToTake.getActionTakenCd()) &&
 623  
                                 actionToTake.getActionItemId() != null) {
 624  0
                         ActionItem actionItem = getActionItemFromActionList(actionList, actionToTake.getActionItemId());
 625  0
                         if (actionItem == null) {
 626  0
                                 LOG.warn("Could not locate the ActionItem to take mass action against in the action list: " + actionToTake.getActionItemId());
 627  0
                                 continue;
 628  
                         }
 629  0
                     invocations.add(new ActionInvocation(actionItem.getActionItemId(), actionToTake.getActionTakenCd()));
 630  
             }
 631  0
                 index++;
 632  0
                 }
 633  0
         KEWServiceLocator.getWorkflowDocumentService().takeMassActions(getUserSession(request).getPrincipalId(), invocations);
 634  0
         messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.routing.processed"));
 635  0
         saveMessages(request, messages);
 636  0
         ActionListForm cleanForm = new ActionListForm();
 637  0
         request.setAttribute(mapping.getName(), cleanForm);
 638  0
         request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true");
 639  0
         return start(mapping, cleanForm, request, response);
 640  
     }
 641  
 
 642  
     protected ActionItem getActionItemFromActionList(List actionList, Long actionItemId) {
 643  0
             for (Iterator iterator = actionList.iterator(); iterator.hasNext();) {
 644  0
                         ActionItem actionItem = (ActionItem) iterator.next();
 645  0
                         if (actionItem.getActionItemId().equals(actionItemId)) {
 646  0
                                 return actionItem;
 647  
                         }
 648  0
                 }
 649  0
             return null;
 650  
     }
 651  
 
 652  
     public ActionForward helpDeskActionListLogin(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 653  0
         ActionListForm actionListForm = (ActionListForm) form;
 654  0
         String name = actionListForm.getHelpDeskActionListUserName();
 655  0
         if (!"true".equals(request.getAttribute("helpDeskActionList"))) {
 656  0
                 throw new AuthorizationException(UserSession.getAuthenticatedUser().getPrincipalId(), "helpDeskActionListLogin", getClass().getSimpleName());
 657  
         }
 658  
         try
 659  
         {
 660  0
                 getUserSession(request).establishHelpDeskWithPrincipalName(name);
 661  
         }
 662  0
         catch (RiceRuntimeException rre)
 663  
         {
 664  0
                 GlobalVariables.getMessageMap().putError(HELPDESK_ACTIONLIST_USERNAME, HELPDESK_LOGIN_INVALID_ERRKEY, name);
 665  
         }
 666  0
         catch (NullPointerException npe)
 667  
         {
 668  0
                 GlobalVariables.getMessageMap().putError("null", HELPDESK_LOGIN_EMPTY_ERRKEY, name);
 669  0
         }
 670  0
             actionListForm.setDelegator(null);
 671  0
         request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true");
 672  0
         return start(mapping, form, request, response);
 673  
     }
 674  
 
 675  
     public ActionForward clearFilter(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 676  0
         LOG.debug("clearFilter ActionListAction");
 677  0
         UserSession session = getUserSession(request);
 678  0
         session.setActionListFilter(null);
 679  0
         request.getSession().setAttribute(REQUERY_ACTION_LIST_KEY, "true");
 680  0
         KEWServiceLocator.getActionListService().saveRefreshUserOption(session.getPrincipalId());
 681  0
         LOG.debug("end clearFilter ActionListAction");
 682  0
         return start(mapping, form, request, response);
 683  
     }
 684  
 
 685  
     public ActionForward clearHelpDeskActionListUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 686  0
         LOG.debug("clearHelpDeskActionListUser ActionListAction");
 687  0
         getUserSession(request).clearHelpDesk();
 688  0
         LOG.debug("end clearHelpDeskActionListUser ActionListAction");
 689  0
         return start(mapping, form, request, response);
 690  
     }
 691  
 
 692  
     /**
 693  
      * Generates an Action List count.
 694  
      */
 695  
     public ActionForward count(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 696  0
             ActionListForm alForm = (ActionListForm)form;
 697  0
             Person user = getUserSession(request).getPerson();
 698  0
             alForm.setCount(KEWServiceLocator.getActionListService().getCount(user.getPrincipalId()));
 699  0
             LOG.info("Fetched Action List count of " + alForm.getCount() + " for user " + user.getPrincipalName());
 700  0
             return mapping.findForward("count");
 701  
     }
 702  
 
 703  
     public ActionForward removeOutboxItems(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
 704  0
         ActionListForm alForm = (ActionListForm)form;
 705  0
         if (alForm.getOutboxItems() != null) {
 706  0
             KEWServiceLocator.getActionListService().removeOutboxItems(getUserSession(request).getPrincipal().getPrincipalId(), Arrays.asList(alForm.getOutboxItems()));
 707  
         }
 708  
 
 709  0
         alForm.setViewOutbox("true");
 710  0
         return start(mapping, form, request, response);
 711  
     }
 712  
 
 713  
     /**
 714  
      * Navigate to the Action List Filter page, preserving any newly-modified primary/secondary delegation filters as necessary.
 715  
      */
 716  
     public ActionForward viewFilter(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
 717  0
             start(mapping, actionForm, request, response);
 718  0
             return mapping.findForward("viewFilter");
 719  
     }
 720  
     
 721  
     /**
 722  
      * Navigate to the user's Preferences page, preserving any newly-modified primary/secondary delegation filters as necessary.
 723  
      */
 724  
     public ActionForward viewPreferences(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws Exception {
 725  0
             start(mapping, actionForm, request, response);
 726  0
             return mapping.findForward("viewPreferences");
 727  
     }
 728  
     
 729  
     private boolean isActionCompatibleRequest(ActionItemActionListExtension actionItem, String actionTakenCode) {
 730  0
         boolean actionCompatible = false;
 731  0
         String requestCd = actionItem.getActionRequestCd();
 732  
 
 733  
         //FYI request matches FYI
 734  0
         if (KEWConstants.ACTION_REQUEST_FYI_REQ.equals(requestCd) && KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode)) {
 735  0
             actionCompatible = true || actionCompatible;
 736  
         }
 737  
 
 738  
         // ACK request matches ACK
 739  0
         if (KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ.equals(requestCd) && KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode)) {
 740  0
             actionCompatible = true || actionCompatible;
 741  
         }
 742  
 
 743  
         // APPROVE request matches all but FYI and ACK
 744  0
         if (KEWConstants.ACTION_REQUEST_APPROVE_REQ.equals(requestCd) && !(KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) {
 745  0
             actionCompatible = true || actionCompatible;
 746  
         }
 747  
 
 748  
         // COMPLETE request matches all but FYI and ACK
 749  0
         if (KEWConstants.ACTION_REQUEST_COMPLETE_REQ.equals(requestCd) && !(KEWConstants.ACTION_TAKEN_FYI_CD.equals(actionTakenCode) || KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD.equals(actionTakenCode))) {
 750  0
             actionCompatible = true || actionCompatible;
 751  
         }
 752  
 
 753  0
         return actionCompatible;
 754  
     }
 755  
 
 756  
     private List getWebFriendlyRecipients(Collection recipients) {
 757  0
         Collection newRecipients = new ArrayList(recipients.size());
 758  0
         for (Iterator iterator = recipients.iterator(); iterator.hasNext();) {
 759  0
             newRecipients.add(new WebFriendlyRecipient(iterator.next()));
 760  
         }
 761  0
         List recipientList = new ArrayList(newRecipients);
 762  0
         Collections.sort(recipientList, new Comparator() {
 763  0
             Comparator comp = new ComparableComparator();
 764  
 
 765  
             public int compare(Object o1, Object o2) {
 766  0
                 return comp.compare(((WebFriendlyRecipient) o1).getDisplayName().trim().toLowerCase(), ((WebFriendlyRecipient) o2).getDisplayName().trim().toLowerCase());
 767  
             }
 768  
         });
 769  0
         return recipientList;
 770  
     }
 771  
 
 772  
         private UserSession getUserSession(HttpServletRequest request){
 773  0
                 return UserSession.getAuthenticatedUser();
 774  
         }
 775  
 
 776  0
     private static class ActionItemComparator implements Comparator {
 777  
 
 778  
             private static final String DOCUMENT_ID = "routeHeaderId";
 779  
 
 780  
             private final String sortName;
 781  
 
 782  0
             public ActionItemComparator(String sortName) {
 783  0
                     if (StringUtils.isEmpty(sortName)) {
 784  0
                             sortName = DOCUMENT_ID;
 785  
                     }
 786  0
                     this.sortName = sortName;
 787  0
             }
 788  
 
 789  
                 public int compare(Object object1, Object object2) {
 790  
                         try {
 791  0
                                 ActionItem actionItem1 = (ActionItem)object1;
 792  0
                                 ActionItem actionItem2 = (ActionItem)object2;
 793  
                                 // invoke the power of the lookup functionality provided by the display tag library, this LookupUtil method allows for us
 794  
                                 // to evaulate nested bean properties (like workgroup.groupNameId.nameId) in a null-safe manner.  For example, in the
 795  
                                 // example if workgroup evaluated to NULL then LookupUtil.getProperty would return null rather than blowing an exception
 796  0
                                 Object property1 = LookupUtil.getProperty(actionItem1, sortName);
 797  0
                                 Object property2 = LookupUtil.getProperty(actionItem2, sortName);
 798  0
                                 if (property1 == null && property2 == null) {
 799  0
                                         return 0;
 800  0
                                 } else if (property1 == null) {
 801  0
                                         return -1;
 802  0
                                 } else if (property2 == null) {
 803  0
                                         return 1;
 804  
                                 }
 805  0
                                 if (property1 instanceof Comparable) {
 806  0
                                         return ((Comparable)property1).compareTo(property2);
 807  
                                 }
 808  0
                                 return property1.toString().compareTo(property2.toString());
 809  0
                         } catch (Exception e) {
 810  0
                                 if (e instanceof RuntimeException) {
 811  0
                                         throw (RuntimeException) e;
 812  
                                 }
 813  0
                                 throw new RuntimeException("Could not sort for the given sort name: " + sortName, e);
 814  
                         }
 815  
                 }
 816  
     }
 817  
 
 818  
 }