NIFI-3976: This closes #1857. Fix ConsumePOP3 and ConsumeIMAP to delete messages.

Signed-off-by: joewitt <joewitt@apache.org>
This commit is contained in:
Koji Kawamura 2017-05-25 22:56:12 +09:00 committed by joewitt
parent dc5e032368
commit 23cbc3b346
3 changed files with 4 additions and 8 deletions

View File

@ -31,7 +31,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.mail.Address;
import javax.mail.Flags;
import javax.mail.Message;
import javax.mail.MessagingException;
@ -369,12 +368,6 @@ abstract class AbstractEmailProcessor<T extends AbstractMailReceiver> extends Ab
this.getLogger().info("Successfully received {} from {} in {} millis", new Object[]{flowFile, fromAddressesString, executionDuration});
processSession.transfer(flowFile, REL_SUCCESS);
try {
emailMessage.setFlag(Flags.Flag.DELETED, this.shouldSetDeleteFlag);
} catch (MessagingException e) {
this.logger.warn("Failed to set DELETE Flag on the message", e);
this.getLogger().warn("Failed to set DELETE Flag on the message");
}
}
/**

View File

@ -70,6 +70,7 @@ public class ConsumeIMAP extends AbstractEmailProcessor<ImapMailReceiver> {
ImapMailReceiver receiver = new ImapMailReceiver(this.buildUrl(processContext));
boolean shouldMarkAsRead = processContext.getProperty(SHOULD_MARK_READ).asBoolean();
receiver.setShouldMarkMessagesAsRead(shouldMarkAsRead);
receiver.setShouldDeleteMessages(processContext.getProperty(AbstractEmailProcessor.SHOULD_DELETE_MESSAGES).asBoolean());
return receiver;
}

View File

@ -55,7 +55,9 @@ public class ConsumePOP3 extends AbstractEmailProcessor<Pop3MailReceiver> {
*/
@Override
protected Pop3MailReceiver buildMessageReceiver(ProcessContext context) {
return new Pop3MailReceiver(this.buildUrl(context));
final Pop3MailReceiver receiver = new Pop3MailReceiver(this.buildUrl(context));
receiver.setShouldDeleteMessages(context.getProperty(AbstractEmailProcessor.SHOULD_DELETE_MESSAGES).asBoolean());
return receiver;
}
/**