Methods Summary |
---|
protected void | close()Method close.
if (null != getFolder() && getFolder().isOpen())
getFolder().close(true);
|
protected java.lang.Boolean | computeMarkSeenPermanent()Answer the result of computing markSeenPermanent.
return new Boolean(
getFolder().getPermanentFlags().contains(Flags.Flag.SEEN));
|
protected javax.mail.Folder | getFolder()Returns the folder.
return fieldFolder;
|
protected boolean | handleMarkSeenNotPermanent(javax.mail.internet.MimeMessage aMessage)Handler for when the folder does not support the SEEN flag.
The default behaviour implemented here is to answer the value of the
SEEN flag anyway.
Subclasses may choose to override this method and implement their own
solutions.
return aMessage.isSet(Flags.Flag.SEEN);
|
protected java.lang.Boolean | isMarkSeenPermanent()Returns the isMarkSeenPermanent.
Boolean markSeenPermanent = null;
if (null == (markSeenPermanent = isMarkSeenPermanentBasic()))
{
updateMarkSeenPermanent();
return isMarkSeenPermanent();
}
return markSeenPermanent;
|
private java.lang.Boolean | isMarkSeenPermanentBasic()Returns the markSeenPermanent.
return fieldMarkSeenPermanent;
|
protected boolean | isSeen(javax.mail.internet.MimeMessage aMessage)Answer if aMessage has been SEEN.
boolean isSeen = false;
if (isMarkSeenPermanent().booleanValue())
isSeen = aMessage.isSet(Flags.Flag.SEEN);
else
isSeen = handleMarkSeenNotPermanent(aMessage);
return isSeen;
|
protected void | open()Method open.
int openFlag = Folder.READ_WRITE;
if (isOpenReadOnly())
openFlag = Folder.READ_ONLY;
getFolder().open(openFlag);
|
public void | process()Method process opens a Folder, fetches the Envelopes for all of its
Messages, creates a MessageProcessor and runs it to process
each message.
int messagesProcessed = 0;
int messageCount = 0;
try
{
// open the folder
try
{
open();
}
catch (MessagingException ex)
{
getLogger().error(
getFetchTaskName() + " Failed to open folder!");
throw ex;
}
// Lock the folder while processing each message
synchronized (getFolder())
{
messageCount = getFolder().getMessageCount();
for (int i = 1; i <= messageCount; i++)
{
MimeMessage message =
(MimeMessage) getFolder().getMessage(i);
if (isFetchAll() || !isSeen(message))
{
try
{
new MessageProcessor(message, getAccount())
.process();
messagesProcessed++;
}
// Catch and report an exception but don't rethrow it,
// allowing subsequent messages to be processed.
catch (Exception ex)
{
StringBuffer logMessageBuffer =
new StringBuffer("Exception processing message ID: ");
logMessageBuffer.append(message.getMessageID());
getLogger().error(logMessageBuffer.toString(), ex);
}
}
}
}
}
catch (MessagingException mex)
{
getLogger().error(
"A MessagingException has terminated fetching messages for this folder",
mex);
}
finally
{
// Close the folder
try
{
close();
}
catch (MessagingException ex)
{
// No-op
}
StringBuffer logMessageBuffer = new StringBuffer("Processed ");
logMessageBuffer.append(messagesProcessed);
logMessageBuffer.append(" messages of ");
logMessageBuffer.append(messageCount);
logMessageBuffer.append(" in folder '");
logMessageBuffer.append(getFolder().getName());
logMessageBuffer.append("'");
getLogger().info(logMessageBuffer.toString());
}
// Recurse through sub-folders if required
try
{
if (isRecurse())
recurse();
}
catch (MessagingException mex)
{
getLogger().error(
"A MessagingException has terminated recursing through sub-folders",
mex);
}
return;
|
protected void | recurse()Method recurse.
if ((getFolder().getType() & Folder.HOLDS_FOLDERS)
== Folder.HOLDS_FOLDERS)
{
// folder contains subfolders...
Folder folders[] = getFolder().list();
for (int i = 0; i < folders.length; i++)
{
new FolderProcessor(folders[i], getAccount()).process();
}
}
|
protected void | setFolder(javax.mail.Folder folder)Sets the folder.
fieldFolder = folder;
|
protected void | setMarkSeenPermanent(java.lang.Boolean markSeenPermanent)Sets the markSeenPermanent.
fieldMarkSeenPermanent = markSeenPermanent;
|
protected void | updateMarkSeenPermanent()Updates the markSeenPermanent.
setMarkSeenPermanent(computeMarkSeenPermanent());
|