Class 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
    • Constructor Detail

      • MailFetcher

        protected MailFetcher()
    • Method Detail

      • handleAlarm

        public void handleAlarm​(AlarmEntry entry)
        Description copied from interface: AlarmListener
        Invoked when an alarm is triggered.
        Specified by:
        handleAlarm in interface AlarmListener
        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 or channel.getProperty.

        Specified by:
        propertiesChange in interface JPropertiesListener
        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)
      • 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.
        1. Retrieve Message from server
        2. Build MailMessage and download attachements
        3. Remove message from server
        4. 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