Class AbstractEmailMessageHandler

java.lang.Object
org.alfresco.email.server.handler.AbstractEmailMessageHandler
All Implemented Interfaces:
EmailMessageHandler
Direct Known Subclasses:
AbstractForumEmailMessageHandler, FolderEmailMessageHandler

public abstract class AbstractEmailMessageHandler extends Object implements EmailMessageHandler
Abstract class implements common logic for processing email messages.
Since:
2.2
Author:
maxim
  • Constructor Details

    • AbstractEmailMessageHandler

      public AbstractEmailMessageHandler()
  • Method Details

    • getContentService

      protected ContentService getContentService()
      Returns:
      Alfresco Content Service.
    • setContentService

      public void setContentService(ContentService contentService)
      Parameters:
      contentService - Alfresco Content Service.
    • getDictionaryService

      protected DictionaryService getDictionaryService()
      Returns:
      the Alfresco dictionary service
    • setDictionaryService

      public void setDictionaryService(DictionaryService dictionaryService)
      Parameters:
      dictionaryService - Alfresco dictionary service
    • getNodeService

      protected NodeService getNodeService()
      Returns:
      Alfresco Node Service.
    • setNodeService

      public void setNodeService(NodeService nodeService)
      Parameters:
      nodeService - Alfresco Node Service.
    • getMimetypeService

      protected MimetypeService getMimetypeService()
      Returns:
      the service used to determine mimeypte and encoding
    • setMimetypeService

      public void setMimetypeService(MimetypeService mimetypeService)
      Parameters:
      mimetypeService - the the service to determine mimetype and encoding
    • writeContent

      protected void writeContent(NodeRef nodeRef, String content, String mimetype)
      Write the string as content to the node.
      Parameters:
      nodeRef - Target node.
      content - Text for writting.
      mimetype - MIME content type. For exaple you can set this parameter to "text/html" or "text/xml", etc.
    • writeContent

      protected void writeContent(NodeRef nodeRef, InputStream content, String mimetype, String encoding)
      Write content to the node from InputStream.
      Parameters:
      nodeRef - Target node.
      content - Content stream.
      mimetype - MIME content type.
      encoding - Encoding. Can be null for text based content, n which case the best guess.
    • addEmailedAspect

      protected void addEmailedAspect(NodeRef nodeRef, EmailMessage message)
      Add emailed aspect to the specified node.
      Parameters:
      nodeRef - Target node.
      message - Mail message that will be used for extracting necessary information
    • addContentNode

      protected NodeRef addContentNode(NodeService nodeService, NodeRef parent, String name, QName assocType, boolean overwrite)
      Add new node into Alfresco repository with specified parameters. Node content isn't added.
      Parameters:
      nodeService - Alfresco Node Service
      parent - Parent node
      name - Name of the new node
      overwrite - if true then overwrite an existing node with the same name. if false the name is changed to make it unique.
      assocType - Association type that should be set between parent node and the new one.
      Returns:
      Reference to created node
    • addContentNode

      protected NodeRef addContentNode(NodeService nodeService, NodeRef parent, String name, boolean overwrite)
      Add new node into Alfresco repository with specified parameters. Node content isn't added. New node will be created with ContentModel.ASSOC_CONTAINS association with parent.
      Parameters:
      nodeService - Alfresco Node Service
      parent - Parent node
      name - Name of the new node
      overwrite - whether a new node should overwrite an existing node with the same name or have its name mangled to be alongside the existing node.
      Returns:
      Reference to created node
    • addAttachment

      protected NodeRef addAttachment(NodeService nodeService, NodeRef folder, NodeRef mainContentNode, String fileName)
      Adds new node into Alfresco repository and mark its as an attachment.
      Parameters:
      nodeService - Alfresco Node Service.
      folder - Space/Folder to add.
      mainContentNode - Main content node. Any mail is added into Alfresco as one main content node and several its attachments. Each attachment related with its main node.
      fileName - File name for the attachment.
      Returns:
      Reference to created node.
    • addAttachments

      protected void addAttachments(NodeRef spaceNodeRef, NodeRef nodeRef, EmailMessage message)
      Extracts the attachments from the given message and adds them to the space. All attachments are linked back to the original node that they are attached to.
      Parameters:
      spaceNodeRef - the space to add the documents into
      nodeRef - the node to which the documents will be attached
      message - the email message
    • encodeSubject

      public static String encodeSubject(String subject)
      Subject field is used as name of the content, so we need to replace characters that are forbidden in file names. Trims whitespace Replaces characters \/*|:"<>? with their hex values.
      Parameters:
      subject - the string of the email subject
      Returns:
      filename