1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.james.fetchmail;
23
24 import java.util.List;
25 import java.util.Set;
26
27 import javax.mail.MessagingException;
28 import javax.mail.Session;
29
30 import org.apache.avalon.framework.logger.Logger;
31 import org.apache.james.api.dnsservice.DNSService;
32 import org.apache.james.api.user.UsersRepository;
33 import org.apache.james.services.MailServer;
34 import org.apache.mailet.MailAddress;
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 abstract public class ProcessorAbstract
53 {
54
55
56
57 private String fieldAttributePrefix;
58
59
60
61
62 private Account fieldAccount;
63
64
65
66
67 private ProcessorAbstract()
68 {
69 super();
70 }
71
72
73
74
75
76 protected ProcessorAbstract(Account account)
77 {
78 this();
79 setAccount(account);
80 }
81
82
83
84
85
86 protected String getDefaultDomainName()
87 {
88 return getConfiguration().getDefaultDomainName();
89 }
90
91
92
93
94
95
96 protected String getDefaultLocalPart()
97 {
98
99 return "FETCHMAIL-SERVICE";
100 }
101
102
103
104
105
106
107 protected List getDeferredRecipientNotFoundMessageIDs()
108 {
109 return getAccount().getDeferredRecipientNotFoundMessageIDs();
110 }
111
112
113
114
115
116 protected String getFetchTaskName()
117 {
118 return getConfiguration().getFetchTaskName();
119 }
120
121
122
123
124
125
126 protected String getHost()
127 {
128 return getConfiguration().getHost();
129 }
130
131
132
133
134
135
136 protected String getJavaMailFolderName()
137 {
138 return getConfiguration().getJavaMailFolderName();
139 }
140
141
142
143
144
145
146
147 protected String getJavaMailProviderName()
148 {
149 return getConfiguration().getJavaMailProviderName();
150 }
151
152
153
154
155
156
157
158 protected Logger getLogger()
159 {
160 return getConfiguration().getLogger();
161 }
162
163
164
165
166
167
168 protected String getPassword()
169 {
170 return getAccount().getPassword();
171 }
172
173
174
175
176
177
178 protected MailAddress getRecipient()
179 {
180 return getAccount().getRecipient();
181 }
182
183
184
185
186
187 protected int getRemoteReceivedHeaderIndex()
188 {
189 return getConfiguration().getRemoteReceivedHeaderIndex();
190 }
191
192
193
194
195
196
197 protected MailServer getServer()
198 {
199 return getConfiguration().getServer();
200 }
201
202
203
204
205
206 protected DNSService getDNSServer()
207 {
208 return getConfiguration().getDNSServer();
209 }
210
211
212
213
214
215 protected Session getSession()
216 {
217 return getAccount().getSession();
218 }
219
220
221
222
223
224 protected UsersRepository getLocalUsers()
225 {
226 return getConfiguration().getLocalUsers();
227 }
228
229
230
231
232
233
234 protected String getUser()
235 {
236 return getAccount().getUser();
237 }
238
239
240
241
242
243
244 protected boolean isFetchAll()
245 {
246 return getConfiguration().isFetchAll();
247 }
248
249
250
251
252
253
254 protected boolean isDeferRecipientNotFound()
255 {
256 return getConfiguration().isDeferRecipientNotFound();
257 }
258
259
260
261
262
263 protected boolean isIgnoreRecipientHeader()
264 {
265 return getAccount().isIgnoreRecipientHeader();
266 }
267
268
269
270
271
272 protected String getCustomRecipientHeader()
273 {
274 return getAccount().getCustomRecipientHeader();
275 }
276
277
278
279
280
281 protected boolean isLeave()
282 {
283 return getConfiguration().isLeave();
284 }
285
286
287
288
289
290
291 protected boolean isMarkSeen()
292 {
293 return getConfiguration().isMarkSeen();
294 }
295
296
297
298
299
300 protected boolean isLeaveBlacklisted()
301 {
302 return getConfiguration().isLeaveBlacklisted();
303 }
304
305
306
307
308
309 protected boolean isLeaveRemoteRecipient()
310 {
311 return getConfiguration().isLeaveRemoteRecipient();
312 }
313
314
315
316
317
318 protected boolean isLeaveUserUndefined()
319 {
320 return getConfiguration().isLeaveUserUndefined();
321 }
322
323
324
325
326
327 protected boolean isLeaveRemoteReceivedHeaderInvalid()
328 {
329 return getConfiguration().isLeaveRemoteReceivedHeaderInvalid();
330 }
331
332
333
334
335
336 protected boolean isLeaveMaxMessageSizeExceeded()
337 {
338 return getConfiguration().isLeaveMaxMessageSizeExceeded();
339 }
340
341
342
343
344
345 protected boolean isLeaveUndeliverable()
346 {
347 return getConfiguration().isLeaveUndeliverable();
348 }
349
350
351
352
353
354 protected boolean isRejectUserUndefined()
355 {
356 return getConfiguration().isRejectUserUndefined();
357 }
358
359
360
361
362
363 protected boolean isRejectRemoteReceivedHeaderInvalid()
364 {
365 return getConfiguration().isRejectRemoteReceivedHeaderInvalid();
366 }
367
368
369
370
371
372 protected boolean isRejectMaxMessageSizeExceeded()
373 {
374 return getConfiguration().isRejectMaxMessageSizeExceeded();
375 }
376
377
378
379
380
381 protected boolean isRejectBlacklisted()
382 {
383 return getConfiguration().isRejectBlacklisted();
384 }
385
386
387
388
389
390 protected boolean isRejectRemoteRecipient()
391 {
392 return getConfiguration().isRejectRemoteRecipient();
393 }
394
395
396
397
398
399 protected boolean isMarkBlacklistedSeen()
400 {
401 return getConfiguration().isMarkBlacklistedSeen();
402 }
403
404
405
406
407
408 protected boolean isMarkRecipientNotFoundSeen()
409 {
410 return getConfiguration().isMarkRecipientNotFoundSeen();
411 }
412
413
414
415
416
417 protected boolean isLeaveRecipientNotFound()
418 {
419 return getConfiguration().isLeaveRecipientNotFound();
420 }
421
422
423
424
425
426 protected boolean isRejectRecipientNotFound()
427 {
428 return getConfiguration().isRejectRecipientNotFound();
429 }
430
431
432
433
434
435 protected boolean isMarkRemoteRecipientSeen()
436 {
437 return getConfiguration().isMarkRemoteRecipientSeen();
438 }
439
440
441
442
443
444 protected boolean isMarkUserUndefinedSeen()
445 {
446 return getConfiguration().isMarkUserUndefinedSeen();
447 }
448
449
450
451
452
453 protected boolean isMarkRemoteReceivedHeaderInvalidSeen()
454 {
455 return getConfiguration().isMarkRemoteReceivedHeaderInvalidSeen();
456 }
457
458
459
460
461
462 protected boolean isMarkMaxMessageSizeExceededSeen()
463 {
464 return getConfiguration().isMarkMaxMessageSizeExceededSeen();
465 }
466
467
468
469
470
471 protected boolean isMarkUndeliverableSeen()
472 {
473 return getConfiguration().isMarkUndeliverableSeen();
474 }
475
476
477
478
479
480
481
482
483 protected boolean isOpenReadOnly()
484 {
485 return getConfiguration().isOpenReadOnly();
486 }
487
488
489
490
491
492
493 protected boolean isRecurse()
494 {
495 return getConfiguration().isRecurse();
496 }
497
498
499
500
501
502
503
504 abstract public void process() throws MessagingException;
505
506
507
508
509
510 protected Set getBlacklist()
511 {
512 return getConfiguration().getBlacklist();
513 }
514
515
516
517
518
519 protected ParsedConfiguration getConfiguration()
520 {
521 return getAccount().getParsedConfiguration();
522 }
523
524
525
526
527
528 protected String getAttributePrefix()
529 {
530 String value = null;
531 if (null == (value = getAttributePrefixBasic()))
532 {
533 updateAttributePrefix();
534 return getAttributePrefix();
535 }
536 return value;
537 }
538
539
540
541
542
543 private String getAttributePrefixBasic()
544 {
545 return fieldAttributePrefix;
546 }
547
548
549
550
551
552 protected String computeAttributePrefix()
553 {
554 return getClass().getPackage().getName() + ".";
555 }
556
557
558
559
560
561 protected void setAttributePrefix(String attributePrefix)
562 {
563 fieldAttributePrefix = attributePrefix;
564 }
565
566
567
568
569 protected void updateAttributePrefix()
570 {
571 setAttributePrefix(computeAttributePrefix());
572 }
573
574
575
576
577
578 public Account getAccount()
579 {
580 return fieldAccount;
581 }
582
583
584
585
586
587 protected void setAccount(Account account)
588 {
589 fieldAccount = account;
590 }
591
592
593
594
595
596 protected int getMaxMessageSizeLimit()
597 {
598 return getConfiguration().getMaxMessageSizeLimit();
599 }
600
601
602 }