| 1 | package fr.sii.ogham.email.sender.impl.javamail; | |
| 2 | ||
| 3 | import java.io.IOException; | |
| 4 | ||
| 5 | import javax.mail.BodyPart; | |
| 6 | ||
| 7 | import fr.sii.ogham.core.resource.ByteResource; | |
| 8 | import fr.sii.ogham.core.resource.NamedResource; | |
| 9 | import fr.sii.ogham.core.resource.OverrideNameWrapper; | |
| 10 | import fr.sii.ogham.core.resource.Resource; | |
| 11 | import fr.sii.ogham.email.attachment.Attachment; | |
| 12 | import fr.sii.ogham.email.exception.handler.AttachmentResourceHandlerException; | |
| 13 | ||
| 14 | public class OverrideNameWrapperResourceHandler implements JavaMailAttachmentResourceHandler { | |
| 15 | private final JavaMailAttachmentResourceHandler delegate; | |
| 16 | | |
| 17 | public OverrideNameWrapperResourceHandler(JavaMailAttachmentResourceHandler delegate) { | |
| 18 | super(); | |
| 19 | this.delegate = delegate; | |
| 20 | } | |
| 21 | ||
| 22 | @Override | |
| 23 | public void setData(BodyPart part, NamedResource resource, Attachment attachment) throws AttachmentResourceHandlerException { | |
| 24 | OverrideNameWrapper wrapper = (OverrideNameWrapper) resource; | |
| 25 | Resource wrapped = wrapper.getDelegate(); | |
| 26 | // if possible, do not convert to ByteResource | |
| 27 |
2
1. setData : negated conditional → SURVIVED 2. setData : negated conditional → NO_COVERAGE |
if (wrapped instanceof NamedResource) { |
| 28 |
2
1. setData : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → NO_COVERAGE 2. setData : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → KILLED |
delegate.setData(part, (NamedResource) wrapped, attachment); |
| 29 | return; | |
| 30 | } | |
| 31 | try { | |
| 32 |
1
1. setData : removed call to fr/sii/ogham/email/sender/impl/javamail/JavaMailAttachmentResourceHandler::setData → NO_COVERAGE |
delegate.setData(part, new ByteResource(wrapper.getName(), wrapper.getInputStream()), attachment); |
| 33 | } catch (IOException e) { | |
| 34 | throw new AttachmentResourceHandlerException("Failed to read the content of the attachment named "+wrapper.getName(), attachment, e); | |
| 35 | } | |
| 36 | } | |
| 37 | ||
| 38 | } | |
Mutations | ||
| 27 |
1.1 2.2 |
|
| 28 |
1.1 2.2 |
|
| 32 |
1.1 |