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 class
AbstractMailProvider.Feature
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MAIL_ACCOUNT_REQUEST_ATTRIBUTE
static java.lang.String
MAIL_PROVIDER_PROP_PREFIX
-
Constructor Summary
Constructors Constructor Description AbstractMailProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endFetchTransaction(FetchMailTransaction mailTransaction)
End aFetchMailTransaction
java.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.String
getLabel(java.lang.String lang)
returns the label of the providerjava.lang.String
getMailInfoJsp()
java.lang.String
getName()
returns the name of the providervoid
init(java.lang.String providerName, JProperties properties)
this method is called on provider's initializationboolean
isFetchFeatureInitialized()
indicate if the provider is correctly initialized for fetching emailboolean
isSendFeatureInitialized()
indicate if the provider is correctly initialized for sending emailjava.util.List<MailMessage>
sendMessages(MailMessage[] msg, boolean catchMailErrors)
Send given messages.protected void
setName(java.lang.String name)
FetchMailTransaction
startFetchTransaction(java.lang.String mbox)
Start aFetchMailTransaction
object (end of this transaction is the responsibility of the caller).boolean
supportFeature(AbstractMailProvider.Feature feature)
Returns true if current provider does support given feature.boolean
supportFeature(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:GenericProvider
returns the name of the provider- Specified by:
getName
in 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:GenericProvider
returns the label of the provider- Specified by:
getLabel
in 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:GenericProvider
this method is called on provider's initialization- Specified by:
init
in 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 aFetchMailTransaction
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
End aFetchMailTransaction
- Parameters:
mailTransaction
- theFetchMailTransaction
instance 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
- theFetchMailTransaction
in 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
- theFetchMailTransaction
in which fetch should be done (seestartFetchTransaction(java.lang.String)
andendFetchTransaction(com.jalios.jcms.mail.FetchMailTransaction)
messageToExpunge
- the Set ofMailMessage
to 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()
-
-