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