1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.actions.asyncservices;
18
19 import java.util.Set;
20
21 import org.kuali.rice.kew.actions.BlanketApproveAction;
22 import org.kuali.rice.kew.actiontaken.ActionTakenValue;
23 import org.kuali.rice.kew.api.KewApiServiceLocator;
24 import org.kuali.rice.kew.api.WorkflowRuntimeException;
25 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
26 import org.kuali.rice.kew.messaging.MessageServiceNames;
27 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
28 import org.kuali.rice.kew.service.KEWServiceLocator;
29 import org.kuali.rice.kim.api.identity.principal.Principal;
30
31
32
33
34
35
36
37
38 public class BlanketApproveProcessor implements BlanketApproveProcessorService {
39
40 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(BlanketApproveProcessor.class);
41
42 public void doBlanketApproveWork(String documentId, String principalId, String actionTakenId, Set<String> nodeNames) {
43 doBlanketApproveWork(documentId, principalId, actionTakenId, nodeNames, false);
44 }
45
46 public void doBlanketApproveWork(String documentId, String principalId, String actionTakenId, Set<String> nodeNames, boolean shouldSearchIndex) {
47 KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentId, true);
48 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId);
49 ActionTakenValue actionTaken = KEWServiceLocator.getActionTakenService().findByActionTakenId(actionTakenId);
50 Principal principal = KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
51 BlanketApproveAction blanketApprove = new BlanketApproveAction(document, principal, "", nodeNames);
52 LOG.debug("Doing blanket approve work document " + document.getDocumentId());
53 try {
54 blanketApprove.performDeferredBlanketApproveWork(actionTaken);
55 } catch (Exception e) {
56 throw new WorkflowRuntimeException(e);
57 }
58 if (shouldSearchIndex) {
59 DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(document.getDocumentType().getApplicationId());
60 queue.indexDocument(documentId);
61 }
62 LOG.debug("Work done and document requeued, document " + document.getDocumentId());
63 }
64 }