1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.deliverer.impl;
17
18 import java.util.HashMap;
19 import java.util.LinkedHashMap;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.log4j.Logger;
23 import org.kuali.rice.kcb.bo.MessageDelivery;
24 import org.kuali.rice.kcb.deliverer.MessageDeliverer;
25 import org.kuali.rice.kcb.exception.ErrorList;
26 import org.kuali.rice.kcb.api.exception.MessageDeliveryException;
27 import org.kuali.rice.kcb.api.exception.MessageDismissalException;
28
29
30
31
32
33
34 public class SMSMessageDeliverer implements MessageDeliverer {
35 private static Logger LOG = Logger.getLogger(SMSMessageDeliverer.class);
36
37 private static final String MOBILE_NUMBER = "sms_mobile_number";
38
39
40
41
42 public SMSMessageDeliverer() {
43 }
44
45
46
47
48 public void deliver(MessageDelivery messageDelivery) throws MessageDeliveryException {
49 }
50
51
52
53
54
55
56
57
58
59
60
61 public void dismiss(MessageDelivery messageDelivery, String user, String cause) throws MessageDismissalException {
62
63 }
64
65
66
67
68 public String getDescription() {
69 return "This is the default SMS message delivery type. Please note that you may incur charges for each SMS message that you receive to your mobile phone.";
70 }
71
72
73
74
75 public String getName() {
76 return "SMS";
77 }
78
79
80
81
82 public String getTitle() {
83 return "SMS Message Delivery";
84 }
85
86
87
88
89
90 public LinkedHashMap getPreferenceKeys() {
91 LinkedHashMap<String, String> prefKeys = new LinkedHashMap<String, String>();
92 prefKeys.put(MOBILE_NUMBER, "Mobile Phone Number (\"555-555-5555\")");
93 return prefKeys;
94 }
95
96
97
98
99 public void validatePreferenceValues(HashMap prefs) throws ErrorList {
100 boolean error = false;
101 ErrorList errorList = new ErrorList();
102
103 if (!prefs.containsKey(getName()+"."+MOBILE_NUMBER)) {
104 errorList.addError("Mobile Phone Number is a required field.");
105 error = true;
106 } else {
107 String mobileNumber = (String) prefs.get(getName()+"."+MOBILE_NUMBER);
108 if(StringUtils.isBlank(mobileNumber)) {
109 errorList.addError("Mobile Phone Number is a required.");
110 error = true;
111 }
112 }
113 if (error) throw errorList;
114 }
115 }