Package com.jalios.jcms.mail
Class MailFetcher
- java.lang.Object
-
- com.jalios.jcms.mail.MailFetcher
-
- All Implemented Interfaces:
AlarmListener
,JPropertiesListener
public class MailFetcher extends java.lang.Object implements JPropertiesListener, AlarmListener
The MailFetcher is used for communication between JCMS, MailServer and Mail Account.- Fetch message from MailAccount
- Fire fetching information to MailListeners
- Provides convenient methods to handle Message retrieved from MailAccount
- Version:
- $Revision: 122682 $
- Author:
- Jean-Philippe Encausse
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALARM_MAIL_FETCHER
static java.lang.String
CONTEXT_MAILFETCHER
static java.lang.String
REVISION
-
Constructor Summary
Constructors Modifier Constructor Description protected
MailFetcher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIncomingMailPattern(java.lang.String pattern, IncomingMailListener.IncomingMailCriteria criteria)
void
addMailListener(MailListener ml)
java.util.Collection<MailMessage.Part>
decodeMultipart(javax.mail.Message msg)
void
fetch(MailAccount account)
Fetch given MailAccount and Fire MailMessage to listeners.protected void
fireFetchMessage(MailAccount account, MailMessage mail)
IncomingMailListener
getIncomingMailListener()
MailAccount
getLastFetchAccount()
Returns the latest Mail Account fetchedjava.util.Map<java.lang.String,MailAccount>
getMailAccountMap()
Retrieve MailAccount list from propertiesstatic java.lang.String
getMessageIdQuietly(javax.mail.Message msg)
Returns the messageId for the given message.void
handleAlarm(AlarmEntry entry)
Invoked when an alarm is triggered.void
propertiesChange(JProperties properties)
Invoked after properties have been modified in JCMS and save on disk.void
removeIncomingMailPattern(java.lang.String pattern)
void
removeMailListener(MailListener ml)
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
ALARM_MAIL_FETCHER
public static final java.lang.String ALARM_MAIL_FETCHER
- See Also:
- Constant Field Values
-
CONTEXT_MAILFETCHER
public static final java.lang.String CONTEXT_MAILFETCHER
- See Also:
- Constant Field Values
-
-
Method Detail
-
handleAlarm
public void handleAlarm(AlarmEntry entry)
Description copied from interface:AlarmListener
Invoked when an alarm is triggered.- Specified by:
handleAlarm
in interfaceAlarmListener
- Parameters:
entry
- the AlarmEntry which has been triggered.
-
propertiesChange
public void propertiesChange(JProperties properties)
Description copied from interface:JPropertiesListener
Invoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getProperties
orchannel.getProperty
.- Specified by:
propertiesChange
in interfaceJPropertiesListener
- Parameters:
properties
- the properties which have been submitted to change
-
getLastFetchAccount
public MailAccount getLastFetchAccount()
Returns the latest Mail Account fetched- Returns:
- MailAccount the latest fetch mail account
-
getMailAccountMap
public java.util.Map<java.lang.String,MailAccount> getMailAccountMap()
Retrieve MailAccount list from properties- Returns:
- List of MailAccount
-
addMailListener
public void addMailListener(MailListener ml)
-
removeMailListener
public void removeMailListener(MailListener ml)
-
fireFetchMessage
protected void fireFetchMessage(MailAccount account, MailMessage mail)
-
getIncomingMailListener
public IncomingMailListener getIncomingMailListener()
-
addIncomingMailPattern
public void addIncomingMailPattern(java.lang.String pattern, IncomingMailListener.IncomingMailCriteria criteria)
-
removeIncomingMailPattern
public void removeIncomingMailPattern(java.lang.String pattern)
-
getMessageIdQuietly
public static java.lang.String getMessageIdQuietly(javax.mail.Message msg)
Returns the messageId for the given message. Trying to catch and log messaging exception.- Parameters:
msg
- the javax.mail.Message- Returns:
- String the message Id or null
-
fetch
public void fetch(MailAccount account)
Fetch given MailAccount and Fire MailMessage to listeners.- Retrieve Message from server
- Build MailMessage and download attachements
- Remove message from server
- Fire notification
- Parameters:
account
- the mailAccount to Fetch
-
decodeMultipart
public java.util.Collection<MailMessage.Part> decodeMultipart(javax.mail.Message msg) throws javax.mail.MessagingException, java.io.IOException
- Throws:
javax.mail.MessagingException
java.io.IOException
-
-