1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.routeheader.service.impl;
17
18 import org.kuali.rice.core.api.exception.RiceRuntimeException;
19 import org.kuali.rice.kew.actionitem.ActionItem;
20 import org.kuali.rice.kew.actionrequest.KimGroupRecipient;
21 import org.kuali.rice.kew.actionrequest.Recipient;
22 import org.kuali.rice.kew.actions.AcknowledgeAction;
23 import org.kuali.rice.kew.actions.ActionTakenEvent;
24 import org.kuali.rice.kew.actions.AdHocAction;
25 import org.kuali.rice.kew.actions.ApproveAction;
26 import org.kuali.rice.kew.actions.BlanketApproveAction;
27 import org.kuali.rice.kew.actions.CancelAction;
28 import org.kuali.rice.kew.actions.ClearFYIAction;
29 import org.kuali.rice.kew.actions.CompleteAction;
30 import org.kuali.rice.kew.actions.DisapproveAction;
31 import org.kuali.rice.kew.actions.LogDocumentActionAction;
32 import org.kuali.rice.kew.actions.MoveDocumentAction;
33 import org.kuali.rice.kew.actions.RecallAction;
34 import org.kuali.rice.kew.actions.ReleaseWorkgroupAuthority;
35 import org.kuali.rice.kew.actions.ReturnToPreviousNodeAction;
36 import org.kuali.rice.kew.actions.RevokeAdHocAction;
37 import org.kuali.rice.kew.actions.RouteDocumentAction;
38 import org.kuali.rice.kew.actions.SaveActionEvent;
39 import org.kuali.rice.kew.actions.SuperUserActionRequestApproveEvent;
40 import org.kuali.rice.kew.actions.SuperUserApproveEvent;
41 import org.kuali.rice.kew.actions.SuperUserCancelEvent;
42 import org.kuali.rice.kew.actions.SuperUserDisapproveEvent;
43 import org.kuali.rice.kew.actions.SuperUserNodeApproveEvent;
44 import org.kuali.rice.kew.actions.SuperUserReturnToPreviousNodeAction;
45 import org.kuali.rice.kew.actions.TakeWorkgroupAuthority;
46 import org.kuali.rice.kew.api.action.ActionInvocation;
47 import org.kuali.rice.kew.api.action.ActionInvocationQueue;
48 import org.kuali.rice.kew.actiontaken.ActionTakenValue;
49 import org.kuali.rice.kew.api.KewApiConstants;
50 import org.kuali.rice.kew.api.KewApiServiceLocator;
51 import org.kuali.rice.kew.api.WorkflowRuntimeException;
52 import org.kuali.rice.kew.api.action.AdHocRevoke;
53 import org.kuali.rice.kew.api.action.MovePoint;
54 import org.kuali.rice.kew.api.doctype.IllegalDocumentTypeException;
55 import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue;
56 import org.kuali.rice.kew.api.exception.InvalidActionTakenException;
57 import org.kuali.rice.kew.api.exception.WorkflowException;
58 import org.kuali.rice.kew.engine.CompatUtils;
59 import org.kuali.rice.kew.engine.OrchestrationConfig;
60 import org.kuali.rice.kew.engine.RouteContext;
61 import org.kuali.rice.kew.engine.OrchestrationConfig.EngineCapability;
62 import org.kuali.rice.kew.engine.node.RouteNode;
63 import org.kuali.rice.kew.framework.postprocessor.PostProcessor;
64 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
65 import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService;
66 import org.kuali.rice.kew.service.KEWServiceLocator;
67 import org.kuali.rice.kim.api.identity.principal.Principal;
68 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
69
70 import java.sql.Timestamp;
71 import java.util.Collections;
72 import java.util.Date;
73 import java.util.HashSet;
74 import java.util.List;
75 import java.util.Set;
76
77
78
79
80
81
82
83
84 public class WorkflowDocumentServiceImpl implements WorkflowDocumentService {
85
86 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(WorkflowDocumentServiceImpl.class);
87
88 private void init(DocumentRouteHeaderValue routeHeader) {
89 KEWServiceLocator.getRouteHeaderService().lockRouteHeader(routeHeader.getDocumentId(), true);
90 KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader);
91 }
92
93 private DocumentRouteHeaderValue finish(DocumentRouteHeaderValue routeHeader) {
94
95
96 if (RouteContext.getCurrentRouteContext().getDocument() == null) {
97 return KEWServiceLocator.getRouteHeaderService().getRouteHeader(routeHeader.getDocumentId(), true);
98 } else {
99
100
101
102
103 return routeHeader;
104 }
105 }
106
107 public DocumentRouteHeaderValue acknowledgeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
108 Principal principal = loadPrincipal(principalId);
109 AcknowledgeAction action = new AcknowledgeAction(routeHeader, principal, annotation);
110 action.performAction();
111 return finish(routeHeader);
112 }
113
114 public DocumentRouteHeaderValue releaseGroupAuthority(String principalId, DocumentRouteHeaderValue routeHeader, String groupId, String annotation) throws InvalidActionTakenException {
115 Principal principal = loadPrincipal(principalId);
116 ReleaseWorkgroupAuthority action = new ReleaseWorkgroupAuthority(routeHeader, principal, annotation, groupId);
117 action.performAction();
118 return finish(routeHeader);
119 }
120
121 public DocumentRouteHeaderValue takeGroupAuthority(String principalId, DocumentRouteHeaderValue routeHeader, String groupId, String annotation) throws InvalidActionTakenException {
122 Principal principal = loadPrincipal(principalId);
123 TakeWorkgroupAuthority action = new TakeWorkgroupAuthority(routeHeader, principal, annotation, groupId);
124 action.performAction();
125 return finish(routeHeader);
126 }
127
128 public DocumentRouteHeaderValue approveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
129 Principal principal = loadPrincipal(principalId);
130 ApproveAction action = new ApproveAction(routeHeader, principal, annotation);
131 action.performAction();
132 return finish(routeHeader);
133 }
134
135 public DocumentRouteHeaderValue placeInExceptionRouting(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
136 try {
137
138 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRouting(annotation, null, routeHeader.getDocumentId());
139 } catch (Exception e) {
140 throw new RiceRuntimeException("Failed to place the document into exception routing!", e);
141 }
142 return finish(routeHeader);
143 }
144
145 public DocumentRouteHeaderValue adHocRouteDocumentToPrincipal(String principalId, DocumentRouteHeaderValue document, String actionRequested, String nodeName, Integer priority, String annotation, String targetPrincipalId,
146 String responsibilityDesc, Boolean forceAction, String requestLabel) throws WorkflowException {
147 Principal principal = loadPrincipal(principalId);
148 Recipient recipient = KEWServiceLocator.getIdentityHelperService().getPrincipalRecipient(targetPrincipalId);
149 AdHocAction action = new AdHocAction(document, principal, annotation, actionRequested, nodeName, priority, recipient, responsibilityDesc, forceAction, requestLabel);
150 action.performAction();
151 return finish(document);
152 }
153
154 public DocumentRouteHeaderValue adHocRouteDocumentToGroup(String principalId, DocumentRouteHeaderValue document, String actionRequested, String nodeName, Integer priority, String annotation, String groupId,
155 String responsibilityDesc, Boolean forceAction, String requestLabel) throws WorkflowException {
156 Principal principal = loadPrincipal(principalId);
157 final Recipient recipient = new KimGroupRecipient(KimApiServiceLocator.getGroupService().getGroup(groupId));
158 AdHocAction action = new AdHocAction(document, principal, annotation, actionRequested, nodeName, priority, recipient, responsibilityDesc, forceAction, requestLabel);
159 action.performAction();
160 return finish(document);
161 }
162
163 public DocumentRouteHeaderValue blanketApproval(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, Integer routeLevel) throws InvalidActionTakenException {
164 RouteNode node = (routeLevel == null ? null : CompatUtils.getNodeForLevel(routeHeader.getDocumentType(), routeLevel));
165 if (node == null && routeLevel != null) {
166 throw new InvalidActionTakenException("Could not locate node for route level " + routeLevel);
167 }
168 Set<String> nodeNames = new HashSet<String>();
169 if (node != null) {
170 nodeNames = Collections.singleton(node.getRouteNodeName());
171 }
172 Principal principal = loadPrincipal(principalId);
173 ActionTakenEvent action = new BlanketApproveAction(routeHeader, principal, annotation, nodeNames);
174 action.performAction();
175 return finish(routeHeader);
176 }
177
178 public DocumentRouteHeaderValue blanketApproval(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, Set nodeNames) throws InvalidActionTakenException {
179 Principal principal = loadPrincipal(principalId);
180 BlanketApproveAction action = new BlanketApproveAction(routeHeader, principal, annotation, nodeNames);
181 action.recordAction();
182
183 return finish(routeHeader);
184 }
185
186 public DocumentRouteHeaderValue cancelDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
187
188 Principal principal = loadPrincipal(principalId);
189 CancelAction action = new CancelAction(routeHeader, principal, annotation);
190 action.recordAction();
191 indexForSearchAfterActionIfNecessary(routeHeader);
192 return finish(routeHeader);
193 }
194
195 public DocumentRouteHeaderValue recallDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean cancel) throws InvalidActionTakenException {
196
197 Principal principal = loadPrincipal(principalId);
198 RecallAction action = new RecallAction(routeHeader, principal, annotation, cancel);
199 action.performAction();
200 indexForSearchAfterActionIfNecessary(routeHeader);
201 return finish(routeHeader);
202 }
203
204
205
206
207
208 protected void indexForSearchAfterActionIfNecessary(DocumentRouteHeaderValue routeHeader) {
209 RouteContext routeContext = RouteContext.getCurrentRouteContext();
210 if (routeHeader.getDocumentType().hasSearchableAttributes() && routeContext.isSearchIndexingRequestedForContext()) {
211 DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(routeHeader.getDocumentType().getApplicationId());
212 queue.indexDocument(routeHeader.getDocumentId());
213 }
214 }
215
216 public DocumentRouteHeaderValue clearFYIDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
217
218 Principal principal = loadPrincipal(principalId);
219 ClearFYIAction action = new ClearFYIAction(routeHeader, principal, annotation);
220 action.recordAction();
221 return finish(routeHeader);
222 }
223
224 public DocumentRouteHeaderValue completeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
225 Principal principal = loadPrincipal(principalId);
226 CompleteAction action = new CompleteAction(routeHeader, principal, annotation);
227 action.performAction();
228 return finish(routeHeader);
229 }
230
231 public DocumentRouteHeaderValue createDocument(String principalId, DocumentRouteHeaderValue routeHeader) throws WorkflowException {
232
233 if (routeHeader.getDocumentId() != null) {
234
235
236 throw new InvalidActionTakenException("Document already has a Document id");
237 }
238 Principal principal = loadPrincipal(principalId);
239 boolean canInitiate = KEWServiceLocator.getDocumentTypePermissionService().canInitiate(principalId, routeHeader.getDocumentType());
240
241 if (!canInitiate) {
242 throw new InvalidActionTakenException("Principal with name '" + principal.getPrincipalName() + "' is not authorized to initiate documents of type '" + routeHeader.getDocumentType().getName());
243 }
244
245 if (!routeHeader.getDocumentType().isDocTypeActive()) {
246
247 throw new IllegalDocumentTypeException("Document type '" + routeHeader.getDocumentType().getName() + "' is inactive");
248 }
249
250 routeHeader.setInitiatorWorkflowId(principalId);
251 if (routeHeader.getDocRouteStatus() == null) {
252 routeHeader.setDocRouteStatus(KewApiConstants.ROUTE_HEADER_INITIATED_CD);
253 }
254 if (routeHeader.getDocRouteLevel() == null) {
255 routeHeader.setDocRouteLevel(Integer.valueOf(KewApiConstants.ADHOC_ROUTE_LEVEL));
256 }
257 if (routeHeader.getCreateDate() == null) {
258 routeHeader.setCreateDate(new Timestamp(new Date().getTime()));
259 }
260 if (routeHeader.getDocVersion() == null) {
261 routeHeader.setDocVersion(Integer.valueOf(KewApiConstants.DocumentContentVersions.CURRENT));
262 }
263 if (routeHeader.getDocContent() == null) {
264 routeHeader.setDocContent(KewApiConstants.DEFAULT_DOCUMENT_CONTENT);
265 }
266 routeHeader.setDateModified(new Timestamp(new Date().getTime()));
267 KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader);
268 OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD);
269 KEWServiceLocator.getWorkflowEngineFactory().newEngine(config).initializeDocument(routeHeader);
270 KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader);
271 return routeHeader;
272 }
273
274 public DocumentRouteHeaderValue disapproveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
275 Principal principal = loadPrincipal(principalId);
276 DisapproveAction action = new DisapproveAction(routeHeader, principal, annotation);
277 action.recordAction();
278 indexForSearchAfterActionIfNecessary(routeHeader);
279 return finish(routeHeader);
280 }
281
282 public DocumentRouteHeaderValue returnDocumentToPreviousRouteLevel(String principalId, DocumentRouteHeaderValue routeHeader, Integer destRouteLevel, String annotation)
283 throws InvalidActionTakenException {
284 DocumentRouteHeaderValue result = null;
285
286 if (destRouteLevel != null) {
287 RouteNode node = CompatUtils.getNodeForLevel(routeHeader.getDocumentType(), destRouteLevel);
288 if (node == null) {
289 throw new InvalidActionTakenException("Could not locate node for route level " + destRouteLevel);
290 }
291
292 Principal principal = loadPrincipal(principalId);
293 ReturnToPreviousNodeAction action = new ReturnToPreviousNodeAction(routeHeader, principal, annotation, node.getRouteNodeName(), true);
294 action.performAction();
295 result = finish(routeHeader);
296 }
297 return result;
298 }
299
300 public DocumentRouteHeaderValue returnDocumentToPreviousNode(String principalId, DocumentRouteHeaderValue routeHeader, String destinationNodeName, String annotation)
301 throws InvalidActionTakenException {
302 Principal principal = loadPrincipal(principalId);
303 ReturnToPreviousNodeAction action = new ReturnToPreviousNodeAction(routeHeader, principal, annotation, destinationNodeName, true);
304 action.performAction();
305 return finish(routeHeader);
306 }
307
308 public DocumentRouteHeaderValue routeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws WorkflowException,
309 InvalidActionTakenException {
310 Principal principal = loadPrincipal(principalId);
311 RouteDocumentAction actionEvent = new RouteDocumentAction(routeHeader, principal, annotation);
312 actionEvent.performAction();
313 LOG.info("routeDocument: " + routeHeader);
314 return finish(routeHeader);
315 }
316
317 public DocumentRouteHeaderValue saveRoutingData(String principalId, DocumentRouteHeaderValue routeHeader) {
318 KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader);
319
320
321 ActionTakenValue val = new ActionTakenValue();
322 val.setActionTaken(KewApiConstants.ACTION_TAKEN_SAVED_CD);
323 val.setDocumentId(routeHeader.getDocumentId());
324 val.setPrincipalId(principalId);
325 PostProcessor postProcessor = routeHeader.getDocumentType().getPostProcessor();
326 try {
327 postProcessor.doActionTaken(new org.kuali.rice.kew.framework.postprocessor.ActionTakenEvent(routeHeader.getDocumentId(), routeHeader.getAppDocId(), ActionTakenValue.to(val)));
328 } catch (Exception e) {
329 if (e instanceof RuntimeException) {
330 throw (RuntimeException)e;
331 }
332 throw new WorkflowRuntimeException(e);
333 }
334
335 RouteContext routeContext = RouteContext.getCurrentRouteContext();
336 if (routeHeader.getDocumentType().hasSearchableAttributes() && !routeContext.isSearchIndexingRequestedForContext()) {
337 routeContext.requestSearchIndexingForContext();
338 DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(routeHeader.getDocumentType().getApplicationId());
339 queue.indexDocument(routeHeader.getDocumentId());
340 }
341 return finish(routeHeader);
342 }
343
344 public DocumentRouteHeaderValue saveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
345 Principal principal = loadPrincipal(principalId);
346 SaveActionEvent action = new SaveActionEvent(routeHeader, principal, annotation);
347 action.performAction();
348 return finish(routeHeader);
349 }
350
351 public void deleteDocument(String principalId, DocumentRouteHeaderValue routeHeader) throws WorkflowException {
352 if (routeHeader.getDocumentId() == null) {
353 LOG.debug("Null Document id passed.");
354 throw new WorkflowException("Document id must not be null.");
355 }
356 KEWServiceLocator.getRouteHeaderService().deleteRouteHeader(routeHeader);
357 }
358
359 public void logDocumentAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException {
360 Principal principal = loadPrincipal(principalId);
361 LogDocumentActionAction action = new LogDocumentActionAction(routeHeader, principal, annotation);
362 action.recordAction();
363 }
364
365 public DocumentRouteHeaderValue moveDocument(String principalId, DocumentRouteHeaderValue routeHeader, MovePoint movePoint, String annotation) throws InvalidActionTakenException {
366 Principal principal = loadPrincipal(principalId);
367 MoveDocumentAction action = new MoveDocumentAction(routeHeader, principal, annotation, movePoint);
368 action.performAction();
369 return finish(routeHeader);
370 }
371
372 public DocumentRouteHeaderValue superUserActionRequestApproveAction(String principalId, DocumentRouteHeaderValue routeHeader, String actionRequestId, String annotation, boolean runPostProcessor)
373 throws InvalidActionTakenException {
374 init(routeHeader);
375 Principal principal = loadPrincipal(principalId);
376 SuperUserActionRequestApproveEvent suActionRequestApprove = new SuperUserActionRequestApproveEvent(routeHeader, principal, actionRequestId, annotation, runPostProcessor);
377 suActionRequestApprove.recordAction();
378
379 RouteContext.getCurrentRouteContext().requestSearchIndexingForContext();
380 indexForSearchAfterActionIfNecessary(routeHeader);
381 return finish(routeHeader);
382 }
383
384
385
386
387
388
389 public DocumentRouteHeaderValue superUserActionRequestApproveAction(String principalId, String documentId, String actionRequestId, String annotation, boolean runPostProcessor)
390 throws InvalidActionTakenException {
391 return superUserActionRequestApproveAction(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), actionRequestId, annotation, runPostProcessor);
392 }
393
394 public DocumentRouteHeaderValue superUserApprove(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException {
395 init(routeHeader);
396 Principal principal = loadPrincipal(principalId);
397 new SuperUserApproveEvent(routeHeader, principal, annotation, runPostProcessor).recordAction();
398 RouteContext.getCurrentRouteContext().requestSearchIndexingForContext();
399 indexForSearchAfterActionIfNecessary(routeHeader);
400 return finish(routeHeader);
401 }
402
403 public DocumentRouteHeaderValue superUserCancelAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException {
404 init(routeHeader);
405 Principal principal = loadPrincipal(principalId);
406 new SuperUserCancelEvent(routeHeader, principal, annotation, runPostProcessor).recordAction();
407 RouteContext.getCurrentRouteContext().requestSearchIndexingForContext();
408 indexForSearchAfterActionIfNecessary(routeHeader);
409 return finish(routeHeader);
410 }
411
412 public DocumentRouteHeaderValue superUserDisapproveAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException {
413 init(routeHeader);
414 Principal principal = loadPrincipal(principalId);
415 new SuperUserDisapproveEvent(routeHeader, principal, annotation, runPostProcessor).recordAction();
416 RouteContext.getCurrentRouteContext().requestSearchIndexingForContext();
417 indexForSearchAfterActionIfNecessary(routeHeader);
418 return finish(routeHeader);
419 }
420
421 public DocumentRouteHeaderValue superUserNodeApproveAction(String principalId, DocumentRouteHeaderValue routeHeader, String nodeName, String annotation, boolean runPostProcessor) throws InvalidActionTakenException {
422 init(routeHeader);
423 Principal principal = loadPrincipal(principalId);
424 new SuperUserNodeApproveEvent(routeHeader, principal, annotation, runPostProcessor, nodeName).recordAction();
425 indexForSearchAfterActionIfNecessary(routeHeader);
426 return finish(routeHeader);
427 }
428
429
430
431
432
433
434 public DocumentRouteHeaderValue superUserNodeApproveAction(String principalId, String documentId, String nodeName, String annotation, boolean runPostProcessor) throws InvalidActionTakenException {
435 return superUserNodeApproveAction(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), nodeName, annotation, runPostProcessor);
436 }
437
438
439
440
441
442
443
444 public DocumentRouteHeaderValue superUserReturnDocumentToPreviousNode(String principalId, String documentId, String nodeName, String annotation, boolean runPostProcessor)
445 throws InvalidActionTakenException {
446 return superUserReturnDocumentToPreviousNode(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), nodeName, annotation, runPostProcessor);
447 }
448
449 public DocumentRouteHeaderValue superUserReturnDocumentToPreviousNode(String principalId, DocumentRouteHeaderValue routeHeader, String nodeName, String annotation, boolean runPostProcessor)
450 throws InvalidActionTakenException {
451 init(routeHeader);
452 Principal principal = loadPrincipal(principalId);
453 SuperUserReturnToPreviousNodeAction action = new SuperUserReturnToPreviousNodeAction(routeHeader, principal, annotation, runPostProcessor, nodeName);
454 action.recordAction();
455 RouteContext.getCurrentRouteContext().requestSearchIndexingForContext();
456 indexForSearchAfterActionIfNecessary(routeHeader);
457 return finish(routeHeader);
458 }
459
460 public void takeMassActions(String principalId, List<ActionInvocation> actionInvocations) {
461 Principal principal = loadPrincipal(principalId);
462 for (ActionInvocation invocation : actionInvocations) {
463 ActionItem actionItem = KEWServiceLocator.getActionListService().findByActionItemId(invocation.getActionItemId());
464 if (actionItem == null) {
465 LOG.warn("Could not locate action item for the given action item id [" + invocation.getActionItemId() + "], not taking mass action on it.");
466 continue;
467 }
468 KEWServiceLocator.getActionListService().deleteActionItem(actionItem, true);
469 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId());
470 String applicationId = document.getDocumentType().getApplicationId();
471 ActionInvocationQueue actionInvocQueue = KewApiServiceLocator.getActionInvocationProcessorService(
472 document.getDocumentId(), applicationId);
473 actionInvocQueue.invokeAction(principalId, actionItem.getDocumentId(), invocation);
474
475 }
476 }
477
478 public DocumentRouteHeaderValue revokeAdHocRequests(String principalId, DocumentRouteHeaderValue document, AdHocRevoke revoke, String annotation) throws InvalidActionTakenException {
479 Principal principal = loadPrincipal(principalId);
480 RevokeAdHocAction action = new RevokeAdHocAction(document, principal, revoke, annotation);
481 action.performAction();
482 return finish(document);
483 }
484
485 public DocumentRouteHeaderValue revokeAdHocRequests(String principalId, DocumentRouteHeaderValue document, String actionRequestId, String annotation) throws InvalidActionTakenException {
486 Principal principal = loadPrincipal(principalId);
487 RevokeAdHocAction action = new RevokeAdHocAction(document, principal, actionRequestId, annotation);
488 action.performAction();
489 return finish(document);
490 }
491
492 protected Principal loadPrincipal(String principalId) {
493 return KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId);
494 }
495
496 }