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 java.sql.Timestamp; |
20 | |
import java.util.Date; |
21 | |
import java.util.HashSet; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.List; |
24 | |
import java.util.Set; |
25 | |
|
26 | |
import org.kuali.rice.core.exception.RiceRuntimeException; |
27 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
28 | |
import org.kuali.rice.kew.actionrequest.Recipient; |
29 | |
import org.kuali.rice.kew.actions.AcknowledgeAction; |
30 | |
import org.kuali.rice.kew.actions.ActionTakenEvent; |
31 | |
import org.kuali.rice.kew.actions.AdHocAction; |
32 | |
import org.kuali.rice.kew.actions.AdHocRevoke; |
33 | |
import org.kuali.rice.kew.actions.ApproveAction; |
34 | |
import org.kuali.rice.kew.actions.BlanketApproveAction; |
35 | |
import org.kuali.rice.kew.actions.CancelAction; |
36 | |
import org.kuali.rice.kew.actions.ClearFYIAction; |
37 | |
import org.kuali.rice.kew.actions.CompleteAction; |
38 | |
import org.kuali.rice.kew.actions.DisapproveAction; |
39 | |
import org.kuali.rice.kew.actions.LogDocumentActionAction; |
40 | |
import org.kuali.rice.kew.actions.MoveDocumentAction; |
41 | |
import org.kuali.rice.kew.actions.MovePoint; |
42 | |
import org.kuali.rice.kew.actions.ReleaseWorkgroupAuthority; |
43 | |
import org.kuali.rice.kew.actions.ReturnToPreviousNodeAction; |
44 | |
import org.kuali.rice.kew.actions.RevokeAdHocAction; |
45 | |
import org.kuali.rice.kew.actions.RouteDocumentAction; |
46 | |
import org.kuali.rice.kew.actions.SaveActionEvent; |
47 | |
import org.kuali.rice.kew.actions.SuperUserActionRequestApproveEvent; |
48 | |
import org.kuali.rice.kew.actions.SuperUserApproveEvent; |
49 | |
import org.kuali.rice.kew.actions.SuperUserCancelEvent; |
50 | |
import org.kuali.rice.kew.actions.SuperUserDisapproveEvent; |
51 | |
import org.kuali.rice.kew.actions.SuperUserNodeApproveEvent; |
52 | |
import org.kuali.rice.kew.actions.SuperUserReturnToPreviousNodeAction; |
53 | |
import org.kuali.rice.kew.actions.TakeWorkgroupAuthority; |
54 | |
import org.kuali.rice.kew.actions.asyncservices.ActionInvocation; |
55 | |
import org.kuali.rice.kew.actions.asyncservices.ActionInvocationService; |
56 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
57 | |
import org.kuali.rice.kew.docsearch.service.SearchableAttributeProcessingService; |
58 | |
import org.kuali.rice.kew.engine.CompatUtils; |
59 | |
import org.kuali.rice.kew.engine.RouteContext; |
60 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
61 | |
import org.kuali.rice.kew.exception.DocumentTypeNotFoundException; |
62 | |
import org.kuali.rice.kew.exception.InvalidActionTakenException; |
63 | |
import org.kuali.rice.kew.exception.WorkflowException; |
64 | |
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
65 | |
import org.kuali.rice.kew.messaging.MessageServiceNames; |
66 | |
import org.kuali.rice.kew.postprocessor.PostProcessor; |
67 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
68 | |
import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService; |
69 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
70 | |
import org.kuali.rice.kew.util.KEWConstants; |
71 | |
import org.kuali.rice.kew.util.Utilities; |
72 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | 0 | public class WorkflowDocumentServiceImpl implements WorkflowDocumentService { |
82 | |
|
83 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(WorkflowDocumentServiceImpl.class); |
84 | |
|
85 | |
private void init(DocumentRouteHeaderValue routeHeader) { |
86 | 0 | KEWServiceLocator.getRouteHeaderService().lockRouteHeader(routeHeader.getRouteHeaderId(), true); |
87 | 0 | KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader); |
88 | 0 | } |
89 | |
|
90 | |
private DocumentRouteHeaderValue finish(DocumentRouteHeaderValue routeHeader) { |
91 | |
|
92 | |
|
93 | 0 | if (RouteContext.getCurrentRouteContext().getDocument() == null) { |
94 | 0 | return KEWServiceLocator.getRouteHeaderService().getRouteHeader(routeHeader.getRouteHeaderId(), true); |
95 | |
} else { |
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | 0 | return routeHeader; |
101 | |
} |
102 | |
} |
103 | |
|
104 | |
public DocumentRouteHeaderValue acknowledgeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
105 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
106 | 0 | AcknowledgeAction action = new AcknowledgeAction(routeHeader, principal, annotation); |
107 | 0 | action.performAction(); |
108 | 0 | return finish(routeHeader); |
109 | |
} |
110 | |
|
111 | |
public DocumentRouteHeaderValue releaseGroupAuthority(String principalId, DocumentRouteHeaderValue routeHeader, String groupId, String annotation) throws InvalidActionTakenException { |
112 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
113 | 0 | ReleaseWorkgroupAuthority action = new ReleaseWorkgroupAuthority(routeHeader, principal, annotation, groupId); |
114 | 0 | action.performAction(); |
115 | 0 | return finish(routeHeader); |
116 | |
} |
117 | |
|
118 | |
public DocumentRouteHeaderValue takeGroupAuthority(String principalId, DocumentRouteHeaderValue routeHeader, String groupId, String annotation) throws InvalidActionTakenException { |
119 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
120 | 0 | TakeWorkgroupAuthority action = new TakeWorkgroupAuthority(routeHeader, principal, annotation, groupId); |
121 | 0 | action.performAction(); |
122 | 0 | return finish(routeHeader); |
123 | |
} |
124 | |
|
125 | |
public DocumentRouteHeaderValue approveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
126 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
127 | 0 | ApproveAction action = new ApproveAction(routeHeader, principal, annotation); |
128 | 0 | action.performAction(); |
129 | 0 | return finish(routeHeader); |
130 | |
} |
131 | |
|
132 | |
public DocumentRouteHeaderValue placeInExceptionRouting(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
133 | |
try { |
134 | 0 | KEWServiceLocator.getExceptionRoutingService().placeInExceptionRouting(annotation, null, routeHeader.getRouteHeaderId()); |
135 | 0 | } catch (Exception e) { |
136 | 0 | throw new RiceRuntimeException("Failed to place the document into exception routing!", e); |
137 | 0 | } |
138 | 0 | return finish(routeHeader); |
139 | |
} |
140 | |
|
141 | |
public DocumentRouteHeaderValue adHocRouteDocumentToPrincipal(String principalId, DocumentRouteHeaderValue document, String actionRequested, String nodeName, String annotation, String targetPrincipalId, |
142 | |
String responsibilityDesc, Boolean forceAction, String requestLabel) throws WorkflowException { |
143 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
144 | 0 | Recipient recipient = KEWServiceLocator.getIdentityHelperService().getPrincipalRecipient(targetPrincipalId); |
145 | 0 | AdHocAction action = new AdHocAction(document, principal, annotation, actionRequested, nodeName, recipient, responsibilityDesc, forceAction, requestLabel); |
146 | 0 | action.performAction(); |
147 | 0 | return finish(document); |
148 | |
} |
149 | |
|
150 | |
public DocumentRouteHeaderValue adHocRouteDocumentToGroup(String principalId, DocumentRouteHeaderValue document, String actionRequested, String nodeName, String annotation, String groupId, |
151 | |
String responsibilityDesc, Boolean forceAction, String requestLabel) throws WorkflowException { |
152 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
153 | 0 | Recipient recipient = KEWServiceLocator.getIdentityHelperService().getGroupRecipient(groupId); |
154 | 0 | AdHocAction action = new AdHocAction(document, principal, annotation, actionRequested, nodeName, recipient, responsibilityDesc, forceAction, requestLabel); |
155 | 0 | action.performAction(); |
156 | 0 | return finish(document); |
157 | |
} |
158 | |
|
159 | |
public DocumentRouteHeaderValue blanketApproval(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, Integer routeLevel) throws InvalidActionTakenException { |
160 | 0 | RouteNode node = (routeLevel == null ? null : CompatUtils.getNodeForLevel(routeHeader.getDocumentType(), routeLevel)); |
161 | 0 | if (node == null && routeLevel != null) { |
162 | 0 | throw new InvalidActionTakenException("Could not locate node for route level " + routeLevel); |
163 | |
} |
164 | 0 | Set<String> nodeNames = new HashSet<String>(); |
165 | 0 | if (node != null) { |
166 | 0 | nodeNames = Utilities.asSet(node.getRouteNodeName()); |
167 | |
} |
168 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
169 | 0 | ActionTakenEvent action = new BlanketApproveAction(routeHeader, principal, annotation, nodeNames); |
170 | 0 | action.performAction(); |
171 | 0 | return finish(routeHeader); |
172 | |
} |
173 | |
|
174 | |
public DocumentRouteHeaderValue blanketApproval(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, Set nodeNames) throws InvalidActionTakenException { |
175 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
176 | 0 | BlanketApproveAction action = new BlanketApproveAction(routeHeader, principal, annotation, nodeNames); |
177 | 0 | action.recordAction(); |
178 | |
|
179 | 0 | return finish(routeHeader); |
180 | |
} |
181 | |
|
182 | |
public DocumentRouteHeaderValue cancelDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
183 | |
|
184 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
185 | 0 | CancelAction action = new CancelAction(routeHeader, principal, annotation); |
186 | 0 | action.recordAction(); |
187 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
188 | 0 | return finish(routeHeader); |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
protected void indexForSearchAfterActionIfNecessary(DocumentRouteHeaderValue routeHeader) { |
196 | 0 | RouteContext routeContext = RouteContext.getCurrentRouteContext(); |
197 | 0 | if (routeHeader.getDocumentType().hasSearchableAttributes() && routeContext.isSearchIndexingRequestedForContext()) { |
198 | 0 | SearchableAttributeProcessingService searchableAttService = (SearchableAttributeProcessingService) MessageServiceNames.getSearchableAttributeService(routeHeader); |
199 | 0 | searchableAttService.indexDocument(routeHeader.getRouteHeaderId()); |
200 | |
} |
201 | 0 | } |
202 | |
|
203 | |
public DocumentRouteHeaderValue clearFYIDocument(String principalId, DocumentRouteHeaderValue routeHeader) throws InvalidActionTakenException { |
204 | |
|
205 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
206 | 0 | ClearFYIAction action = new ClearFYIAction(routeHeader, principal, ""); |
207 | 0 | action.recordAction(); |
208 | 0 | return finish(routeHeader); |
209 | |
} |
210 | |
|
211 | |
public DocumentRouteHeaderValue completeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
212 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
213 | 0 | CompleteAction action = new CompleteAction(routeHeader, principal, annotation); |
214 | 0 | action.performAction(); |
215 | 0 | return finish(routeHeader); |
216 | |
} |
217 | |
|
218 | |
public DocumentRouteHeaderValue createDocument(String principalId, DocumentRouteHeaderValue routeHeader) throws DocumentTypeNotFoundException, WorkflowException { |
219 | |
|
220 | 0 | LOG.debug("Rmi createDocument() with "); |
221 | |
|
222 | |
|
223 | 0 | if (routeHeader.getRouteHeaderId() != null) { |
224 | |
|
225 | |
|
226 | 0 | throw new InvalidActionTakenException("Document already has a Document id"); |
227 | |
} |
228 | 0 | KimPrincipal 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 InvalidActionTakenException("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(KEWConstants.CURRENT_DOCUMENT_VERSION)); |
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 | KimPrincipal 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 | KimPrincipal 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 | KimPrincipal 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 | KimPrincipal 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.setRouteHeaderId(routeHeader.getRouteHeaderId()); |
313 | 0 | val.setRouteHeader(routeHeader); |
314 | 0 | PostProcessor postProcessor = routeHeader.getDocumentType().getPostProcessor(); |
315 | |
try { |
316 | 0 | postProcessor.doActionTaken(new org.kuali.rice.kew.postprocessor.ActionTakenEvent(routeHeader.getRouteHeaderId(), routeHeader.getAppDocId(), val)); |
317 | 0 | } catch (Exception e) { |
318 | 0 | if (e instanceof RuntimeException) { |
319 | 0 | throw (RuntimeException)e; |
320 | |
} |
321 | 0 | throw new WorkflowRuntimeException(e); |
322 | 0 | } |
323 | |
|
324 | 0 | RouteContext routeContext = RouteContext.getCurrentRouteContext(); |
325 | 0 | if (routeHeader.getDocumentType().hasSearchableAttributes() && !routeContext.isSearchIndexingRequestedForContext()) { |
326 | 0 | routeContext.requestSearchIndexingForContext(); |
327 | |
|
328 | 0 | SearchableAttributeProcessingService searchableAttService = (SearchableAttributeProcessingService) MessageServiceNames.getSearchableAttributeService(routeHeader); |
329 | 0 | searchableAttService.indexDocument(routeHeader.getRouteHeaderId()); |
330 | |
} |
331 | 0 | return finish(routeHeader); |
332 | |
} |
333 | |
|
334 | |
public DocumentRouteHeaderValue saveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
335 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
336 | 0 | SaveActionEvent action = new SaveActionEvent(routeHeader, principal, annotation); |
337 | 0 | action.performAction(); |
338 | 0 | return finish(routeHeader); |
339 | |
} |
340 | |
|
341 | |
public void deleteDocument(String principalId, DocumentRouteHeaderValue routeHeader) throws WorkflowException { |
342 | 0 | if (routeHeader.getRouteHeaderId() == null) { |
343 | 0 | LOG.debug("Null Document id passed."); |
344 | 0 | throw new WorkflowException("Document id must not be null."); |
345 | |
} |
346 | 0 | KEWServiceLocator.getRouteHeaderService().deleteRouteHeader(routeHeader); |
347 | 0 | } |
348 | |
|
349 | |
public void logDocumentAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
350 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
351 | 0 | LogDocumentActionAction action = new LogDocumentActionAction(routeHeader, principal, annotation); |
352 | 0 | action.recordAction(); |
353 | 0 | } |
354 | |
|
355 | |
public DocumentRouteHeaderValue moveDocument(String principalId, DocumentRouteHeaderValue routeHeader, MovePoint movePoint, String annotation) throws InvalidActionTakenException { |
356 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
357 | 0 | MoveDocumentAction action = new MoveDocumentAction(routeHeader, principal, annotation, movePoint); |
358 | 0 | action.performAction(); |
359 | 0 | return finish(routeHeader); |
360 | |
} |
361 | |
|
362 | |
public DocumentRouteHeaderValue superUserActionRequestApproveAction(String principalId, DocumentRouteHeaderValue routeHeader, Long actionRequestId, String annotation, boolean runPostProcessor) |
363 | |
throws InvalidActionTakenException { |
364 | 0 | init(routeHeader); |
365 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
366 | 0 | SuperUserActionRequestApproveEvent suActionRequestApprove = new SuperUserActionRequestApproveEvent(routeHeader, principal, actionRequestId, annotation, runPostProcessor); |
367 | 0 | suActionRequestApprove.recordAction(); |
368 | |
|
369 | 0 | RouteContext.getCurrentRouteContext().requestSearchIndexingForContext(); |
370 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
371 | 0 | return finish(routeHeader); |
372 | |
} |
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
public DocumentRouteHeaderValue superUserActionRequestApproveAction(String principalId, Long documentId, Long actionRequestId, String annotation, boolean runPostProcessor) |
380 | |
throws InvalidActionTakenException { |
381 | 0 | return superUserActionRequestApproveAction(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), actionRequestId, annotation, runPostProcessor); |
382 | |
} |
383 | |
|
384 | |
public DocumentRouteHeaderValue superUserApprove(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException { |
385 | 0 | init(routeHeader); |
386 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
387 | 0 | new SuperUserApproveEvent(routeHeader, principal, annotation, runPostProcessor).recordAction(); |
388 | 0 | RouteContext.getCurrentRouteContext().requestSearchIndexingForContext(); |
389 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
390 | 0 | return finish(routeHeader); |
391 | |
} |
392 | |
|
393 | |
public DocumentRouteHeaderValue superUserCancelAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException { |
394 | 0 | init(routeHeader); |
395 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
396 | 0 | new SuperUserCancelEvent(routeHeader, principal, annotation, runPostProcessor).recordAction(); |
397 | 0 | RouteContext.getCurrentRouteContext().requestSearchIndexingForContext(); |
398 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
399 | 0 | return finish(routeHeader); |
400 | |
} |
401 | |
|
402 | |
public DocumentRouteHeaderValue superUserDisapproveAction(String principalId, DocumentRouteHeaderValue routeHeader, String annotation, boolean runPostProcessor) throws InvalidActionTakenException { |
403 | 0 | init(routeHeader); |
404 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
405 | 0 | new SuperUserDisapproveEvent(routeHeader, principal, annotation, runPostProcessor).recordAction(); |
406 | 0 | RouteContext.getCurrentRouteContext().requestSearchIndexingForContext(); |
407 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
408 | 0 | return finish(routeHeader); |
409 | |
} |
410 | |
|
411 | |
public DocumentRouteHeaderValue superUserNodeApproveAction(String principalId, DocumentRouteHeaderValue routeHeader, String nodeName, String annotation, boolean runPostProcessor) throws InvalidActionTakenException { |
412 | 0 | init(routeHeader); |
413 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
414 | 0 | new SuperUserNodeApproveEvent(routeHeader, principal, annotation, runPostProcessor, nodeName).recordAction(); |
415 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
416 | 0 | return finish(routeHeader); |
417 | |
} |
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
public DocumentRouteHeaderValue superUserNodeApproveAction(String principalId, Long documentId, String nodeName, String annotation, boolean runPostProcessor) throws InvalidActionTakenException { |
425 | 0 | return superUserNodeApproveAction(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), nodeName, annotation, runPostProcessor); |
426 | |
} |
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
public DocumentRouteHeaderValue superUserReturnDocumentToPreviousNode(String principalId, Long documentId, String nodeName, String annotation, boolean runPostProcessor) |
435 | |
throws InvalidActionTakenException { |
436 | 0 | return superUserReturnDocumentToPreviousNode(principalId, KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId), nodeName, annotation, runPostProcessor); |
437 | |
} |
438 | |
|
439 | |
public DocumentRouteHeaderValue superUserReturnDocumentToPreviousNode(String principalId, DocumentRouteHeaderValue routeHeader, String nodeName, String annotation, boolean runPostProcessor) |
440 | |
throws InvalidActionTakenException { |
441 | 0 | init(routeHeader); |
442 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
443 | 0 | SuperUserReturnToPreviousNodeAction action = new SuperUserReturnToPreviousNodeAction(routeHeader, principal, annotation, runPostProcessor, nodeName); |
444 | 0 | action.recordAction(); |
445 | 0 | RouteContext.getCurrentRouteContext().requestSearchIndexingForContext(); |
446 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
447 | 0 | return finish(routeHeader); |
448 | |
} |
449 | |
|
450 | |
public void takeMassActions(String principalId, List actionInvocations) { |
451 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
452 | 0 | for (Iterator iterator = actionInvocations.iterator(); iterator.hasNext();) { |
453 | 0 | ActionInvocation invocation = (ActionInvocation) iterator.next(); |
454 | 0 | ActionItem actionItem = KEWServiceLocator.getActionListService().findByActionItemId(invocation.getActionItemId()); |
455 | 0 | if (actionItem == null) { |
456 | 0 | LOG.warn("Could not locate action item for the given action item id [" + invocation.getActionItemId() + "], not taking mass action on it."); |
457 | 0 | continue; |
458 | |
} |
459 | 0 | KEWServiceLocator.getActionListService().deleteActionItem(actionItem, true); |
460 | 0 | ActionInvocationService actionInvocService = MessageServiceNames.getActionInvocationProcessorService(actionItem.getRouteHeader()); |
461 | 0 | actionInvocService.invokeAction(principalId, actionItem.getRouteHeaderId(), invocation); |
462 | |
|
463 | 0 | } |
464 | 0 | } |
465 | |
|
466 | |
public DocumentRouteHeaderValue revokeAdHocRequests(String principalId, DocumentRouteHeaderValue document, AdHocRevoke revoke, String annotation) throws InvalidActionTakenException { |
467 | 0 | KimPrincipal principal = loadPrincipal(principalId); |
468 | 0 | RevokeAdHocAction action = new RevokeAdHocAction(document, principal, revoke, annotation); |
469 | 0 | action.performAction(); |
470 | 0 | return finish(document); |
471 | |
} |
472 | |
|
473 | |
protected KimPrincipal loadPrincipal(String principalId) { |
474 | 0 | return KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId); |
475 | |
} |
476 | |
|
477 | |
} |