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 class
MessageChecker.MessageCheckingListener
-
Field Summary
Fields Modifier and Type Field Description static String
IMAP_PROTOCOL
static String
IMAP_SSL_PROTOCOL
static String
POP3_PROTOCOL
-
Constructor Summary
Constructors Constructor Description MessageChecker()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessageListener(MessageListener listener)
Adds a new listener to the list of listeners.void
checkNewMessages(Date date)
Gets the new messages on the Mail Server and processes them.boolean
equals(Object obj)
protected Set<String>
getAllRecipients(javax.mail.internet.MimeMessage mail)
Extracts all the recipients of an email.String
getLogin()
MailingListService
getMailingListService()
MailProcessor
getMailProcessor()
String
getMailServer()
javax.mail.Session
getMailSession()
String
getPassword()
int
getPort()
String
getProtocol()
protected Set<MessageListener>
getRecipientMailingLists(Collection<String> recipients, Map<String,MessageListener> listenersByEmail)
Finds all the mailing lists recipients for an email.int
hashCode()
protected boolean
isImap()
boolean
isLeaveOnServer()
Map<String,MessageListener>
prepareListeners()
Prepare a map of subscribed email addresses and their corresponding listeners.protected void
processEmail(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.void
removeListener(String componentId)
Removes a listener from the list of listeners.void
schedule(org.silverpeas.core.scheduler.trigger.JobTrigger trigger)
void
setPort(int port)
void
setProtocol(String protocol)
void
unschedule()
-
-
-
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, IOException
Process 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.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.
-
getMailProcessor
public MailProcessor getMailProcessor()
-
isImap
protected boolean isImap()
-
-