1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.routelog.web; |
18 | |
|
19 | |
import org.apache.struts.action.ActionForm; |
20 | |
import org.apache.struts.action.ActionForward; |
21 | |
import org.apache.struts.action.ActionMapping; |
22 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
23 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
24 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
25 | |
import org.kuali.rice.kew.actionrequest.service.ActionRequestService; |
26 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
27 | |
import org.kuali.rice.kew.doctype.SecuritySession; |
28 | |
import org.kuali.rice.kew.doctype.service.DocumentSecurityService; |
29 | |
import org.kuali.rice.kew.dto.*; |
30 | |
import org.kuali.rice.kew.dto.DTOConverter.RouteNodeInstanceLoader; |
31 | |
import org.kuali.rice.kew.engine.node.Branch; |
32 | |
import org.kuali.rice.kew.engine.node.NodeState; |
33 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
34 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
35 | |
import org.kuali.rice.kew.engine.node.service.RouteNodeService; |
36 | |
import org.kuali.rice.kew.exception.InvalidActionTakenException; |
37 | |
import org.kuali.rice.kew.exception.WorkflowRuntimeException; |
38 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
39 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
40 | |
import org.kuali.rice.kew.service.WorkflowUtility; |
41 | |
import org.kuali.rice.kew.util.KEWConstants; |
42 | |
import org.kuali.rice.kew.util.Utilities; |
43 | |
import org.kuali.rice.kew.web.KewKualiAction; |
44 | |
import org.kuali.rice.kns.UserSession; |
45 | |
import org.kuali.rice.kns.util.GlobalVariables; |
46 | |
|
47 | |
import javax.servlet.http.HttpServletRequest; |
48 | |
import javax.servlet.http.HttpServletResponse; |
49 | |
import javax.xml.namespace.QName; |
50 | |
import java.util.*; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | 0 | public class RouteLogAction extends KewKualiAction { |
59 | |
|
60 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(RouteLogAction.class); |
61 | 0 | private static Comparator<ActionRequestValue> ROUTE_LOG_ACTION_REQUEST_SORTER = new Utilities.RouteLogActionRequestSorter(); |
62 | |
|
63 | |
@Override |
64 | |
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
65 | |
|
66 | 0 | RouteLogForm rlForm = (RouteLogForm) form; |
67 | 0 | Long routeHeaderId = null; |
68 | 0 | if (! org.apache.commons.lang.StringUtils.isEmpty(rlForm.getRouteHeaderId())) { |
69 | 0 | routeHeaderId = new Long(rlForm.getRouteHeaderId()); |
70 | 0 | } else if (! org.apache.commons.lang.StringUtils.isEmpty(rlForm.getDocId())) { |
71 | 0 | routeHeaderId = new Long(rlForm.getDocId()); |
72 | |
} else { |
73 | 0 | throw new WorkflowRuntimeException("No paramater provided to fetch document"); |
74 | |
} |
75 | |
|
76 | 0 | DocumentRouteHeaderValue routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(routeHeaderId); |
77 | |
|
78 | 0 | DocumentSecurityService security = KEWServiceLocator.getDocumentSecurityService(); |
79 | 0 | if (!security.routeLogAuthorized(getUserSession(), routeHeader, new SecuritySession(GlobalVariables.getUserSession()))) { |
80 | 0 | return mapping.findForward("NotAuthorized"); |
81 | |
} |
82 | |
|
83 | 0 | fixActionRequestsPositions(routeHeader); |
84 | 0 | populateRouteLogFormActionRequests(rlForm, routeHeader); |
85 | |
|
86 | 0 | rlForm.setLookFuture(routeHeader.getDocumentType().getLookIntoFuturePolicy().getPolicyValue().booleanValue()); |
87 | |
|
88 | 0 | if (rlForm.isShowFuture()) { |
89 | |
try { |
90 | 0 | populateRouteLogFutureRequests(rlForm, routeHeader); |
91 | 0 | } catch (Exception e) { |
92 | 0 | String errorMsg = "Unable to determine Future Action Requests"; |
93 | 0 | LOG.info(errorMsg,e); |
94 | 0 | rlForm.setShowFutureError(errorMsg); |
95 | 0 | } |
96 | |
} |
97 | 0 | request.setAttribute("routeHeader", routeHeader); |
98 | |
|
99 | |
|
100 | |
|
101 | 0 | boolean isAuthorizedToAddRouteLogMessage = KEWServiceLocator.getDocumentTypePermissionService() |
102 | |
.canAddRouteLogMessage(GlobalVariables.getUserSession().getPrincipalId(), routeHeader); |
103 | 0 | if (isAuthorizedToAddRouteLogMessage) { |
104 | 0 | rlForm.setEnableLogAction(true); |
105 | |
} else { |
106 | 0 | rlForm.setEnableLogAction(false); |
107 | |
} |
108 | |
|
109 | 0 | return super.execute(mapping, rlForm, request, response); |
110 | |
} |
111 | |
|
112 | |
@SuppressWarnings("unchecked") |
113 | |
public void populateRouteLogFormActionRequests(RouteLogForm rlForm, DocumentRouteHeaderValue routeHeader) { |
114 | 0 | List<ActionRequestValue> rootRequests = getActionRequestService().getRootRequests(routeHeader.getActionRequests()); |
115 | 0 | Collections.sort(rootRequests, ROUTE_LOG_ACTION_REQUEST_SORTER); |
116 | 0 | rootRequests = switchActionRequestPositionsIfPrimaryDelegatesPresent(rootRequests); |
117 | 0 | int arCount = 0; |
118 | 0 | for ( ActionRequestValue actionRequest : rootRequests ) { |
119 | 0 | if (actionRequest.isPending()) { |
120 | 0 | arCount++; |
121 | |
|
122 | 0 | if (KEWConstants.ACTION_REQUEST_INITIALIZED.equals(actionRequest.getStatus())) { |
123 | 0 | actionRequest.setDisplayStatus("PENDING"); |
124 | 0 | } else if (KEWConstants.ACTION_REQUEST_ACTIVATED.equals(actionRequest.getStatus())) { |
125 | 0 | actionRequest.setDisplayStatus("IN ACTION LIST"); |
126 | |
} |
127 | |
} |
128 | |
} |
129 | 0 | rlForm.setRootRequests(rootRequests); |
130 | 0 | rlForm.setPendingActionRequestCount(arCount); |
131 | 0 | } |
132 | |
|
133 | |
@SuppressWarnings("unchecked") |
134 | |
private ActionRequestValue switchActionRequestPositionIfPrimaryDelegatePresent( ActionRequestValue actionRequest ) { |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | 0 | if (!actionRequest.isRoleRequest()) { |
151 | 0 | List<ActionRequestValue> primaryDelegateRequests = actionRequest.getPrimaryDelegateRequests(); |
152 | |
|
153 | 0 | if ( primaryDelegateRequests.size() != 1) { |
154 | 0 | return actionRequest; |
155 | |
} |
156 | 0 | ActionRequestValue primaryDelegateRequest = primaryDelegateRequests.get(0); |
157 | 0 | actionRequest.getChildrenRequests().remove(primaryDelegateRequest); |
158 | 0 | primaryDelegateRequest.setChildrenRequests(actionRequest.getChildrenRequests()); |
159 | 0 | primaryDelegateRequest.setParentActionRequest(actionRequest.getParentActionRequest()); |
160 | 0 | primaryDelegateRequest.setParentActionRequestId(actionRequest.getParentActionRequestId()); |
161 | |
|
162 | 0 | actionRequest.setChildrenRequests( new ArrayList<ActionRequestValue>(0) ); |
163 | 0 | actionRequest.setParentActionRequest(primaryDelegateRequest); |
164 | 0 | actionRequest.setParentActionRequestId(primaryDelegateRequest.getActionRequestId()); |
165 | |
|
166 | 0 | primaryDelegateRequest.getChildrenRequests().add(0, actionRequest); |
167 | |
|
168 | 0 | for (ActionRequestValue delegateRequest : primaryDelegateRequest.getChildrenRequests()) { |
169 | 0 | delegateRequest.setParentActionRequest(primaryDelegateRequest); |
170 | 0 | delegateRequest.setParentActionRequestId(primaryDelegateRequest.getActionRequestId()); |
171 | |
} |
172 | |
|
173 | 0 | return primaryDelegateRequest; |
174 | |
} |
175 | |
|
176 | 0 | return actionRequest; |
177 | |
} |
178 | |
|
179 | |
private List<ActionRequestValue> switchActionRequestPositionsIfPrimaryDelegatesPresent( Collection<ActionRequestValue> actionRequests ) { |
180 | 0 | List<ActionRequestValue> results = new ArrayList<ActionRequestValue>( actionRequests.size() ); |
181 | 0 | for ( ActionRequestValue actionRequest : actionRequests ) { |
182 | 0 | results.add( switchActionRequestPositionIfPrimaryDelegatePresent(actionRequest) ); |
183 | |
} |
184 | 0 | return results; |
185 | |
} |
186 | |
|
187 | |
@SuppressWarnings("unchecked") |
188 | |
private void fixActionRequestsPositions(DocumentRouteHeaderValue routeHeader) { |
189 | 0 | for (ActionTakenValue actionTaken : routeHeader.getActionsTaken()) { |
190 | 0 | Collections.sort((List<ActionRequestValue>) actionTaken.getActionRequests(), ROUTE_LOG_ACTION_REQUEST_SORTER); |
191 | 0 | actionTaken.setActionRequests( actionTaken.getActionRequests() ); |
192 | |
} |
193 | 0 | } |
194 | |
|
195 | |
|
196 | |
|
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
public void populateRouteLogFutureRequests(RouteLogForm rlForm, DocumentRouteHeaderValue document) throws Exception { |
204 | |
|
205 | 0 | ReportCriteriaDTO reportCriteria = new ReportCriteriaDTO(document.getRouteHeaderId()); |
206 | 0 | String serviceNamespace = document.getDocumentType().getServiceNamespace(); |
207 | 0 | WorkflowUtility workflowUtility = |
208 | |
(WorkflowUtility) GlobalResourceLoader.getService(new QName(serviceNamespace, "WorkflowUtilityService")); |
209 | |
|
210 | |
|
211 | 0 | Set<Long> preexistingActionRequestIds = getActionRequestIds(document); |
212 | |
|
213 | |
|
214 | 0 | DocumentDetailDTO documentDetail = workflowUtility.routingReport(reportCriteria); |
215 | |
|
216 | |
|
217 | 0 | List<ActionRequestValue> futureActionRequests = |
218 | |
reconstituteActionRequestValues(documentDetail, preexistingActionRequestIds); |
219 | |
|
220 | 0 | Collections.sort(futureActionRequests, ROUTE_LOG_ACTION_REQUEST_SORTER); |
221 | |
|
222 | 0 | futureActionRequests = switchActionRequestPositionsIfPrimaryDelegatesPresent(futureActionRequests); |
223 | |
|
224 | 0 | int pendingActionRequestCount = 0; |
225 | 0 | for (ActionRequestValue actionRequest: futureActionRequests) { |
226 | 0 | if (actionRequest.isPending()) { |
227 | 0 | pendingActionRequestCount++; |
228 | |
|
229 | 0 | if (KEWConstants.ACTION_REQUEST_INITIALIZED.equals(actionRequest.getStatus())) { |
230 | 0 | actionRequest.setDisplayStatus("PENDING"); |
231 | 0 | } else if (KEWConstants.ACTION_REQUEST_ACTIVATED.equals(actionRequest.getStatus())) { |
232 | 0 | actionRequest.setDisplayStatus("IN ACTION LIST"); |
233 | |
} |
234 | |
} |
235 | |
} |
236 | |
|
237 | 0 | rlForm.setFutureRootRequests(futureActionRequests); |
238 | 0 | rlForm.setFutureActionRequestCount(pendingActionRequestCount); |
239 | 0 | } |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
@SuppressWarnings("unchecked") |
247 | |
private Set<Long> getActionRequestIds(DocumentRouteHeaderValue document) { |
248 | 0 | Set<Long> actionRequestIds = new HashSet<Long>(); |
249 | |
|
250 | 0 | List<ActionRequestValue> actionRequests = |
251 | |
KEWServiceLocator.getActionRequestService().findAllActionRequestsByRouteHeaderId(document.getRouteHeaderId()); |
252 | |
|
253 | 0 | if (actionRequests != null) { |
254 | 0 | for (ActionRequestValue actionRequest : actionRequests) { |
255 | 0 | if (actionRequest.getActionRequestId() != null) { |
256 | 0 | actionRequestIds.add(actionRequest.getActionRequestId()); |
257 | |
} |
258 | |
} |
259 | |
} |
260 | 0 | return actionRequestIds; |
261 | |
} |
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
private List<ActionRequestValue> reconstituteActionRequestValues(DocumentDetailDTO documentDetail, |
272 | |
Set<Long> preexistingActionRequestIds) { |
273 | |
|
274 | 0 | RouteNodeInstanceFabricator routeNodeInstanceFabricator = |
275 | |
new RouteNodeInstanceFabricator(KEWServiceLocator.getRouteNodeService()); |
276 | |
|
277 | 0 | if (documentDetail.getNodeInstances() != null && documentDetail.getNodeInstances().length > 0) { |
278 | 0 | for (RouteNodeInstanceDTO routeNodeInstanceVO : documentDetail.getNodeInstances()) { |
279 | 0 | routeNodeInstanceFabricator.importRouteNodeInstanceDTO(routeNodeInstanceVO); |
280 | |
} |
281 | |
} |
282 | |
|
283 | 0 | ActionRequestDTO[] actionRequestVOs = documentDetail.getActionRequests(); |
284 | 0 | List<ActionRequestValue> futureActionRequests = new ArrayList<ActionRequestValue>(); |
285 | 0 | if (actionRequestVOs != null) { |
286 | 0 | for (ActionRequestDTO actionRequestVO : actionRequestVOs) { |
287 | 0 | if (actionRequestVO != null) { |
288 | 0 | if (!preexistingActionRequestIds.contains(actionRequestVO.getActionRequestId())) { |
289 | 0 | ActionRequestValue converted = DTOConverter.convertActionRequestDTO(actionRequestVO, routeNodeInstanceFabricator); |
290 | 0 | futureActionRequests.add(converted); |
291 | |
} |
292 | |
} |
293 | |
} |
294 | |
} |
295 | 0 | return futureActionRequests; |
296 | |
} |
297 | |
|
298 | |
private ActionRequestService getActionRequestService() { |
299 | 0 | return (ActionRequestService) KEWServiceLocator.getService(KEWServiceLocator.ACTION_REQUEST_SRV); |
300 | |
} |
301 | |
|
302 | |
private UserSession getUserSession() { |
303 | 0 | return GlobalVariables.getUserSession(); |
304 | |
} |
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | |
|
311 | |
|
312 | |
|
313 | 0 | private static class RouteNodeInstanceFabricator implements RouteNodeInstanceLoader { |
314 | |
|
315 | 0 | private Map<Long,Branch> branches = new HashMap<Long, Branch>();; |
316 | 0 | private Map<Long,RouteNodeInstance> routeNodeInstances = new HashMap<Long, RouteNodeInstance>(); |
317 | 0 | private Map<Long,RouteNode> routeNodes = new HashMap<Long, RouteNode>(); |
318 | 0 | private Map<Long,NodeState> nodeStates = new HashMap<Long, NodeState>(); |
319 | |
|
320 | |
private RouteNodeService routeNodeService; |
321 | |
|
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
|
327 | 0 | public RouteNodeInstanceFabricator(RouteNodeService routeNodeService) { |
328 | 0 | this.routeNodeService = routeNodeService; |
329 | 0 | } |
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
|
335 | |
|
336 | |
|
337 | |
|
338 | |
public void importRouteNodeInstanceDTO(RouteNodeInstanceDTO nodeInstanceDTO) { |
339 | 0 | _importRouteNodeInstanceDTO(nodeInstanceDTO); |
340 | 0 | } |
341 | |
|
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
|
351 | |
private RouteNodeInstance _importRouteNodeInstanceDTO(RouteNodeInstanceDTO nodeInstanceDTO) { |
352 | 0 | if (nodeInstanceDTO == null) { |
353 | 0 | return null; |
354 | |
} |
355 | 0 | RouteNodeInstance nodeInstance = new RouteNodeInstance(); |
356 | 0 | nodeInstance.setActive(nodeInstanceDTO.isActive()); |
357 | |
|
358 | 0 | nodeInstance.setComplete(nodeInstanceDTO.isComplete()); |
359 | 0 | nodeInstance.setDocumentId(nodeInstanceDTO.getDocumentId()); |
360 | 0 | nodeInstance.setInitial(nodeInstanceDTO.isInitial()); |
361 | |
|
362 | 0 | Branch branch = getBranch(nodeInstanceDTO.getBranchId()); |
363 | 0 | nodeInstance.setBranch(branch); |
364 | |
|
365 | 0 | if (nodeInstanceDTO.getRouteNodeId() != null) { |
366 | 0 | RouteNode routeNode = routeNodeService.findRouteNodeById(nodeInstanceDTO.getRouteNodeId()); |
367 | |
|
368 | 0 | if (routeNode == null) { |
369 | 0 | routeNode = getRouteNode(nodeInstanceDTO.getRouteNodeId()); |
370 | 0 | routeNode.setNodeType(nodeInstanceDTO.getName()); |
371 | |
} |
372 | |
|
373 | 0 | nodeInstance.setRouteNode(routeNode); |
374 | |
|
375 | 0 | if (routeNode.getBranch() != null) { |
376 | 0 | branch.setName(routeNode.getBranch().getName()); |
377 | |
} |
378 | |
} |
379 | |
|
380 | 0 | RouteNodeInstance process = getRouteNodeInstance(nodeInstanceDTO.getProcessId()); |
381 | 0 | nodeInstance.setProcess(process); |
382 | |
|
383 | 0 | nodeInstance.setRouteNodeInstanceId(nodeInstanceDTO.getRouteNodeInstanceId()); |
384 | 0 | DTOConverter.convertState(null); |
385 | |
|
386 | 0 | List<NodeState> nodeState = new ArrayList<NodeState>(); |
387 | 0 | if (nodeInstanceDTO.getState() != null) { |
388 | 0 | for (StateDTO stateDTO : nodeInstanceDTO.getState()) { |
389 | 0 | NodeState state = getNodeState(stateDTO.getStateId()); |
390 | 0 | if (state != null) { |
391 | 0 | state.setKey(stateDTO.getKey()); |
392 | 0 | state.setValue(stateDTO.getValue()); |
393 | 0 | state.setStateId(stateDTO.getStateId()); |
394 | 0 | state.setNodeInstance(nodeInstance); |
395 | 0 | nodeState.add(state); |
396 | |
} |
397 | |
} |
398 | |
} |
399 | 0 | nodeInstance.setState(nodeState); |
400 | |
|
401 | 0 | List<RouteNodeInstance> nextNodeInstances = new ArrayList<RouteNodeInstance>(); |
402 | 0 | nodeInstance.setNextNodeInstances(nextNodeInstances); |
403 | |
|
404 | 0 | for (RouteNodeInstanceDTO nextNodeInstanceVO : nodeInstanceDTO.getNextNodes()) { |
405 | |
|
406 | 0 | nextNodeInstances.add(_importRouteNodeInstanceDTO(nextNodeInstanceVO)); |
407 | |
} |
408 | |
|
409 | 0 | routeNodeInstances.put(nodeInstance.getRouteNodeInstanceId(), nodeInstance); |
410 | 0 | return nodeInstance; |
411 | |
} |
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
@Override |
420 | |
public RouteNodeInstance load(Long routeNodeInstanceID) { |
421 | 0 | return routeNodeInstances.get(routeNodeInstanceID); |
422 | |
} |
423 | |
|
424 | |
|
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
private Branch getBranch(Long branchId) { |
432 | 0 | Branch result = null; |
433 | |
|
434 | 0 | if (branchId != null) { |
435 | |
|
436 | 0 | if (!branches.containsKey(branchId)) { |
437 | 0 | result = new Branch(); |
438 | 0 | result.setBranchId(branchId); |
439 | 0 | branches.put(branchId, result); |
440 | |
} else { |
441 | 0 | result = branches.get(branchId); |
442 | |
} |
443 | |
} |
444 | 0 | return result; |
445 | |
} |
446 | |
|
447 | |
|
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
private RouteNode getRouteNode(Long routeNodeId) { |
454 | 0 | RouteNode result = null; |
455 | |
|
456 | 0 | if (routeNodeId != null) { |
457 | |
|
458 | 0 | if (!routeNodes.containsKey(routeNodeId)) { |
459 | 0 | result = new RouteNode(); |
460 | 0 | result.setRouteNodeId(routeNodeId); |
461 | 0 | routeNodes.put(routeNodeId, result); |
462 | |
} else { |
463 | 0 | result = routeNodes.get(routeNodeId); |
464 | |
} |
465 | |
} |
466 | 0 | return result; |
467 | |
} |
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
public RouteNodeInstance getRouteNodeInstance(Long routeNodeInstanceId) { |
476 | 0 | RouteNodeInstance result = null; |
477 | |
|
478 | 0 | if (routeNodeInstanceId != null) { |
479 | |
|
480 | 0 | if (!routeNodeInstances.containsKey(routeNodeInstanceId)) { |
481 | 0 | result = new RouteNodeInstance(); |
482 | 0 | result.setRouteNodeInstanceId(routeNodeInstanceId); |
483 | 0 | routeNodeInstances.put(routeNodeInstanceId, result); |
484 | |
} else { |
485 | 0 | result = routeNodeInstances.get(routeNodeInstanceId); |
486 | |
} |
487 | |
} |
488 | 0 | return result; |
489 | |
} |
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
private NodeState getNodeState(Long nodeStateId) { |
498 | 0 | NodeState result = null; |
499 | |
|
500 | 0 | if (nodeStateId != null) { |
501 | |
|
502 | 0 | if (!nodeStates.containsKey(nodeStateId)) { |
503 | 0 | result = new NodeState(); |
504 | 0 | result.setNodeStateId(nodeStateId); |
505 | 0 | nodeStates.put(nodeStateId, result); |
506 | |
} else { |
507 | 0 | result = nodeStates.get(nodeStateId); |
508 | |
} |
509 | |
} |
510 | 0 | return result; |
511 | |
} |
512 | |
|
513 | |
} |
514 | |
|
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
|
520 | |
public ActionForward logActionMessageInRouteLog(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
521 | |
HttpServletResponse response) throws Exception { |
522 | 0 | RouteLogForm routeLogForm = (RouteLogForm) form; |
523 | |
|
524 | 0 | Long routeHeaderId = null; |
525 | 0 | if (!org.apache.commons.lang.StringUtils.isEmpty(routeLogForm.getRouteHeaderId())) { |
526 | 0 | routeHeaderId = new Long(routeLogForm.getRouteHeaderId()); |
527 | 0 | } else if (!org.apache.commons.lang.StringUtils.isEmpty(routeLogForm.getDocId())) { |
528 | 0 | routeHeaderId = new Long(routeLogForm.getDocId()); |
529 | |
} else { |
530 | 0 | throw new WorkflowRuntimeException("No paramater provided to fetch document"); |
531 | |
} |
532 | |
|
533 | 0 | DocumentRouteHeaderValue routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(routeHeaderId); |
534 | |
|
535 | |
|
536 | 0 | boolean isAuthorizedToAddRouteLogMessage = KEWServiceLocator.getDocumentTypePermissionService() |
537 | |
.canAddRouteLogMessage(GlobalVariables.getUserSession().getPrincipalId(), routeHeader); |
538 | |
|
539 | 0 | if (!isAuthorizedToAddRouteLogMessage) { |
540 | 0 | throw new InvalidActionTakenException("Principal with name '" |
541 | |
+ GlobalVariables.getUserSession().getPrincipalName() |
542 | |
+ "' is not authorized to add route log messages for documents of type '" |
543 | |
+ routeHeader.getDocumentType().getName()); |
544 | |
} |
545 | |
|
546 | 0 | LOG.info("Logging new action message for user " + GlobalVariables.getUserSession().getPrincipalName() |
547 | |
+ ", route header id " + routeHeader); |
548 | 0 | KEWServiceLocator.getWorkflowDocumentService().logDocumentAction( |
549 | |
GlobalVariables.getUserSession().getPrincipalId(), routeHeader, |
550 | |
routeLogForm.getNewRouteLogActionMessage()); |
551 | |
|
552 | 0 | routeLogForm.setNewRouteLogActionMessage(""); |
553 | |
|
554 | |
|
555 | 0 | routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(routeHeaderId, true); |
556 | 0 | fixActionRequestsPositions(routeHeader); |
557 | 0 | request.setAttribute("routeHeader", routeHeader); |
558 | |
|
559 | 0 | return mapping.findForward(getDefaultMapping()); |
560 | |
} |
561 | |
|
562 | |
} |