1 | package fr.sii.ogham.email.sender.impl.javamail; | |
2 | ||
3 | import javax.mail.MessagingException; | |
4 | import javax.mail.Multipart; | |
5 | import javax.mail.internet.MimeBodyPart; | |
6 | ||
7 | import fr.sii.ogham.email.attachment.Attachment; | |
8 | import fr.sii.ogham.email.exception.handler.AttachmentResourceHandlerException; | |
9 | ||
10 | public class JavaMailAttachmentHandler { | |
11 | /** | |
12 | * The handler used to set the content of the attachment | |
13 | */ | |
14 | private final JavaMailAttachmentResourceHandler attachmentContentHandler; | |
15 | ||
16 | public JavaMailAttachmentHandler(JavaMailAttachmentResourceHandler attachmentContentHandler) { | |
17 | super(); | |
18 | this.attachmentContentHandler = attachmentContentHandler; | |
19 | } | |
20 | ||
21 | /** | |
22 | * Add an attachment on the mime message. | |
23 | * | |
24 | * @param multipart | |
25 | * the mime message to fill | |
26 | * @param attachment | |
27 | * the attachment to add | |
28 | * @throws AttachmentResourceHandlerException | |
29 | * when the attachment couldn't be attached | |
30 | */ | |
31 | public void addAttachment(Multipart multipart, Attachment attachment) throws AttachmentResourceHandlerException { | |
32 | try { | |
33 | MimeBodyPart part = new MimeBodyPart(); | |
34 |
3
1. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setFileName → NO_COVERAGE 2. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setFileName → KILLED 3. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setFileName → KILLED |
part.setFileName(attachment.getResource().getName()); |
35 |
3
1. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setDisposition → NO_COVERAGE 2. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setDisposition → SURVIVED 3. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setDisposition → KILLED |
part.setDisposition(attachment.getDisposition()); |
36 |
2
1. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setDescription → NO_COVERAGE 2. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setDescription → SURVIVED |
part.setDescription(attachment.getDescription()); |
37 |
3
1. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setContentID → SURVIVED 2. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setContentID → NO_COVERAGE 3. addAttachment : removed call to javax/mail/internet/MimeBodyPart::setContentID → KILLED |
part.setContentID(attachment.getContentId()); |
38 |
3
1. addAttachment : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → NO_COVERAGE 2. addAttachment : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → KILLED 3. addAttachment : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → KILLED |
attachmentContentHandler.setData(part, attachment.getResource(), attachment); |
39 |
3
1. addAttachment : removed call to javax/mail/Multipart::addBodyPart → NO_COVERAGE 2. addAttachment : removed call to javax/mail/Multipart::addBodyPart → KILLED 3. addAttachment : removed call to javax/mail/Multipart::addBodyPart → KILLED |
multipart.addBodyPart(part); |
40 | } catch (MessagingException e) { | |
41 | throw new AttachmentResourceHandlerException("Failed to attach " + attachment.getResource().getName(), attachment, e); | |
42 | } | |
43 | } | |
44 | ||
45 | } | |
Mutations | ||
34 |
1.1 2.2 3.3 |
|
35 |
1.1 2.2 3.3 |
|
36 |
1.1 2.2 |
|
37 |
1.1 2.2 3.3 |
|
38 |
1.1 2.2 3.3 |
|
39 |
1.1 2.2 3.3 |