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