1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.messaging.exceptionhandling;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.kew.api.WorkflowRuntimeException;
20 import org.kuali.rice.kew.service.KEWServiceLocator;
21 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
22 import org.kuali.rice.ksb.messaging.exceptionhandling.DefaultMessageExceptionHandler;
23 import org.kuali.rice.ksb.messaging.exceptionhandling.MessageExceptionHandler;
24 import org.kuali.rice.ksb.service.KSBServiceLocator;
25
26
27
28
29
30
31
32 public class DocumentMessageExceptionHandler extends DefaultMessageExceptionHandler {
33
34 @Override
35 protected void placeInException(Throwable throwable, PersistedMessageBO message) throws Exception {
36 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRouting(throwable, message, getDocumentId(message));
37 }
38
39
40
41 @Override
42 public void handleExceptionLastDitchEffort(Throwable throwable, PersistedMessageBO message, Object service) throws Exception {
43 KEWServiceLocator.getExceptionRoutingService().placeInExceptionRoutingLastDitchEffort(throwable, message, getDocumentId(message));
44 }
45
46
47
48 @Override
49 protected void scheduleExecution(Throwable throwable, PersistedMessageBO message) throws Exception {
50 String description = "DocumentId: " + getDocumentId(message);
51 KSBServiceLocator.getExceptionRoutingService().scheduleExecution(throwable, message, description);
52 }
53
54 protected String getDocumentId(PersistedMessageBO message) {
55 if (!StringUtils.isEmpty(message.getValue1())) {
56 return message.getValue1();
57 }
58 throw new WorkflowRuntimeException("Unable to put this message in exception routing service name " + message.getServiceName());
59 }
60 }