Class AbstractMailProvider

java.lang.Object
com.jalios.jcms.mail.AbstractMailProvider
All Implemented Interfaces:
GenericProvider
Direct Known Subclasses:
LegacyMailProvider

public abstract class AbstractMailProvider extends Object implements GenericProvider
Since:
jcms-10.0.8 / JCMS-8473
  • Field Details

    • MAIL_PROVIDER_PROP_PREFIX

      public static String MAIL_PROVIDER_PROP_PREFIX
    • MAIL_ACCOUNT_REQUEST_ATTRIBUTE

      public static String MAIL_ACCOUNT_REQUEST_ATTRIBUTE
  • Constructor Details

    • AbstractMailProvider

      public AbstractMailProvider()
  • Method Details

    • supportFeature

      public boolean supportFeature(String featureName)
      Returns true if current provider does support given feature.

      To be overridden by each provider implementation to indicate which features are supported.

      Return false by default.

      Parameters:
      featureName - the name of the feature to test
      Returns:
      true if the given feature is supported by the current provider.
    • supportFeature

      public boolean supportFeature(AbstractMailProvider.Feature feature)
      Returns true if current provider does support given feature.

      Feature is checked to be contained in getFeatureSet().

      Parameters:
      feature - feature to test
      Returns:
      true if the given feature is supported by the current provider.
    • getFeatureSet

      public Set<AbstractMailProvider.Feature> getFeatureSet()
      Returns the set of features current provider does support.

      By default, returns null.

      Has to be override by each provider for real feature support detection.

      Returns:
      provider supported features set
    • getName

      public String getName()
      Description copied from interface: GenericProvider
      returns the name of the provider
      Specified by:
      getName in interface GenericProvider
      Returns:
      the name of the provider
    • setName

      protected void setName(String name)
    • getLabel

      public String getLabel(String lang)
      Description copied from interface: GenericProvider
      returns the label of the provider
      Specified by:
      getLabel in interface GenericProvider
      Parameters:
      lang - the language of the label
      Returns:
      the label of the provider
    • init

      public void init(String providerName, JProperties properties)
      Description copied from interface: GenericProvider
      this method is called on provider's initialization
      Specified by:
      init in interface GenericProvider
      Parameters:
      providerName - the name of the provider, from class configuration property
      properties - the properties with the same prefix than the property describing the provider class
    • isSendFeatureInitialized

      public boolean isSendFeatureInitialized()
      indicate if the provider is correctly initialized for sending email
      Returns:
      true if the provider is correctly initialized for sending email, false otherwise
    • isFetchFeatureInitialized

      public boolean isFetchFeatureInitialized()
      indicate if the provider is correctly initialized for fetching email
      Returns:
      true if the provider is correctly initialized for fetching email, false otherwise
    • sendMessages

      public List<MailMessage> sendMessages(MailMessage[] msg, boolean catchMailErrors) throws ServiceException
      Send given messages.
      Parameters:
      msg - array of MailMessage to be sent
      catchMailErrors - set to true to prevent this method to throw exception when sending messages
      Returns:
      null or empty list if catchMailErrors is false, a List of Message that could not be sent if catchMailErrors is true
      Throws:
      ServiceException - if any exception occurs in send process
    • startFetchTransaction

      public FetchMailTransaction startFetchTransaction(String mbox) throws ServiceException
      Start a FetchMailTransaction object (end of this transaction is the responsibility of the caller).
      Parameters:
      mbox - the mail box name (may be null if not needed)
      Returns:
      the FetchMailTransaction instance
      Throws:
      ServiceException - if any exception occurs
    • endFetchTransaction

      public void endFetchTransaction(FetchMailTransaction mailTransaction) throws ServiceException
      Parameters:
      mailTransaction - the FetchMailTransaction instance to end
      Throws:
      ServiceException - if any exception occurs
    • fetch

      public List<MailMessage> fetch(FetchMailTransaction mailTransaction, boolean expungeOnFetch) throws ServiceException
      Fetch MailMessage from a mail box
      Parameters:
      mailTransaction - the FetchMailTransaction in which fetch should be done (see startFetchTransaction(java.lang.String) and endFetchTransaction(com.jalios.jcms.mail.FetchMailTransaction)
      expungeOnFetch - expunge after mail fetch
      Returns:
      The list of MailMessage read from the mailbox service
      Throws:
      ServiceException - if any exception occurs in fetch process
    • expunge

      public Set<MailMessage> expunge(FetchMailTransaction mailTransaction, Set<MailMessage> messageToExpunge) throws ServiceException
      expunge the provided message from the remote mailbox service
      Parameters:
      mailTransaction - the FetchMailTransaction in which fetch should be done (see startFetchTransaction(java.lang.String) and endFetchTransaction(com.jalios.jcms.mail.FetchMailTransaction)
      messageToExpunge - the Set of MailMessage to expunge
      Returns:
      the Set of MailMessage which has been successfully expunged
      Throws:
      ServiceException - if any exception occurs in expunge process
    • getEditHandlerClass

      public Class<? extends AbstractMailEditHandler> getEditHandlerClass()
    • getMailInfoJsp

      public String getMailInfoJsp()