Class MessageChecker


  • @Service
    public class MessageChecker
    extends Object
    • Constructor Detail

      • MessageChecker

        public MessageChecker()
        Default constructor
    • Method Detail

      • getMailSession

        public javax.mail.Session getMailSession()
      • schedule

        public void schedule​(org.silverpeas.core.scheduler.trigger.JobTrigger trigger)
                      throws org.silverpeas.core.scheduler.SchedulerException
        Throws:
        org.silverpeas.core.scheduler.SchedulerException
      • unschedule

        public void unschedule()
                        throws org.silverpeas.core.scheduler.SchedulerException
        Throws:
        org.silverpeas.core.scheduler.SchedulerException
      • getLogin

        public String getLogin()
      • getPassword

        public String getPassword()
      • getMailServer

        public String getMailServer()
      • isLeaveOnServer

        public boolean isLeaveOnServer()
      • getPort

        public int getPort()
      • setPort

        public void setPort​(int port)
      • getProtocol

        public String getProtocol()
      • setProtocol

        public void setProtocol​(String protocol)
      • addMessageListener

        public void addMessageListener​(MessageListener listener)
        Adds a new listener to the list of listeners.
        Parameters:
        listener - the listener to be added.
      • checkNewMessages

        public void checkNewMessages​(Date date)
        Gets the new messages on the Mail Server and processes them.
        Parameters:
        date - the date of the checking.
      • processEmail

        protected void processEmail​(javax.mail.internet.MimeMessage mail,
                                    Map<MessageListener,​MessageEvent> eventsMap,
                                    Map<String,​MessageListener> listenersByEmail)
                             throws javax.mail.MessagingException,
                                    IOException
        Process an email, building the events to be send when all email have been processed.
        Parameters:
        mail - the mail to be processed
        eventsMap - the map of MessageEvents
        listenersByEmail - the map of MessageListners with their emil address as key
        Throws:
        javax.mail.MessagingException
        IOException
      • getAllRecipients

        protected Set<String> getAllRecipients​(javax.mail.internet.MimeMessage mail)
                                        throws javax.mail.MessagingException
        Extracts all the recipients of an email.
        Parameters:
        mail - the email whose recipients are extracted.
        Returns:
        a list of InternetAdress.
        Throws:
        javax.mail.MessagingException
        See Also:
        InternetAddress
      • getRecipientMailingLists

        protected Set<MessageListener> getRecipientMailingLists​(Collection<String> recipients,
                                                                Map<String,​MessageListener> listenersByEmail)
        Finds all the mailing lists recipients for an email.
        Parameters:
        recipients - the recipients of the email.
        Returns:
        the list of mailing lists (as MessageListener) for this email.
      • prepareListeners

        public Map<String,​MessageListener> prepareListeners()
        Prepare a map of subscribed email addresses and their corresponding listeners.
        Returns:
        a map of subscribed email addresses and their corresponding listeners.
      • removeListener

        public void removeListener​(String componentId)
        Removes a listener from the list of listeners.
        Parameters:
        componentId - the unique id of the component.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isImap

        protected boolean isImap()