1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.ken.postprocessor.kew; |
18 | |
|
19 | |
import java.rmi.RemoteException; |
20 | |
|
21 | |
import org.apache.log4j.Logger; |
22 | |
import org.kuali.rice.core.framework.persistence.dao.GenericDao; |
23 | |
import org.kuali.rice.ken.bo.Notification; |
24 | |
import org.kuali.rice.ken.core.GlobalNotificationServiceLocator; |
25 | |
import org.kuali.rice.ken.document.kew.NotificationWorkflowDocument; |
26 | |
import org.kuali.rice.ken.service.NotificationMessageContentService; |
27 | |
import org.kuali.rice.ken.service.NotificationService; |
28 | |
import org.kuali.rice.ken.util.Util; |
29 | |
import org.kuali.rice.kew.api.WorkflowDocument; |
30 | |
import org.kuali.rice.kew.dto.ActionTakenEventDTO; |
31 | |
import org.kuali.rice.kew.dto.AfterProcessEventDTO; |
32 | |
import org.kuali.rice.kew.dto.BeforeProcessEventDTO; |
33 | |
import org.kuali.rice.kew.dto.DeleteEventDTO; |
34 | |
import org.kuali.rice.kew.dto.DocumentLockingEventDTO; |
35 | |
import org.kuali.rice.kew.dto.DocumentRouteLevelChangeDTO; |
36 | |
import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO; |
37 | |
import org.kuali.rice.kew.postprocessor.PostProcessorRemote; |
38 | |
import org.kuali.rice.kew.util.KEWConstants; |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public class NotificationSenderFormPostProcessor implements PostProcessorRemote { |
47 | 0 | private static final Logger LOG = Logger.getLogger(NotificationSenderFormPostProcessor.class); |
48 | |
|
49 | |
NotificationService notificationService; |
50 | |
GenericDao businessObjectDao; |
51 | |
NotificationMessageContentService messageContentService; |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | 0 | public NotificationSenderFormPostProcessor() { |
57 | 0 | this.notificationService = GlobalNotificationServiceLocator.getInstance().getNotificationService(); |
58 | 0 | this.businessObjectDao = GlobalNotificationServiceLocator.getInstance().getGenericDao(); |
59 | 0 | this.messageContentService = GlobalNotificationServiceLocator.getInstance().getNotificationMessageContentService(); |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | 0 | public NotificationSenderFormPostProcessor(NotificationService notificationService, GenericDao businessObjectDao) { |
68 | 0 | this.notificationService = notificationService; |
69 | 0 | this.businessObjectDao = businessObjectDao; |
70 | 0 | } |
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public boolean doActionTaken(ActionTakenEventDTO arg0) throws RemoteException { |
76 | 0 | return true; |
77 | |
} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
public boolean doDeleteRouteHeader(DeleteEventDTO arg0) throws RemoteException { |
83 | 0 | return true; |
84 | |
} |
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public boolean doRouteLevelChange(DocumentRouteLevelChangeDTO arg0) throws RemoteException { |
90 | 0 | return true; |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public boolean doRouteStatusChange(DocumentRouteStatusChangeDTO arg0) throws RemoteException { |
99 | 0 | LOG.debug("ENTERING NotificationSenderFormPostProcessor.doRouteStatusChange() for Notification Sender Form with document ID: " + arg0.getDocumentId()); |
100 | |
|
101 | 0 | if(arg0.getNewRouteStatus().equals(KEWConstants.ROUTE_HEADER_PROCESSED_CD)) { |
102 | 0 | LOG.debug("Workflow status has changed to RESOLVED for Notification Sender Form with document ID: " + arg0.getDocumentId() + |
103 | |
". We are now calling the NotificationService.sendNotification() service."); |
104 | |
|
105 | |
|
106 | |
|
107 | 0 | String proxyUserId = Util.getNotificationSystemUser(); |
108 | |
|
109 | |
|
110 | |
WorkflowDocument document; |
111 | |
try { |
112 | 0 | document = NotificationWorkflowDocument.loadNotificationDocument(proxyUserId, arg0.getDocumentId()); |
113 | |
|
114 | 0 | LOG.debug("XML:" + document.getApplicationContent()); |
115 | |
|
116 | |
|
117 | 0 | Notification notification = messageContentService.parseSerializedNotificationXml(document.getApplicationContent().getBytes()); |
118 | |
|
119 | 0 | LOG.debug("Notification Content: " + notification.getContent()); |
120 | |
|
121 | |
|
122 | 0 | notificationService.sendNotification(notification); |
123 | |
|
124 | 0 | LOG.debug("NotificationService.sendNotification() was successfully called for Notification Sender Form with document ID: " + arg0.getDocumentId()); |
125 | 0 | } catch(Exception e) { |
126 | 0 | throw new RuntimeException(e); |
127 | 0 | } |
128 | |
} |
129 | |
|
130 | 0 | LOG.debug("LEAVING NotificationSenderFormPostProcessor.doRouteStatusChange() for Notification Sender Form with document ID: " + arg0.getDocumentId()); |
131 | 0 | return true; |
132 | |
} |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
public boolean beforeProcess(BeforeProcessEventDTO beforeProcessEvent) throws Exception { |
138 | 0 | return true; |
139 | |
} |
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
public boolean afterProcess(AfterProcessEventDTO afterProcessEvent) throws Exception { |
145 | 0 | return true; |
146 | |
} |
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
public String[] getDocumentIdsToLock(DocumentLockingEventDTO documentLockingEvent) throws Exception { |
152 | 0 | return null; |
153 | |
} |
154 | |
|
155 | |
} |