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