java.lang.Object
org.silverpeas.components.mailinglist.service.job.MailProcessor

@Service public class MailProcessor extends Object
  • Field Details

  • Constructor Details

    • MailProcessor

      public MailProcessor()
  • Method Details

    • setCleaner

      public void setCleaner(HtmlCleaner cleaner)
    • processMailPart

      public void processMailPart(jakarta.mail.Part part, Message message) throws jakarta.mail.MessagingException, IOException
      Processes a part for a multipart email.
      Parameters:
      part - the part to be processed.
      message - the message corresponding to the email.
      Throws:
      jakarta.mail.MessagingException
      IOException
    • processBody

      public void processBody(String content, String contentType, Message message) throws IOException, jakarta.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:
      IOException
      jakarta.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(jakarta.mail.Part part, String componentId, String messageId) throws IOException, jakarta.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:
      IOException
      jakarta.mail.MessagingException
    • prepareMessage

      public void prepareMessage(jakarta.mail.internet.MimeMessage mail, MessageListener mailingList, MessageEvent event) throws jakarta.mail.MessagingException, IOException
      Process 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:
      jakarta.mail.MessagingException
      IOException
    • extractContentType

      protected static String extractContentType(String contentType)
    • getFileName

      protected String getFileName(jakarta.mail.Part part) throws jakarta.mail.MessagingException
      Throws:
      jakarta.mail.MessagingException
    • isTextPart

      protected boolean isTextPart(jakarta.mail.Part part) throws jakarta.mail.MessagingException
      Analyze 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:
      jakarta.mail.MessagingException
    • processMultipart

      public void processMultipart(jakarta.mail.Multipart multipart, Message message) throws jakarta.mail.MessagingException, IOException
      Throws:
      jakarta.mail.MessagingException
      IOException