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.api.reflect.DataDefinition;
 21  
 import org.kuali.rice.kew.actions.ActionTakenEvent;
 22  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 23  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 24  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 25  
 import org.kuali.rice.kim.api.identity.principal.Principal;
 26  
 
 27  
 
 28  
 
 29  
 /**
 30  
  * Service for doing the actual work of a mass action in the action list. Represents a single action on a single document.
 31  
  *
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  */
 34  0
 public class ActionInvocationProcessor implements ActionInvocationService { // implements RouteQueueProcessor {
 35  
 
 36  0
     private static final Logger LOG = Logger.getLogger(ActionInvocationProcessor.class);
 37  
 
 38  
     public void invokeAction(String principalId, String documentId, ActionInvocation invocation) {
 39  
 
 40  0
         KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
 41  0
         DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
 42  
 
 43  0
         Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
 44  0
         List<DataDefinition> parameters = new ArrayList<DataDefinition>();
 45  0
         parameters.add(new DataDefinition(document));
 46  0
         parameters.add(new DataDefinition(principal));
 47  0
         parameters.add(new DataDefinition(""));
 48  
         ActionTakenEvent action;
 49  
         try {
 50  0
             action = KEWServiceLocator.getActionRegistry().createAction(invocation.getActionCode(), parameters);
 51  0
             if (!document.isValidActionToTake(invocation.getActionCode())) {
 52  0
                 LOG.warn("Action " + invocation.getActionCode() + " is not a valid action to take against document " + document.getDocumentId() + " by principal with name '" + principal.getPrincipalName() + "'");
 53  0
                 return;
 54  0
             } else if (!KEWServiceLocator.getActionRegistry().getValidActions(principal, document).getActionTakenCodes().contains(action.getActionTakenCode())) {
 55  0
                 LOG.warn("Action " + action.getActionTakenCode() + " is not valid for document " + document.getDocumentId() + " by principal with name '" + principal.getPrincipalName() + "'");
 56  0
                 return;
 57  
             }
 58  0
             action.performAction();
 59  0
         } catch (Exception e) {
 60  0
             throw new WorkflowRuntimeException(e);
 61  0
         }
 62  
 
 63  0
     }
 64  
 
 65  
 }