1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.routeheader.service.impl; |
17 | |
|
18 | |
import org.kuali.rice.core.api.exception.RiceRuntimeException; |
19 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
20 | |
import org.kuali.rice.kew.actionrequest.KimGroupRecipient; |
21 | |
import org.kuali.rice.kew.actionrequest.Recipient; |
22 | |
import org.kuali.rice.kew.actions.AcknowledgeAction; |
23 | |
import org.kuali.rice.kew.actions.ActionTakenEvent; |
24 | |
import org.kuali.rice.kew.actions.AdHocAction; |
25 | |
import org.kuali.rice.kew.actions.ApproveAction; |
26 | |
import org.kuali.rice.kew.actions.BlanketApproveAction; |
27 | |
import org.kuali.rice.kew.actions.CancelAction; |
28 | |
import org.kuali.rice.kew.actions.ClearFYIAction; |
29 | |
import org.kuali.rice.kew.actions.CompleteAction; |
30 | |
import org.kuali.rice.kew.actions.DisapproveAction; |
31 | |
import org.kuali.rice.kew.actions.LogDocumentActionAction; |
32 | |
import org.kuali.rice.kew.actions.MoveDocumentAction; |
33 | |
import org.kuali.rice.kew.actions.ReleaseWorkgroupAuthority; |
34 | |
import org.kuali.rice.kew.actions.ReturnToPreviousNodeAction; |
35 | |
import org.kuali.rice.kew.actions.RevokeAdHocAction; |
36 | |
import org.kuali.rice.kew.actions.RouteDocumentAction; |
37 | |
import org.kuali.rice.kew.actions.SaveActionEvent; |
38 | |
import org.kuali.rice.kew.actions.SuperUserActionRequestApproveEvent; |
39 | |
import org.kuali.rice.kew.actions.SuperUserApproveEvent; |
40 | |
import org.kuali.rice.kew.actions.SuperUserCancelEvent; |
41 | |
import org.kuali.rice.kew.actions.SuperUserDisapproveEvent; |
42 | |
import org.kuali.rice.kew.actions.SuperUserNodeApproveEvent; |
43 | |
import org.kuali.rice.kew.actions.SuperUserReturnToPreviousNodeAction; |
44 | |
import org.kuali.rice.kew.actions.TakeWorkgroupAuthority; |
45 | |
import org.kuali.rice.kew.api.action.ActionInvocation; |
46 | |
import org.kuali.rice.kew.api.action.ActionInvocationQueue; |
47 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
48 | |
import org.kuali.rice.kew.api.KewApiConstants; |
49 | |
import org.kuali.rice.kew.api.KewApiServiceLocator; |
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.api.document.attribute.DocumentAttributeIndexingQueue; |
55 | |
import org.kuali.rice.kew.api.exception.InvalidActionTakenException; |
56 | |
import org.kuali.rice.kew.api.exception.WorkflowException; |
57 | |
import org.kuali.rice.kew.engine.CompatUtils; |
58 | |
import org.kuali.rice.kew.engine.OrchestrationConfig; |
59 | |
import org.kuali.rice.kew.engine.RouteContext; |
60 | |
import org.kuali.rice.kew.engine.OrchestrationConfig.EngineCapability; |
61 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
62 | |
import org.kuali.rice.kew.framework.postprocessor.PostProcessor; |
63 | |
import org.kuali.rice.kew.messaging.MessageServiceNames; |
64 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
65 | |
import org.kuali.rice.kew.routeheader.service.WorkflowDocumentService; |
66 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
67 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
68 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
69 | |
|
70 | |
import java.sql.Timestamp; |
71 | |
import java.util.Collections; |
72 | |
import java.util.Date; |
73 | |
import java.util.HashSet; |
74 | |
import java.util.List; |
75 | |
import java.util.Set; |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | 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, Integer priority, 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, priority, 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, Integer priority, 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, priority, 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 | DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(routeHeader.getDocumentType().getApplicationId()); |
202 | 0 | queue.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(KewApiConstants.ROUTE_HEADER_INITIATED_CD); |
243 | |
} |
244 | 0 | if (routeHeader.getDocRouteLevel() == null) { |
245 | 0 | routeHeader.setDocRouteLevel(Integer.valueOf(KewApiConstants.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(KewApiConstants.DEFAULT_DOCUMENT_CONTENT); |
255 | |
} |
256 | 0 | routeHeader.setStatusModDate(new Timestamp(new Date().getTime())); |
257 | 0 | KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader); |
258 | 0 | OrchestrationConfig config = new OrchestrationConfig(EngineCapability.STANDARD); |
259 | 0 | KEWServiceLocator.getWorkflowEngineFactory().newEngine(config).initializeDocument(routeHeader); |
260 | 0 | KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader); |
261 | 0 | return routeHeader; |
262 | |
} |
263 | |
|
264 | |
public DocumentRouteHeaderValue disapproveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
265 | 0 | Principal principal = loadPrincipal(principalId); |
266 | 0 | DisapproveAction action = new DisapproveAction(routeHeader, principal, annotation); |
267 | 0 | action.recordAction(); |
268 | 0 | indexForSearchAfterActionIfNecessary(routeHeader); |
269 | 0 | return finish(routeHeader); |
270 | |
} |
271 | |
|
272 | |
public DocumentRouteHeaderValue returnDocumentToPreviousRouteLevel(String principalId, DocumentRouteHeaderValue routeHeader, Integer destRouteLevel, String annotation) |
273 | |
throws InvalidActionTakenException { |
274 | 0 | DocumentRouteHeaderValue result = null; |
275 | |
|
276 | 0 | if (destRouteLevel != null) { |
277 | 0 | RouteNode node = CompatUtils.getNodeForLevel(routeHeader.getDocumentType(), destRouteLevel); |
278 | 0 | if (node == null) { |
279 | 0 | throw new InvalidActionTakenException("Could not locate node for route level " + destRouteLevel); |
280 | |
} |
281 | |
|
282 | 0 | Principal principal = loadPrincipal(principalId); |
283 | 0 | ReturnToPreviousNodeAction action = new ReturnToPreviousNodeAction(routeHeader, principal, annotation, node.getRouteNodeName(), true); |
284 | 0 | action.performAction(); |
285 | 0 | result = finish(routeHeader); |
286 | |
} |
287 | 0 | return result; |
288 | |
} |
289 | |
|
290 | |
public DocumentRouteHeaderValue returnDocumentToPreviousNode(String principalId, DocumentRouteHeaderValue routeHeader, String destinationNodeName, String annotation) |
291 | |
throws InvalidActionTakenException { |
292 | 0 | Principal principal = loadPrincipal(principalId); |
293 | 0 | ReturnToPreviousNodeAction action = new ReturnToPreviousNodeAction(routeHeader, principal, annotation, destinationNodeName, true); |
294 | 0 | action.performAction(); |
295 | 0 | return finish(routeHeader); |
296 | |
} |
297 | |
|
298 | |
public DocumentRouteHeaderValue routeDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws WorkflowException, |
299 | |
InvalidActionTakenException { |
300 | 0 | Principal principal = loadPrincipal(principalId); |
301 | 0 | RouteDocumentAction actionEvent = new RouteDocumentAction(routeHeader, principal, annotation); |
302 | 0 | actionEvent.performAction(); |
303 | 0 | LOG.info("routeDocument: " + routeHeader); |
304 | 0 | return finish(routeHeader); |
305 | |
} |
306 | |
|
307 | |
public DocumentRouteHeaderValue saveRoutingData(String principalId, DocumentRouteHeaderValue routeHeader) { |
308 | 0 | KEWServiceLocator.getRouteHeaderService().saveRouteHeader(routeHeader); |
309 | |
|
310 | |
|
311 | 0 | ActionTakenValue val = new ActionTakenValue(); |
312 | 0 | val.setActionTaken(KewApiConstants.ACTION_TAKEN_SAVED_CD); |
313 | 0 | val.setDocumentId(routeHeader.getDocumentId()); |
314 | 0 | val.setPrincipalId(principalId); |
315 | 0 | PostProcessor postProcessor = routeHeader.getDocumentType().getPostProcessor(); |
316 | |
try { |
317 | 0 | postProcessor.doActionTaken(new org.kuali.rice.kew.framework.postprocessor.ActionTakenEvent(routeHeader.getDocumentId(), routeHeader.getAppDocId(), ActionTakenValue.to(val))); |
318 | 0 | } catch (Exception e) { |
319 | 0 | if (e instanceof RuntimeException) { |
320 | 0 | throw (RuntimeException)e; |
321 | |
} |
322 | 0 | throw new WorkflowRuntimeException(e); |
323 | 0 | } |
324 | |
|
325 | 0 | RouteContext routeContext = RouteContext.getCurrentRouteContext(); |
326 | 0 | if (routeHeader.getDocumentType().hasSearchableAttributes() && !routeContext.isSearchIndexingRequestedForContext()) { |
327 | 0 | routeContext.requestSearchIndexingForContext(); |
328 | 0 | DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(routeHeader.getDocumentType().getApplicationId()); |
329 | 0 | queue.indexDocument(routeHeader.getDocumentId()); |
330 | |
} |
331 | 0 | return finish(routeHeader); |
332 | |
} |
333 | |
|
334 | |
public DocumentRouteHeaderValue saveDocument(String principalId, DocumentRouteHeaderValue routeHeader, String annotation) throws InvalidActionTakenException { |
335 | 0 | Principal 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.getDocumentId() == 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 | Principal 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 | Principal 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, String actionRequestId, String annotation, boolean runPostProcessor) |
363 | |
throws InvalidActionTakenException { |
364 | 0 | init(routeHeader); |
365 | 0 | Principal 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, String documentId, String 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 | Principal 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 | Principal 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 | Principal 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 | Principal 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, String 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, String 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 | Principal 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<ActionInvocation> actionInvocations) { |
451 | 0 | Principal principal = loadPrincipal(principalId); |
452 | 0 | for (ActionInvocation invocation : actionInvocations) { |
453 | 0 | ActionItem actionItem = KEWServiceLocator.getActionListService().findByActionItemId(invocation.getActionItemId()); |
454 | 0 | if (actionItem == null) { |
455 | 0 | LOG.warn("Could not locate action item for the given action item id [" + invocation.getActionItemId() + "], not taking mass action on it."); |
456 | 0 | continue; |
457 | |
} |
458 | 0 | KEWServiceLocator.getActionListService().deleteActionItem(actionItem, true); |
459 | 0 | ActionInvocationQueue actionInvocQueue = MessageServiceNames.getActionInvocationProcessorService( |
460 | |
KEWServiceLocator.getRouteHeaderService().getRouteHeader(actionItem.getDocumentId())); |
461 | 0 | actionInvocQueue.invokeAction(principalId, actionItem.getDocumentId(), invocation); |
462 | |
|
463 | 0 | } |
464 | 0 | } |
465 | |
|
466 | |
public DocumentRouteHeaderValue revokeAdHocRequests(String principalId, DocumentRouteHeaderValue document, AdHocRevoke revoke, String annotation) throws InvalidActionTakenException { |
467 | 0 | Principal 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 | |
public DocumentRouteHeaderValue revokeAdHocRequests(String principalId, DocumentRouteHeaderValue document, String actionRequestId, String annotation) throws InvalidActionTakenException { |
474 | 0 | Principal principal = loadPrincipal(principalId); |
475 | 0 | RevokeAdHocAction action = new RevokeAdHocAction(document, principal, actionRequestId, annotation); |
476 | 0 | action.performAction(); |
477 | 0 | return finish(document); |
478 | |
} |
479 | |
|
480 | |
protected Principal loadPrincipal(String principalId) { |
481 | 0 | return KEWServiceLocator.getIdentityHelperService().getPrincipal(principalId); |
482 | |
} |
483 | |
|
484 | |
} |