Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MailConfiguration |
|
| 1.0689655172413792;1,069 |
1 | package pt.digitalis.dif.utils.mail; | |
2 | ||
3 | import java.util.Properties; | |
4 | ||
5 | import pt.digitalis.dif.ioc.DIFIoCRegistry; | |
6 | import pt.digitalis.utils.config.ConfigurationsPreferencesImpl; | |
7 | import pt.digitalis.utils.config.IConfigurations; | |
8 | import pt.digitalis.utils.config.annotations.ConfigDefault; | |
9 | import pt.digitalis.utils.config.annotations.ConfigID; | |
10 | import pt.digitalis.utils.config.annotations.ConfigIgnore; | |
11 | import pt.digitalis.utils.config.annotations.ConfigSectionID; | |
12 | ||
13 | /** | |
14 | * @author Galaio da Silva <a href="mailto:jgalaio@digitalis.pt">jgalaio@digitalis.pt</a><br/> | |
15 | * @created May 24, 2012 | |
16 | */ | |
17 | @ConfigID(MailConfiguration.CONFIG_ID) | |
18 | @ConfigSectionID(MailConfiguration.CONFIG_SECTION_ID) | |
19 | 0 | public class MailConfiguration implements IMailConfiguration { |
20 | ||
21 | /** The Constant CONFIG_ID. */ | |
22 | public static final String CONFIG_ID = "Digi Utils"; | |
23 | ||
24 | /** The Constant CONFIG_SECTION_ID. */ | |
25 | public static final String CONFIG_SECTION_ID = "mail"; | |
26 | ||
27 | /** the singleton instance. */ | |
28 | 0 | private static MailConfiguration instance = null; |
29 | ||
30 | /** | |
31 | * @return {@link MailConfiguration} | |
32 | */ | |
33 | @ConfigIgnore | |
34 | public static IMailConfiguration getInstance() | |
35 | { | |
36 | 0 | if (instance == null) |
37 | { | |
38 | 0 | instance = new ConfigurationsPreferencesImpl().readConfiguration(MailConfiguration.class); |
39 | 0 | instance.setOriginalConfs(instance.getConfigurations().readConfiguration(CONFIG_ID, CONFIG_SECTION_ID)); |
40 | } | |
41 | 0 | return instance; |
42 | } | |
43 | ||
44 | /** The configuration manager instance. */ | |
45 | private IConfigurations configurations; | |
46 | ||
47 | /** Determines if the debug is enabled. */ | |
48 | private String debugEnabled; | |
49 | ||
50 | /** The default from ail address. */ | |
51 | private String defaultFromAddress; | |
52 | ||
53 | /** The charater encoding */ | |
54 | private String encoding; | |
55 | ||
56 | /** The Gab Between Mails */ | |
57 | private int gapBetweenMails; | |
58 | ||
59 | /** The Limit Max Emails */ | |
60 | private int limitMaxEmails; | |
61 | ||
62 | /** The Limit Time Interval */ | |
63 | private int limitTimeInterval; | |
64 | ||
65 | /** The mail server. */ | |
66 | private String mailServer; | |
67 | ||
68 | /** The mail server security password. */ | |
69 | private String mailServerPassword; | |
70 | ||
71 | /** The mail server port. */ | |
72 | private int mailServerPort; | |
73 | ||
74 | /** The mail server security username. */ | |
75 | private String mailServerUsername; | |
76 | ||
77 | /** The original confs. */ | |
78 | 0 | private Properties originalConfs = null; |
79 | ||
80 | /** The use ssl. */ | |
81 | private Boolean useSSL; | |
82 | ||
83 | /** | |
84 | * MailConfiguration Construtor | |
85 | */ | |
86 | 0 | public MailConfiguration() |
87 | { | |
88 | ||
89 | 0 | } |
90 | ||
91 | /** | |
92 | * Gets the configurations. | |
93 | * | |
94 | * @return the configurations | |
95 | */ | |
96 | @ConfigIgnore | |
97 | public IConfigurations getConfigurations() | |
98 | { | |
99 | ||
100 | 0 | if (configurations == null) |
101 | 0 | configurations = DIFIoCRegistry.getRegistry().getImplementation(IConfigurations.class); |
102 | ||
103 | 0 | return configurations; |
104 | } | |
105 | ||
106 | /** | |
107 | * Inspector for the 'debugEnabled' attribute. | |
108 | * | |
109 | * @return the debugEnabled value | |
110 | */ | |
111 | @ConfigDefault("false") | |
112 | public String getDebugEnabled() | |
113 | { | |
114 | 0 | return debugEnabled; |
115 | } | |
116 | ||
117 | /** | |
118 | * Inspector for the 'defaultFromAddress' attribute. | |
119 | * | |
120 | * @return the defaultFromAddress value | |
121 | */ | |
122 | @ConfigDefault("no-reply@company.com") | |
123 | public String getDefaultFromAddress() | |
124 | { | |
125 | 0 | return defaultFromAddress; |
126 | } | |
127 | ||
128 | /** | |
129 | * Inspector for the 'enconding' attribute. | |
130 | * | |
131 | * @return the enconding value | |
132 | */ | |
133 | @ConfigDefault("ISO-8859-1") | |
134 | public String getEncoding() | |
135 | { | |
136 | 0 | return encoding; |
137 | } | |
138 | ||
139 | /** | |
140 | * Inspector for the 'GapBetweenMails' attribute. | |
141 | * | |
142 | * @return the gapBetweenMails value | |
143 | */ | |
144 | @ConfigDefault("0") | |
145 | public int getGapBetweenMails() | |
146 | { | |
147 | 0 | return gapBetweenMails; |
148 | } | |
149 | ||
150 | /** | |
151 | * Inspector for the 'LimitMaxEmails' attribute. | |
152 | * | |
153 | * @return the limitMaxEmails value | |
154 | */ | |
155 | @ConfigDefault("0") | |
156 | public int getLimitMaxEmails() | |
157 | { | |
158 | 0 | return limitMaxEmails; |
159 | } | |
160 | ||
161 | /** | |
162 | * Inspector for the 'LimitTimeInterval' attribute. | |
163 | * | |
164 | * @return the limitTimeInterval value | |
165 | */ | |
166 | @ConfigDefault("0") | |
167 | public int getLimitTimeInterval() | |
168 | { | |
169 | 0 | return limitTimeInterval; |
170 | } | |
171 | ||
172 | /** | |
173 | * Inspector for the 'mailServer' attribute. | |
174 | * | |
175 | * @return the mailServer value | |
176 | */ | |
177 | @ConfigDefault("domino.digitalis.pt") | |
178 | public String getMailServer() | |
179 | { | |
180 | 0 | return mailServer; |
181 | } | |
182 | ||
183 | /** | |
184 | * Inspector for the 'mailServerPassword' attribute. | |
185 | * | |
186 | * @return the mailServerPassword value | |
187 | */ | |
188 | public String getMailServerPassword() | |
189 | { | |
190 | 0 | return mailServerPassword; |
191 | } | |
192 | ||
193 | /** | |
194 | * Inspector for the 'mailServerPort' attribute. | |
195 | * | |
196 | * @return the mailServerPort value | |
197 | */ | |
198 | public int getMailServerPort() | |
199 | { | |
200 | 0 | return mailServerPort; |
201 | } | |
202 | ||
203 | /** | |
204 | * Inspector for the 'mailServerUsername' attribute. | |
205 | * | |
206 | * @return the mailServerUsername value | |
207 | */ | |
208 | public String getMailServerUsername() | |
209 | { | |
210 | 0 | return mailServerUsername; |
211 | } | |
212 | ||
213 | /** | |
214 | * Inspector for the 'originalConfs' attribute. | |
215 | * | |
216 | * @return the originalConfs value | |
217 | */ | |
218 | @ConfigIgnore | |
219 | public Properties getOriginalConfs() | |
220 | { | |
221 | 0 | return originalConfs; |
222 | } | |
223 | ||
224 | /** | |
225 | * Inspector for the 'useSSL' attribute. | |
226 | * | |
227 | * @return the useSSL value | |
228 | */ | |
229 | @ConfigDefault("false") | |
230 | public Boolean getUseSSL() | |
231 | { | |
232 | 0 | return useSSL; |
233 | } | |
234 | ||
235 | /** | |
236 | * Modifier for the 'configurations' attribute. | |
237 | * | |
238 | * @param configurations | |
239 | * the new configurations value to set | |
240 | */ | |
241 | public void setConfigurations(IConfigurations configurations) | |
242 | { | |
243 | 0 | this.configurations = configurations; |
244 | 0 | } |
245 | ||
246 | /** | |
247 | * Modifier for the 'debugEnabled' attribute. | |
248 | * | |
249 | * @param debugEnabled | |
250 | * the new debugEnabled value to set | |
251 | */ | |
252 | public void setDebugEnabled(String debugEnabled) | |
253 | { | |
254 | 0 | this.debugEnabled = debugEnabled; |
255 | 0 | } |
256 | ||
257 | /** | |
258 | * Modifier for the 'defaultFromAddress' attribute. | |
259 | * | |
260 | * @param defaultFromAddress | |
261 | * the new defaultFromAddress value to set | |
262 | */ | |
263 | public void setDefaultFromAddress(String defaultFromAddress) | |
264 | { | |
265 | 0 | this.defaultFromAddress = defaultFromAddress; |
266 | 0 | } |
267 | ||
268 | /** | |
269 | * Modifier for the 'enconding' attribute. | |
270 | * | |
271 | * @param enconding | |
272 | * the new enconding value to set | |
273 | */ | |
274 | public void setEncoding(String enconding) | |
275 | { | |
276 | 0 | this.encoding = enconding; |
277 | 0 | } |
278 | ||
279 | /** | |
280 | * Modifier for the 'GapBetweenMails' attribute. | |
281 | * | |
282 | * @param gapBetweenMails | |
283 | * the new gapBetweenMails value to set | |
284 | */ | |
285 | public void setGapBetweenMails(int gapBetweenMails) | |
286 | { | |
287 | 0 | this.gapBetweenMails = gapBetweenMails; |
288 | 0 | } |
289 | ||
290 | /** | |
291 | * Modifier for the 'LimitMaxEmails' attribute. | |
292 | * | |
293 | * @param limitMaxEmails | |
294 | * the new limitMaxEmails value to set | |
295 | */ | |
296 | public void setLimitMaxEmails(int limitMaxEmails) | |
297 | { | |
298 | 0 | this.limitMaxEmails = limitMaxEmails; |
299 | 0 | } |
300 | ||
301 | /** | |
302 | * Modifier for the 'LimitTimeInterval' attribute. | |
303 | * | |
304 | * @param limitTimeInterval | |
305 | * the new limitTimeInterval value to set | |
306 | */ | |
307 | public void setLimitTimeInterval(int limitTimeInterval) | |
308 | { | |
309 | 0 | this.limitTimeInterval = limitTimeInterval; |
310 | 0 | } |
311 | ||
312 | /** | |
313 | * Modifier for the 'mailServer' attribute. | |
314 | * | |
315 | * @param mailServer | |
316 | * the new mailServer value to set | |
317 | */ | |
318 | public void setMailServer(String mailServer) | |
319 | { | |
320 | 0 | this.mailServer = mailServer; |
321 | 0 | } |
322 | ||
323 | /** | |
324 | * Modifier for the 'mailServerPassword' attribute. | |
325 | * | |
326 | * @param mailServerPassword | |
327 | * the new mailServerPassword value to set | |
328 | */ | |
329 | public void setMailServerPassword(String mailServerPassword) | |
330 | { | |
331 | 0 | this.mailServerPassword = mailServerPassword; |
332 | 0 | } |
333 | ||
334 | /** | |
335 | * Modifier for the 'mailServerPort' attribute. | |
336 | * | |
337 | * @param mailServerPort | |
338 | * the new mailServerPort value to set | |
339 | */ | |
340 | public void setMailServerPort(int mailServerPort) | |
341 | { | |
342 | 0 | this.mailServerPort = mailServerPort; |
343 | 0 | } |
344 | ||
345 | /** | |
346 | * Modifier for the 'mailServerUsername' attribute. | |
347 | * | |
348 | * @param mailServerUsername | |
349 | * the new mailServerUsername value to set | |
350 | */ | |
351 | public void setMailServerUsername(String mailServerUsername) | |
352 | { | |
353 | 0 | this.mailServerUsername = mailServerUsername; |
354 | 0 | } |
355 | ||
356 | /** | |
357 | * Modifier for the 'originalConfs' attribute. | |
358 | * | |
359 | * @param originalConfs | |
360 | * the new originalConfs value to set | |
361 | */ | |
362 | public void setOriginalConfs(Properties originalConfs) | |
363 | { | |
364 | 0 | this.originalConfs = originalConfs; |
365 | 0 | } |
366 | ||
367 | /** | |
368 | * Modifier for the 'useSSL' attribute. | |
369 | * | |
370 | * @param useSSL | |
371 | * the new useSSL value to set | |
372 | */ | |
373 | public void setUseSSL(Boolean useSSL) | |
374 | { | |
375 | 0 | this.useSSL = useSSL; |
376 | 0 | } |
377 | ||
378 | /** | |
379 | * Write configuration | |
380 | * | |
381 | * @throws Exception | |
382 | */ | |
383 | public void writeConfiguration() throws Exception | |
384 | { | |
385 | 0 | this.getConfigurations().writeConfiguration(this); |
386 | ||
387 | 0 | } |
388 | } |