1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ken.service.impl;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
20 import org.kuali.rice.ken.api.notification.Notification;
21 import org.kuali.rice.ken.api.notification.NotificationResponse;
22 import org.kuali.rice.ken.api.service.SendNotificationService;
23 import org.kuali.rice.ken.bo.NotificationBo;
24 import org.kuali.rice.ken.bo.NotificationResponseBo;
25 import org.kuali.rice.ken.service.NotificationService;
26 import org.kuali.rice.kew.api.WorkflowRuntimeException;
27
28
29
30
31
32
33 public class SendNotificationServiceKewXmlImpl implements SendNotificationService {
34 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
35 .getLogger(SendNotificationServiceKewXmlImpl.class);
36
37 private final NotificationService notificationService;
38
39
40
41
42
43 public SendNotificationServiceKewXmlImpl(NotificationService notificationService) {
44 this.notificationService = notificationService;
45 }
46
47
48
49
50
51
52 @Override
53 public NotificationResponse invoke(String message) {
54 if (StringUtils.isBlank(message)) {
55 throw new RiceIllegalArgumentException("xml is null or blank");
56 }
57
58 try {
59 NotificationResponseBo response = notificationService.sendNotification(message);
60 LOG.info(response.getMessage());
61 return NotificationResponseBo.to(response);
62 } catch (Exception e) {
63 throw new WorkflowRuntimeException(e);
64 }
65 }
66
67 @Override
68 public NotificationResponse sendNotification(Notification notification) {
69 if (null == notification) {
70 throw new RiceIllegalArgumentException("xml is null or blank");
71 }
72
73 try {
74 NotificationBo notificationBo = NotificationBo.from(notification);
75 NotificationResponseBo response = notificationService.sendNotification(notificationBo);
76 LOG.info(response.getMessage());
77 return NotificationResponseBo.to(response);
78 } catch (Exception e) {
79 throw new IllegalStateException(e);
80 }
81 }
82 }