| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.mail; |
| 21 |
|
|
| 22 |
|
import java.util.Date; |
| 23 |
|
|
| 24 |
|
import javax.mail.MessagingException; |
| 25 |
|
import javax.mail.internet.InternetAddress; |
| 26 |
|
|
| 27 |
|
import org.apache.commons.lang3.builder.ToStringBuilder; |
| 28 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
| 29 |
|
import org.xwiki.text.XWikiToStringBuilder; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@version |
| 35 |
|
@since |
| 36 |
|
|
| |
|
| 98.7% |
Uncovered Elements: 1 (75) |
Complexity: 28 |
Complexity Density: 0.64 |
|
| 37 |
|
public class MailStatus |
| 38 |
|
{ |
| 39 |
|
|
| 40 |
|
@see |
| 41 |
|
|
| 42 |
|
private String uniqueMessageId; |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@see |
| 46 |
|
|
| 47 |
|
private String state; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@see |
| 51 |
|
|
| 52 |
|
private String batchId; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@see |
| 56 |
|
|
| 57 |
|
private Date date; |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
@see |
| 61 |
|
|
| 62 |
|
private String recipients; |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
@see |
| 66 |
|
|
| 67 |
|
private String type; |
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@see |
| 71 |
|
|
| 72 |
|
private String errorSummary; |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
@see |
| 76 |
|
|
| 77 |
|
private String errorDescription; |
| 78 |
|
|
| 79 |
|
|
| 80 |
|
@see |
| 81 |
|
|
| 82 |
|
private String wiki; |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 87 |
42 |
public MailStatus()... |
| 88 |
|
{ |
| 89 |
|
|
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
@param |
| 98 |
|
@param |
| 99 |
|
@param |
| 100 |
|
@since |
| 101 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 102 |
51 |
public MailStatus(String batchId, ExtendedMimeMessage message, MailState state)... |
| 103 |
|
{ |
| 104 |
51 |
try { |
| 105 |
51 |
setMessageId(message.getUniqueMessageId()); |
| 106 |
51 |
setBatchId(batchId); |
| 107 |
51 |
setType(message.getType()); |
| 108 |
51 |
setRecipients(InternetAddress.toString(message.getAllRecipients())); |
| 109 |
51 |
setState(state); |
| 110 |
51 |
setDate(new Date()); |
| 111 |
|
} catch (MessagingException e) { |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
0 |
throw new RuntimeException(String.format( |
| 117 |
|
"Unexpected exception constructing the Mail Status for state [%s]", state), e); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
@return |
| 123 |
|
|
| 124 |
|
@link |
| 125 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 126 |
133 |
public String getMessageId()... |
| 127 |
|
{ |
| 128 |
133 |
return this.uniqueMessageId; |
| 129 |
|
} |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
@param@link |
| 133 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 134 |
102 |
public void setMessageId(String messageId)... |
| 135 |
|
{ |
| 136 |
102 |
this.uniqueMessageId = messageId; |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@link |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
@return |
| 144 |
|
@see |
| 145 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 146 |
131 |
public String getState()... |
| 147 |
|
{ |
| 148 |
131 |
return this.state; |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
@param@link |
| 153 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
62 |
public void setState(MailState state)... |
| 155 |
|
{ |
| 156 |
62 |
this.state = state.toString(); |
| 157 |
|
} |
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
@param@link |
| 163 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 164 |
40 |
public void setState(String state)... |
| 165 |
|
{ |
| 166 |
40 |
this.state = state; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
@return |
| 173 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 174 |
114 |
public String getBatchId()... |
| 175 |
|
{ |
| 176 |
114 |
return this.batchId; |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
@param |
| 183 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 184 |
91 |
public void setBatchId(String batchId)... |
| 185 |
|
{ |
| 186 |
91 |
this.batchId = batchId; |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
@return |
| 193 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 194 |
61 |
public Date getDate()... |
| 195 |
|
{ |
| 196 |
61 |
return this.date; |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
@param |
| 203 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 204 |
94 |
public void setDate(Date date)... |
| 205 |
|
{ |
| 206 |
94 |
this.date = date; |
| 207 |
|
} |
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
@return |
| 213 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 214 |
60 |
public String getRecipients()... |
| 215 |
|
{ |
| 216 |
60 |
return this.recipients; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
@param@link |
| 223 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 224 |
91 |
public void setRecipients(String recipients)... |
| 225 |
|
{ |
| 226 |
91 |
this.recipients = recipients; |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
@return |
| 233 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 234 |
76 |
public String getType()... |
| 235 |
|
{ |
| 236 |
76 |
return this.type; |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
|
| 242 |
|
@param |
| 243 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 244 |
89 |
public void setType(String type)... |
| 245 |
|
{ |
| 246 |
89 |
this.type = type; |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
@return |
| 253 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 254 |
73 |
public String getErrorSummary()... |
| 255 |
|
{ |
| 256 |
73 |
return this.errorSummary; |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
@return |
| 263 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 264 |
36 |
public String getErrorDescription()... |
| 265 |
|
{ |
| 266 |
36 |
return this.errorDescription; |
| 267 |
|
} |
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 271 |
|
|
| 272 |
|
@param@link |
| 273 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 274 |
40 |
public void setErrorSummary(String errorSummary)... |
| 275 |
|
{ |
| 276 |
40 |
this.errorSummary = errorSummary; |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
|
| 280 |
|
|
| 281 |
|
|
| 282 |
|
@param@link |
| 283 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 284 |
40 |
public void setErrorDescription(String errorDescription)... |
| 285 |
|
{ |
| 286 |
40 |
this.errorDescription = errorDescription; |
| 287 |
|
} |
| 288 |
|
|
| 289 |
|
|
| 290 |
|
@param |
| 291 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 292 |
14 |
public void setError(Exception exception)... |
| 293 |
|
{ |
| 294 |
14 |
this.errorSummary = ExceptionUtils.getRootCauseMessage(exception); |
| 295 |
14 |
this.errorDescription = ExceptionUtils.getStackTrace(exception); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
@return |
| 302 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 303 |
72 |
public String getWiki()... |
| 304 |
|
{ |
| 305 |
72 |
return this.wiki; |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
@param@link |
| 312 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 313 |
53 |
public void setWiki(String wiki)... |
| 314 |
|
{ |
| 315 |
53 |
this.wiki = wiki; |
| 316 |
|
} |
| 317 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 5 |
Complexity Density: 0.33 |
|
| 318 |
6 |
@Override... |
| 319 |
|
public String toString() |
| 320 |
|
{ |
| 321 |
6 |
ToStringBuilder builder = new XWikiToStringBuilder(this); |
| 322 |
6 |
builder.append("messageId", getMessageId()); |
| 323 |
6 |
builder.append("batchId", getBatchId()); |
| 324 |
6 |
builder.append("state", getState()); |
| 325 |
6 |
builder.append("date", getDate()); |
| 326 |
6 |
builder.append("recipients", getRecipients()); |
| 327 |
6 |
if (getType() != null) { |
| 328 |
4 |
builder.append("type", getType()); |
| 329 |
|
} |
| 330 |
6 |
if (getErrorSummary() != null) { |
| 331 |
3 |
builder.append("errorSummary", getErrorSummary()); |
| 332 |
|
} |
| 333 |
6 |
if (getErrorDescription() != null) { |
| 334 |
3 |
builder.append("errorDescription", getErrorDescription()); |
| 335 |
|
} |
| 336 |
6 |
if (getWiki() != null) { |
| 337 |
2 |
builder.append("wiki", getWiki()); |
| 338 |
|
} |
| 339 |
6 |
return builder.toString(); |
| 340 |
|
} |
| 341 |
|
} |