1 | |
package org.kuali.rice.kim.api.identity.email; |
2 | |
|
3 | |
import org.apache.commons.lang.StringUtils; |
4 | |
import org.kuali.rice.core.api.CoreConstants; |
5 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
6 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
7 | |
import org.kuali.rice.kim.api.KimConstants; |
8 | |
import org.kuali.rice.kim.api.identity.Type; |
9 | |
|
10 | |
import javax.xml.bind.Element; |
11 | |
import javax.xml.bind.annotation.XmlAccessType; |
12 | |
import javax.xml.bind.annotation.XmlAccessorType; |
13 | |
import javax.xml.bind.annotation.XmlAnyElement; |
14 | |
import javax.xml.bind.annotation.XmlElement; |
15 | |
import javax.xml.bind.annotation.XmlRootElement; |
16 | |
import javax.xml.bind.annotation.XmlType; |
17 | |
import java.io.Serializable; |
18 | |
import java.util.Collection; |
19 | |
|
20 | 21 | @XmlRootElement(name = EntityEmail.Constants.ROOT_ELEMENT_NAME) |
21 | |
@XmlAccessorType(XmlAccessType.NONE) |
22 | |
@XmlType(name = EntityEmail.Constants.TYPE_NAME, propOrder = { |
23 | |
EntityEmail.Elements.ID, |
24 | |
EntityEmail.Elements.ENTITY_TYPE_CODE, |
25 | |
EntityEmail.Elements.ENTITY_ID, |
26 | |
EntityEmail.Elements.EMAIL_TYPE, |
27 | |
EntityEmail.Elements.EMAIL_ADDRESS, |
28 | |
EntityEmail.Elements.EMAIL_ADDRESS_UNMASKED, |
29 | |
EntityEmail.Elements.SUPPRESS_EMAIL, |
30 | |
EntityEmail.Elements.DEFAULT_VALUE, |
31 | |
EntityEmail.Elements.ACTIVE, |
32 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
33 | |
CoreConstants.CommonElements.OBJECT_ID, |
34 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
35 | |
}) |
36 | 13 | public class EntityEmail extends AbstractDataTransferObject implements EntityEmailContract{ |
37 | |
|
38 | |
@XmlElement(name = Elements.ID, required = false) |
39 | |
private final String id; |
40 | |
@XmlElement(name = Elements.ENTITY_TYPE_CODE, required = false) |
41 | |
private final String entityTypeCode; |
42 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
43 | |
private final String entityId; |
44 | |
@XmlElement(name = Elements.EMAIL_TYPE, required = false) |
45 | |
private final Type emailType; |
46 | |
@XmlElement(name = Elements.EMAIL_ADDRESS, required = false) |
47 | |
private final String emailAddress; |
48 | |
@XmlElement(name = Elements.EMAIL_ADDRESS_UNMASKED, required = false) |
49 | |
private final String emailAddressUnmasked; |
50 | |
@XmlElement(name = Elements.SUPPRESS_EMAIL, required = false) |
51 | |
private final boolean suppressEmail; |
52 | |
@XmlElement(name = Elements.DEFAULT_VALUE, required = false) |
53 | |
private final boolean defaultValue; |
54 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
55 | |
private final Long versionNumber; |
56 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
57 | |
private final String objectId; |
58 | |
@XmlElement(name = Elements.ACTIVE, required = false) |
59 | |
private final boolean active; |
60 | 23 | @SuppressWarnings("unused") |
61 | |
@XmlAnyElement |
62 | |
private final Collection<Element> _futureElements = null; |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | 10 | private EntityEmail() { |
69 | 10 | this.id = null; |
70 | 10 | this.entityId = null; |
71 | 10 | this.entityTypeCode = null; |
72 | 10 | this.emailType = null; |
73 | 10 | this.emailAddress = null; |
74 | 10 | this.emailAddressUnmasked = null; |
75 | 10 | this.suppressEmail = false; |
76 | 10 | this.defaultValue = false; |
77 | 10 | this.versionNumber = null; |
78 | 10 | this.objectId = null; |
79 | 10 | this.active = false; |
80 | 10 | } |
81 | |
|
82 | 13 | private EntityEmail(Builder builder) { |
83 | 13 | this.id = builder.getId(); |
84 | 13 | this.entityId = builder.getEntityId(); |
85 | 13 | this.entityTypeCode = builder.getEntityTypeCode(); |
86 | 13 | this.emailType = (builder.getEmailType() != null) ? builder.getEmailType().build() : null; |
87 | 13 | this.emailAddress = builder.getEmailAddress(); |
88 | 13 | this.emailAddressUnmasked = builder.getEmailAddressUnmasked(); |
89 | 13 | this.suppressEmail = builder.isSuppressEmail(); |
90 | 13 | this.defaultValue = builder.isDefaultValue(); |
91 | 13 | this.versionNumber = builder.getVersionNumber(); |
92 | 13 | this.objectId = builder.getObjectId(); |
93 | 13 | this.active = builder.isActive(); |
94 | 13 | } |
95 | |
|
96 | |
@Override |
97 | |
public String getId() { |
98 | 7 | return this.id; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public String getEntityId() { |
103 | 7 | return this.entityId; |
104 | |
} |
105 | |
|
106 | |
@Override |
107 | |
public String getEntityTypeCode() { |
108 | 7 | return this.entityTypeCode; |
109 | |
} |
110 | |
|
111 | |
@Override |
112 | |
public Type getEmailType() { |
113 | 21 | return this.emailType; |
114 | |
} |
115 | |
|
116 | |
@Override |
117 | |
public String getEmailAddress() { |
118 | 2 | return this.emailAddress; |
119 | |
} |
120 | |
|
121 | |
@Override |
122 | |
public String getEmailAddressUnmasked() { |
123 | 7 | return this.emailAddressUnmasked; |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public boolean isSuppressEmail() { |
128 | 7 | return this.suppressEmail; |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public boolean isDefaultValue() { |
133 | 7 | return this.defaultValue; |
134 | |
} |
135 | |
|
136 | |
@Override |
137 | |
public Long getVersionNumber() { |
138 | 7 | return this.versionNumber; |
139 | |
} |
140 | |
|
141 | |
@Override |
142 | |
public String getObjectId() { |
143 | 7 | return this.objectId; |
144 | |
} |
145 | |
|
146 | |
@Override |
147 | |
public boolean isActive() { |
148 | 7 | return this.active; |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | 5 | public final static class Builder |
156 | |
implements Serializable, ModelBuilder, EntityEmailContract |
157 | |
{ |
158 | |
|
159 | |
private String id; |
160 | |
private String entityId; |
161 | |
private String entityTypeCode; |
162 | |
private Type.Builder emailType; |
163 | |
private String emailAddressUnmasked; |
164 | |
private boolean suppressEmail; |
165 | |
private boolean defaultValue; |
166 | |
private Long versionNumber; |
167 | |
private String objectId; |
168 | |
private boolean active; |
169 | |
|
170 | 11 | private Builder() { |
171 | |
|
172 | 11 | } |
173 | |
|
174 | |
public static Builder create() { |
175 | 11 | return new Builder(); |
176 | |
} |
177 | |
|
178 | |
public static Builder create(EntityEmailContract contract) { |
179 | 8 | if (contract == null) { |
180 | 0 | throw new IllegalArgumentException("contract was null"); |
181 | |
} |
182 | 8 | Builder builder = create(); |
183 | 8 | builder.setId(contract.getId()); |
184 | 8 | builder.setEntityId(contract.getEntityId()); |
185 | 8 | builder.setEntityTypeCode(contract.getEntityTypeCode()); |
186 | 8 | builder.setSuppressEmail(contract.isSuppressEmail()); |
187 | 8 | if (contract.getEmailType() != null) { |
188 | 7 | builder.setEmailType(Type.Builder.create(contract.getEmailType())); |
189 | |
} |
190 | 8 | builder.setEmailAddress(contract.getEmailAddressUnmasked()); |
191 | 8 | builder.setDefaultValue(contract.isDefaultValue()); |
192 | 8 | builder.setVersionNumber(contract.getVersionNumber()); |
193 | 8 | builder.setObjectId(contract.getObjectId()); |
194 | 8 | builder.setActive(contract.isActive()); |
195 | 8 | return builder; |
196 | |
} |
197 | |
|
198 | |
public EntityEmail build() { |
199 | 13 | return new EntityEmail(this); |
200 | |
} |
201 | |
|
202 | |
@Override |
203 | |
public String getId() { |
204 | 13 | return this.id; |
205 | |
} |
206 | |
|
207 | |
@Override |
208 | |
public String getEntityTypeCode() { |
209 | 13 | return this.entityTypeCode; |
210 | |
} |
211 | |
|
212 | |
@Override |
213 | |
public String getEntityId() { |
214 | 13 | return this.entityId; |
215 | |
} |
216 | |
|
217 | |
@Override |
218 | |
public Type.Builder getEmailType() { |
219 | 24 | return this.emailType; |
220 | |
} |
221 | |
|
222 | |
@Override |
223 | |
public String getEmailAddress() { |
224 | 13 | if (isSuppressEmail()) { |
225 | 0 | return KimConstants.RestrictedMasks.RESTRICTED_DATA_MASK; |
226 | |
} |
227 | 13 | return this.emailAddressUnmasked; |
228 | |
} |
229 | |
|
230 | |
@Override |
231 | |
public String getEmailAddressUnmasked() { |
232 | 13 | return this.emailAddressUnmasked; |
233 | |
} |
234 | |
|
235 | |
@Override |
236 | |
public boolean isSuppressEmail() { |
237 | 26 | return this.suppressEmail; |
238 | |
} |
239 | |
|
240 | |
@Override |
241 | |
public boolean isDefaultValue() { |
242 | 21 | return this.defaultValue; |
243 | |
} |
244 | |
|
245 | |
@Override |
246 | |
public Long getVersionNumber() { |
247 | 13 | return this.versionNumber; |
248 | |
} |
249 | |
|
250 | |
@Override |
251 | |
public String getObjectId() { |
252 | 13 | return this.objectId; |
253 | |
} |
254 | |
|
255 | |
@Override |
256 | |
public boolean isActive() { |
257 | 21 | return this.active; |
258 | |
} |
259 | |
|
260 | |
public void setId(String id) { |
261 | 9 | if (StringUtils.isWhitespace(id)) { |
262 | 1 | throw new IllegalArgumentException("id is blank"); |
263 | |
} |
264 | 8 | this.id = id; |
265 | 8 | } |
266 | |
|
267 | |
public void setEntityTypeCode(String entityTypeCode) { |
268 | 8 | this.entityTypeCode = entityTypeCode; |
269 | 8 | } |
270 | |
|
271 | |
public void setEntityId(String entityId) { |
272 | 8 | this.entityId = entityId; |
273 | 8 | } |
274 | |
|
275 | |
public void setEmailType(Type.Builder emailType) { |
276 | 7 | this.emailType = emailType; |
277 | 7 | } |
278 | |
|
279 | |
public void setEmailAddress(String emailAddress) { |
280 | 8 | this.emailAddressUnmasked = emailAddress; |
281 | 8 | } |
282 | |
|
283 | |
private void setSuppressEmail(boolean suppressEmail) { |
284 | 8 | this.suppressEmail = suppressEmail; |
285 | 8 | } |
286 | |
|
287 | |
public void setDefaultValue(boolean defaultValue) { |
288 | 8 | this.defaultValue = defaultValue; |
289 | 8 | } |
290 | |
|
291 | |
public void setVersionNumber(Long versionNumber) { |
292 | 8 | this.versionNumber = versionNumber; |
293 | 8 | } |
294 | |
|
295 | |
public void setObjectId(String objectId) { |
296 | 8 | this.objectId = objectId; |
297 | 8 | } |
298 | |
|
299 | |
public void setActive(boolean active) { |
300 | 8 | this.active = active; |
301 | 8 | } |
302 | |
|
303 | |
} |
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
|
309 | |
|
310 | 0 | static class Constants { |
311 | |
|
312 | |
final static String ROOT_ELEMENT_NAME = "entityEmail"; |
313 | |
final static String TYPE_NAME = "EntityEmailType"; |
314 | |
} |
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
|
321 | 0 | static class Elements { |
322 | |
|
323 | |
final static String ID = "id"; |
324 | |
final static String ENTITY_TYPE_CODE = "entityTypeCode"; |
325 | |
final static String ENTITY_ID = "entityId"; |
326 | |
final static String EMAIL_TYPE = "emailType"; |
327 | |
final static String EMAIL_ADDRESS = "emailAddress"; |
328 | |
final static String EMAIL_ADDRESS_UNMASKED = "emailAddressUnmasked"; |
329 | |
final static String SUPPRESS_EMAIL = "suppressEmail"; |
330 | |
final static String DEFAULT_VALUE = "defaultValue"; |
331 | |
final static String ACTIVE = "active"; |
332 | |
|
333 | |
} |
334 | |
|
335 | |
} |