1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.service.ws.impl;
17
18 import org.apache.log4j.Logger;
19 import org.kuali.rice.core.api.util.xml.XmlException;
20 import org.kuali.rice.ken.bo.NotificationResponseBo;
21 import org.kuali.rice.ken.service.NotificationMessageContentService;
22 import org.kuali.rice.ken.service.NotificationService;
23 import org.kuali.rice.ken.service.ws.NotificationWebService;
24 import org.kuali.rice.ken.util.NotificationConstants;
25 import org.kuali.rice.ken.util.PerformanceLog;
26 import org.kuali.rice.ken.util.PerformanceLog.PerformanceStopWatch;
27
28 import java.io.IOException;
29 import java.rmi.RemoteException;
30
31
32
33
34
35
36
37
38
39 public class NotificationWebServiceImpl
40 private static final Logger LOG = Logger.getLogger(NotificationWebServiceImpl.class);
41
42 private NotificationService notificationService;
43 private NotificationMessageContentService notificationMessageContentService;
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 public String sendNotification(String notificationMessageAsXml) throws RemoteException {
61 PerformanceStopWatch watch = PerformanceLog.startTimer("Time to send notification from web service");
62
63 NotificationResponseBo response;
64 try {
65 response = notificationService.sendNotification(notificationMessageAsXml);
66
67 } catch(IOException ioe) {
68 response = new NotificationResponseBo();
69 response.setStatus(NotificationConstants.RESPONSE_STATUSES.FAILURE);
70 response.setMessage("Failed to process the message content: " + ioe.getMessage());
71 LOG.error("Failed to process the message content", ioe);
72 } catch(XmlException ixe) {
73 response = new NotificationResponseBo();
74 response.setStatus(NotificationConstants.RESPONSE_STATUSES.FAILURE);
75 response.setMessage("Failed to process the message content because the XML message provided to the system was invalid: " + ixe.getMessage());
76 LOG.error("Failed to process the message content because the XML message provided to the system was invalid", ixe);
77 }
78
79 String responseAsXml = notificationMessageContentService.generateNotificationResponseMessage(response);
80
81 watch.recordDuration();
82
83 LOG.info("Notification response: " + response);
84
85 return responseAsXml;
86 }
87 }