Package com.jalios.jcms.mail
Class AbstractMailProvider
- java.lang.Object
-
- com.jalios.jcms.mail.AbstractMailProvider
-
- All Implemented Interfaces:
GenericProvider
- Direct Known Subclasses:
LegacyMailProvider
public abstract class AbstractMailProvider extends java.lang.Object implements GenericProvider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractMailProvider.Feature
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMAIL_ACCOUNT_REQUEST_ATTRIBUTEstatic java.lang.StringMAIL_PROVIDER_PROP_PREFIX
-
Constructor Summary
Constructors Constructor Description AbstractMailProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendFetchTransaction(FetchMailTransaction mailTransaction)End aFetchMailTransactionjava.util.Set<MailMessage>expunge(FetchMailTransaction mailTransaction, java.util.Set<MailMessage> messageToExpunge)expunge the provided message from the remote mailbox servicejava.util.List<MailMessage>fetch(FetchMailTransaction mailTransaction, boolean expungeOnFetch)Fetch MailMessage from a mail boxjava.lang.Class<? extends AbstractMailEditHandler>getEditHandlerClass()java.util.Set<AbstractMailProvider.Feature>getFeatureSet()Returns the set of features current provider does support.java.lang.StringgetLabel(java.lang.String lang)returns the label of the providerjava.lang.StringgetMailInfoJsp()java.lang.StringgetName()returns the name of the providervoidinit(java.lang.String providerName, JProperties properties)this method is called on provider's initializationbooleanisFetchFeatureInitialized()indicate if the provider is correctly initialized for fetching emailbooleanisSendFeatureInitialized()indicate if the provider is correctly initialized for sending emailjava.util.List<MailMessage>sendMessages(MailMessage[] msg, boolean catchMailErrors)Send given messages.protected voidsetName(java.lang.String name)FetchMailTransactionstartFetchTransaction(java.lang.String mbox)Start aFetchMailTransactionobject (end of this transaction is the responsibility of the caller).booleansupportFeature(AbstractMailProvider.Feature feature)Returns true if current provider does support given feature.booleansupportFeature(java.lang.String featureName)Returns true if current provider does support given feature.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jalios.jcms.GenericProvider
isInitialized
-
-
-
-
Method Detail
-
supportFeature
public boolean supportFeature(java.lang.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 java.util.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 java.lang.String getName()
Description copied from interface:GenericProviderreturns the name of the provider- Specified by:
getNamein interfaceGenericProvider- Returns:
- the name of the provider
-
setName
protected void setName(java.lang.String name)
-
getLabel
public java.lang.String getLabel(java.lang.String lang)
Description copied from interface:GenericProviderreturns the label of the provider- Specified by:
getLabelin interfaceGenericProvider- Parameters:
lang- the language of the label- Returns:
- the label of the provider
-
init
public void init(java.lang.String providerName, JProperties properties)Description copied from interface:GenericProviderthis method is called on provider's initialization- Specified by:
initin interfaceGenericProvider- Parameters:
providerName- the name of the provider, from class configuration propertyproperties- 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 java.util.List<MailMessage> sendMessages(MailMessage[] msg, boolean catchMailErrors) throws ServiceException
Send given messages.- Parameters:
msg- array of MailMessage to be sentcatchMailErrors- 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(java.lang.String mbox) throws ServiceException
Start aFetchMailTransactionobject (end of this transaction is the responsibility of the caller).- Parameters:
mbox- the mail box name (may be null if not needed)- Returns:
- the
FetchMailTransactioninstance - Throws:
ServiceException- if any exception occurs
-
endFetchTransaction
public void endFetchTransaction(FetchMailTransaction mailTransaction) throws ServiceException
End aFetchMailTransaction- Parameters:
mailTransaction- theFetchMailTransactioninstance to end- Throws:
ServiceException- if any exception occurs
-
fetch
public java.util.List<MailMessage> fetch(FetchMailTransaction mailTransaction, boolean expungeOnFetch) throws ServiceException
Fetch MailMessage from a mail box- Parameters:
mailTransaction- theFetchMailTransactionin which fetch should be done (seestartFetchTransaction(java.lang.String)andendFetchTransaction(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 java.util.Set<MailMessage> expunge(FetchMailTransaction mailTransaction, java.util.Set<MailMessage> messageToExpunge) throws ServiceException
expunge the provided message from the remote mailbox service- Parameters:
mailTransaction- theFetchMailTransactionin which fetch should be done (seestartFetchTransaction(java.lang.String)andendFetchTransaction(com.jalios.jcms.mail.FetchMailTransaction)messageToExpunge- the Set ofMailMessageto expunge- Returns:
- the Set of MailMessage which has been successfully expunged
- Throws:
ServiceException- if any exception occurs in expunge process
-
getEditHandlerClass
public java.lang.Class<? extends AbstractMailEditHandler> getEditHandlerClass()
-
getMailInfoJsp
public java.lang.String getMailInfoJsp()
-
-