| 1 | package fr.sii.ogham.email.sendgrid.v4.sender.impl.sendgrid.handler; | |
| 2 | ||
| 3 | import org.slf4j.Logger; | |
| 4 | import org.slf4j.LoggerFactory; | |
| 5 | ||
| 6 | import fr.sii.ogham.core.message.content.Content; | |
| 7 | import fr.sii.ogham.email.attachment.Attachment; | |
| 8 | import fr.sii.ogham.email.exception.handler.ContentHandlerException; | |
| 9 | import fr.sii.ogham.email.message.Email; | |
| 10 | import fr.sii.ogham.email.message.content.ContentWithAttachments; | |
| 11 | import fr.sii.ogham.email.sendgrid.v4.sender.impl.sendgrid.compat.MailCompat; | |
| 12 | ||
| 13 | /** | |
| 14 | * Content handler that extract {@link Attachment} that are associated to the | |
| 15 | * {@link ContentWithAttachments}. | |
| 16 | */ | |
| 17 | public final class ContentWithAttachmentsHandler implements SendGridContentHandler { | |
| 18 | private static final Logger LOG = LoggerFactory.getLogger(ContentWithAttachmentsHandler.class); | |
| 19 | private final SendGridContentHandler delegate; | |
| 20 | ||
| 21 | /** | |
| 22 | * Initialize with the {@link SendGridContentHandler} that is able to handle | |
| 23 | * the underlying content. | |
| 24 | * | |
| 25 | * @param delegate | |
| 26 | * the handler | |
| 27 | */ | |
| 28 | public ContentWithAttachmentsHandler(SendGridContentHandler delegate) { | |
| 29 | super(); | |
| 30 | this.delegate = delegate; | |
| 31 | } | |
| 32 | ||
| 33 | @Override | |
| 34 | public void setContent(Email original, MailCompat email, Content content) throws ContentHandlerException { | |
| 35 | ContentWithAttachments cwa = (ContentWithAttachments) content; | |
| 36 | for (Attachment attachment : cwa.getAttachments()) { | |
| 37 | LOG.debug("Attaching {} to email", attachment); | |
| 38 | original.attach(attachment); | |
| 39 | } | |
| 40 |
1
1. setContent : removed call to fr/sii/ogham/email/sendgrid/v4/sender/impl/sendgrid/handler/SendGridContentHandler::setContent → NO_COVERAGE |
delegate.setContent(original, email, cwa.getContent()); |
| 41 | } | |
| 42 | } | |
Mutations | ||
| 40 |
1.1 |