Class MailProcessor
- java.lang.Object
-
- org.silverpeas.components.mailinglist.service.job.MailProcessor
-
@Service public class MailProcessor extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringMAIL_HEADER_IN_REPLY_TOstatic StringMAIL_HEADER_REFERENCESstatic intSUMMARY_SIZE
-
Constructor Summary
Constructors Constructor Description MailProcessor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static StringextractContentType(String contentType)protected StringgetFileName(javax.mail.Part part)protected booleanisTextPart(javax.mail.Part part)Analyze the part to check if it is an attachment, a base64 encoded file or some text.voidprepareMessage(javax.mail.internet.MimeMessage mail, MessageListener mailingList, MessageEvent event)Process an email, extracting attachments and constructing a Message.voidprocessBody(String content, String contentType, Message message)Processes the body (text) part of an email.voidprocessMailPart(javax.mail.Part part, Message message)Processes a part for a multi-part email.voidprocessMultipart(javax.mail.Multipart multipart, Message message)StringreplaceSpecialChars(String toParse)Replaces special chars.StringsaveAttachment(javax.mail.Part part, String componentId, String messageId)Saves an attachment as a file, and stores the path in the message.voidsetCleaner(HtmlCleaner cleaner)
-
-
-
Field Detail
-
SUMMARY_SIZE
public static final int SUMMARY_SIZE
- See Also:
- Constant Field Values
-
MAIL_HEADER_IN_REPLY_TO
public static final String MAIL_HEADER_IN_REPLY_TO
- See Also:
- Constant Field Values
-
MAIL_HEADER_REFERENCES
public static final String MAIL_HEADER_REFERENCES
- See Also:
- Constant Field Values
-
-
Method Detail
-
setCleaner
public void setCleaner(HtmlCleaner cleaner)
-
processMailPart
public void processMailPart(javax.mail.Part part, Message message) throws javax.mail.MessagingException, IOExceptionProcesses a part for a multi-part email.- Parameters:
part- the part to be processed.message- the message corresponding to the email.- Throws:
javax.mail.MessagingExceptionIOException
-
processBody
public void processBody(String content, String contentType, Message message) throws IOException, javax.mail.MessagingException
Processes the body (text) part of an email.- Parameters:
content- the text content of the email.contentType- the content type for this text.message- the message corresponding to this part- Throws:
IOExceptionjavax.mail.MessagingException
-
replaceSpecialChars
public String replaceSpecialChars(String toParse)
Replaces special chars.- Parameters:
toParse- the String whose chars are to be replaced.- Returns:
- the String without its special chars. Empty String if toParse is null.
-
saveAttachment
public String saveAttachment(javax.mail.Part part, String componentId, String messageId) throws IOException, javax.mail.MessagingException
Saves an attachment as a file, and stores the path in the message.- Parameters:
part- the part corresponding to the attachment.componentId- the id of the mailing list component.messageId- the id of the message (email id).- Returns:
- the absolute path to the file.
- Throws:
IOExceptionjavax.mail.MessagingException
-
prepareMessage
public void prepareMessage(javax.mail.internet.MimeMessage mail, MessageListener mailingList, MessageEvent event) throws javax.mail.MessagingException, IOExceptionProcess an email, extracting attachments and constructing a Message.- Parameters:
mail- the email to be processed.mailingList- the mailing list it is going to be affected to.event- the event which will be send at the end of all processing.- Throws:
javax.mail.MessagingExceptionIOException
-
getFileName
protected String getFileName(javax.mail.Part part) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
isTextPart
protected boolean isTextPart(javax.mail.Part part) throws javax.mail.MessagingExceptionAnalyze the part to check if it is an attachment, a base64 encoded file or some text.- Parameters:
part- the part to be analyzed.- Returns:
- true if it is some text - false otherwise.
- Throws:
javax.mail.MessagingException
-
processMultipart
public void processMultipart(javax.mail.Multipart multipart, Message message) throws javax.mail.MessagingException, IOException- Throws:
javax.mail.MessagingExceptionIOException
-
-