1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.mail.internal; |
21 |
|
|
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
|
26 |
|
import org.slf4j.Logger; |
27 |
|
import org.xwiki.mail.ExtendedMimeMessage; |
28 |
|
import org.xwiki.mail.MailListener; |
29 |
|
|
30 |
|
|
31 |
|
@link |
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 71.4% |
Uncovered Elements: 10 (35) |
Complexity: 14 |
Complexity Density: 0.88 |
|
35 |
|
public abstract class AbstractMailListener implements MailListener |
36 |
|
{ |
37 |
|
@Inject |
38 |
|
protected Logger logger; |
39 |
|
|
40 |
|
private String batchId; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
46 |
protected String getBatchId()... |
43 |
|
{ |
44 |
46 |
return batchId; |
45 |
|
} |
46 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
47 |
53 |
@Override... |
48 |
|
public void onPrepareBegin(String batchId, Map<String, Object> parameters) |
49 |
|
{ |
50 |
53 |
if (this.batchId != null) { |
51 |
0 |
throw new RuntimeException("A mail listener cannot be reused. This listener has been used for batch [" |
52 |
|
+ this.batchId + "] and is now called for batch [" + batchId + "]."); |
53 |
|
} |
54 |
|
|
55 |
53 |
logger.debug("Mail preparation begins for batch [{}].", batchId); |
56 |
|
|
57 |
53 |
this.batchId = batchId; |
58 |
|
} |
59 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
60 |
29 |
@Override... |
61 |
|
public void onPrepareMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) |
62 |
|
{ |
63 |
29 |
if (logger.isDebugEnabled()) { |
64 |
0 |
logger.debug("Mail preparation succeed for message [{}] of batch [{}].", |
65 |
|
message.getUniqueMessageId(), batchId); |
66 |
|
} |
67 |
|
} |
68 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
69 |
5 |
@Override... |
70 |
|
public void onPrepareMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters) |
71 |
|
{ |
72 |
5 |
if (logger.isDebugEnabled()) { |
73 |
0 |
logger.debug("Mail preparation failed for message [{}] of batch [{}].", |
74 |
|
message.getUniqueMessageId(), batchId, exception); |
75 |
|
} |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
1 |
@Override... |
79 |
|
public void onPrepareFatalError(Exception exception, Map<String, Object> parameters) |
80 |
|
{ |
81 |
1 |
logger.debug("Failure during preparation phase of thread [" + batchId + "]"); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
42 |
@Override... |
85 |
|
public void onPrepareEnd(Map<String, Object> parameters) |
86 |
|
{ |
87 |
42 |
logger.debug("Mail preparation ended for batch [{}].", batchId); |
88 |
|
} |
89 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
90 |
9 |
@Override... |
91 |
|
public void onSendMessageSuccess(ExtendedMimeMessage message, Map<String, Object> parameters) |
92 |
|
{ |
93 |
9 |
if (logger.isDebugEnabled()) { |
94 |
0 |
logger.debug("Mail sent successfully for message [{}] of batch [{}].", |
95 |
|
message.getUniqueMessageId(), batchId); |
96 |
|
} |
97 |
|
} |
98 |
|
|
|
|
| 50% |
Uncovered Elements: 2 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
99 |
4 |
@Override... |
100 |
|
public void onSendMessageError(ExtendedMimeMessage message, Exception exception, Map<String, Object> parameters) |
101 |
|
{ |
102 |
4 |
if (logger.isDebugEnabled()) { |
103 |
0 |
logger.debug("Mail sending failed for message [{}] of batch [{}].", |
104 |
|
message.getUniqueMessageId(), batchId, exception); |
105 |
|
} |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
108 |
3 |
@Override... |
109 |
|
public void onSendMessageFatalError(String uniqueMessageId, Exception exception, Map<String, Object> parameters) |
110 |
|
{ |
111 |
3 |
logger.debug("Mail loading failed for message [{}] of batch [{}].", uniqueMessageId, batchId, exception); |
112 |
|
} |
113 |
|
} |