Coverage Report - org.kuali.rice.kew.actions.asyncservices.ActionInvocationProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionInvocationProcessor
0%
0/21
0%
0/4
7
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in
 6  
  * compliance with the License. You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS
 11  
  * IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
 12  
  * language governing permissions and limitations under the License.
 13  
  */
 14  
 package org.kuali.rice.kew.actions.asyncservices;
 15  
 
 16  
 import java.util.ArrayList;
 17  
 import java.util.List;
 18  
 
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.reflect.DataDefinition;
 21  
 import org.kuali.rice.kew.actions.ActionTakenEvent;
 22  
 import org.kuali.rice.kew.exception.WorkflowRuntimeException;
 23  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 24  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 25  
 import org.kuali.rice.kim.bo.entity.KimPrincipal;
 26  
 
 27  
 
 28  
 /**
 29  
  * Service for doing the actual work of a mass action in the action list. Represents a single action on a single document.
 30  
  *
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 32  
  */
 33  0
 public class ActionInvocationProcessor implements ActionInvocationService { // implements RouteQueueProcessor {
 34  
 
 35  0
     private static final Logger LOG = Logger.getLogger(ActionInvocationProcessor.class);
 36  
 
 37  
     public void invokeAction(String principalId, Long documentId, ActionInvocation invocation) {
 38  
 
 39  0
         KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
 40  0
         DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
 41  
 
 42  0
         KimPrincipal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
 43  0
         List<DataDefinition> parameters = new ArrayList<DataDefinition>();
 44  0
         parameters.add(new DataDefinition(document));
 45  0
         parameters.add(new DataDefinition(principal));
 46  0
         parameters.add(new DataDefinition(""));
 47  
         ActionTakenEvent action;
 48  
         try {
 49  0
             action = KEWServiceLocator.getActionRegistry().createAction(invocation.getActionCode(), parameters);
 50  0
             if (!document.isValidActionToTake(invocation.getActionCode())) {
 51  0
                 LOG.warn("Action " + invocation.getActionCode() + " is not a valid action to take against document " + document.getRouteHeaderId() + " by principal with name '" + principal.getPrincipalName() + "'");
 52  0
                 return;
 53  0
             } else if (!KEWServiceLocator.getActionRegistry().getValidActions(principal, document).getActionTakenCodes().contains(action.getActionTakenCode())) {
 54  0
                 LOG.warn("Action " + action.getActionTakenCode() + " is not valid for document " + document.getRouteHeaderId() + " by principal with name '" + principal.getPrincipalName() + "'");
 55  0
                 return;
 56  
             }
 57  0
             action.performAction();
 58  0
         } catch (Exception e) {
 59  0
             throw new WorkflowRuntimeException(e);
 60  0
         }
 61  
 
 62  0
     }
 63  
 
 64  
 }