1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.routemanager;
17
18 import java.util.List;
19
20 import org.kuali.rice.kew.framework.postprocessor.ActionTakenEvent;
21 import org.kuali.rice.kew.framework.postprocessor.AfterProcessEvent;
22 import org.kuali.rice.kew.framework.postprocessor.BeforeProcessEvent;
23 import org.kuali.rice.kew.framework.postprocessor.DeleteEvent;
24 import org.kuali.rice.kew.framework.postprocessor.DocumentLockingEvent;
25 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteLevelChange;
26 import org.kuali.rice.kew.framework.postprocessor.DocumentRouteStatusChange;
27 import org.kuali.rice.kew.framework.postprocessor.PostProcessor;
28 import org.kuali.rice.kew.framework.postprocessor.ProcessDocReport;
29 import org.kuali.rice.kew.api.KewApiConstants;
30
31
32 public class ExceptionRoutingTestPostProcessor implements PostProcessor {
33
34 public static boolean THROW_ROUTE_STATUS_CHANGE_EXCEPTION;
35 public static boolean THROW_ROUTE_STATUS_LEVEL_EXCEPTION;
36 public static boolean THROW_ROUTE_DELETE_ROUTE_HEADER_EXCEPTION;
37 public static boolean THROW_DO_ACTION_TAKEN_EXCEPTION;
38 public static boolean THROW_BEFORE_PROCESS_EXCEPTION;
39 public static boolean THROW_AFTER_PROCESS_EXCEPTION;
40 public static boolean THROW_DOCUMENT_LOCKING_EXCEPTION;
41 public static boolean TRANSITIONED_OUT_OF_EXCEPTION_ROUTING = false;
42 public static boolean BLOW_UP_ON_TRANSITION_INTO_EXCEPTION = false;
43
44 public ProcessDocReport doRouteStatusChange(DocumentRouteStatusChange statusChangeEvent) throws Exception {
45
46
47
48 boolean transitioningIntoException = !KewApiConstants.ROUTE_HEADER_EXCEPTION_CD.equals(statusChangeEvent.getOldRouteStatus()) &&
49 KewApiConstants.ROUTE_HEADER_EXCEPTION_CD.equals(statusChangeEvent.getNewRouteStatus());
50 if (THROW_ROUTE_STATUS_CHANGE_EXCEPTION && !transitioningIntoException) {
51 throw new RuntimeException("I am the doRouteStatusChange exploder");
52 }
53 if (BLOW_UP_ON_TRANSITION_INTO_EXCEPTION && transitioningIntoException) {
54 throw new RuntimeException("Throwing an exception when transitioning into exception status.");
55 }
56 if (KewApiConstants.ROUTE_HEADER_EXCEPTION_CD.equals(statusChangeEvent.getOldRouteStatus())) {
57 TRANSITIONED_OUT_OF_EXCEPTION_ROUTING = true;
58 }
59 return new ProcessDocReport(true, "");
60 }
61
62 public ProcessDocReport doRouteLevelChange(DocumentRouteLevelChange levelChangeEvent) throws Exception {
63 if (THROW_ROUTE_STATUS_LEVEL_EXCEPTION) {
64 throw new RuntimeException("I am the doRouteLevelChange exploder");
65 }
66 return new ProcessDocReport(true, "");
67 }
68
69 public ProcessDocReport doDeleteRouteHeader(DeleteEvent event) throws Exception {
70 if (THROW_ROUTE_DELETE_ROUTE_HEADER_EXCEPTION) {
71 throw new RuntimeException("I am the doDeleteRouteHeader exploder");
72 }
73 return new ProcessDocReport(true, "");
74 }
75
76 public ProcessDocReport doActionTaken(ActionTakenEvent event) throws Exception {
77 if (THROW_DO_ACTION_TAKEN_EXCEPTION) {
78 throw new RuntimeException("I am the doActionTaken exploder");
79 }
80 return new ProcessDocReport(true, "");
81 }
82
83 public ProcessDocReport beforeProcess(BeforeProcessEvent event) throws Exception {
84 if (THROW_BEFORE_PROCESS_EXCEPTION) {
85 throw new RuntimeException("I am the beforeProcess exploder");
86 }
87 return new ProcessDocReport(true, "");
88 }
89
90 public ProcessDocReport afterProcess(AfterProcessEvent event) throws Exception {
91 if (THROW_AFTER_PROCESS_EXCEPTION) {
92 throw new RuntimeException("I am the afterProcess exploder");
93 }
94 return new ProcessDocReport(true, "");
95 }
96
97 public List<String> getDocumentIdsToLock(DocumentLockingEvent lockingEvent)
98 throws Exception {
99 if (THROW_DOCUMENT_LOCKING_EXCEPTION) {
100 throw new RuntimeException("I am the getDocumentIdsToLock exploder");
101 }
102 return null;
103 }
104
105
106
107 }