1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
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 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class ActionInvocationProcessor implements ActionInvocationService { |
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 | |
} |