Class MessageChecker
- java.lang.Object
-
- org.silverpeas.components.mailinglist.service.job.MessageChecker
-
@Service public class MessageChecker extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMessageChecker.MessageCheckingListener
-
Field Summary
Fields Modifier and Type Field Description static StringIMAP_PROTOCOLstatic StringIMAP_SSL_PROTOCOLstatic StringPOP3_PROTOCOL
-
Constructor Summary
Constructors Constructor Description MessageChecker()Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessageListener(MessageListener listener)Adds a new listener to the list of listeners.voidcheckNewMessages(Date date)Gets the new messages on the Mail Server and processes them.booleanequals(Object obj)protected Set<String>getAllRecipients(javax.mail.internet.MimeMessage mail)Extracts all the recipients of an email.StringgetLogin()MailingListServicegetMailingListService()MailProcessorgetMailProcessor()StringgetMailServer()javax.mail.SessiongetMailSession()StringgetPassword()intgetPort()StringgetProtocol()protected Set<MessageListener>getRecipientMailingLists(Collection<String> recipients, Map<String,MessageListener> listenersByEmail)Finds all the mailing lists recipients for an email.inthashCode()protected booleanisImap()booleanisLeaveOnServer()Map<String,MessageListener>prepareListeners()Prepare a map of subscribed email addresses and their corresponding listeners.protected voidprocessEmail(javax.mail.internet.MimeMessage mail, Map<MessageListener,MessageEvent> eventsMap, Map<String,MessageListener> listenersByEmail)Process an email, building the events to be send when all email have been processed.voidremoveListener(String componentId)Removes a listener from the list of listeners.voidschedule(org.silverpeas.core.scheduler.trigger.JobTrigger trigger)voidsetPort(int port)voidsetProtocol(String protocol)voidunschedule()
-
-
-
Field Detail
-
IMAP_PROTOCOL
public static final String IMAP_PROTOCOL
- See Also:
- Constant Field Values
-
IMAP_SSL_PROTOCOL
public static final String IMAP_SSL_PROTOCOL
- See Also:
- Constant Field Values
-
POP3_PROTOCOL
public static final String POP3_PROTOCOL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMailingListService
public MailingListService getMailingListService()
-
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, IOExceptionProcess an email, building the events to be send when all email have been processed.- Parameters:
mail- the mail to be processedeventsMap- the map of MessageEventslistenersByEmail- the map of MessageListners with their emil address as key- Throws:
javax.mail.MessagingExceptionIOException
-
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.
-
getMailProcessor
public MailProcessor getMailProcessor()
-
isImap
protected boolean isImap()
-
-