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