Package org.ametys.cms.schedule
Class AbstractSendingMailSchedulable
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
org.ametys.cms.schedule.AbstractSendingMailSchedulable
- All Implemented Interfaces:
Schedulable
,LogEnabled
,PluginAware
,Initializable
,Component
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
AbstractRebuildLiveWorkspaceSchedulable
,CatalogPDFExportSchedulable
,CopyCatalogSchedulable
,DeleteCatalogSchedulable
,DuplicateContentsDetectionSchedulable
,EducationalBookletSchedulable
,ExecuteExtractionSchedulable
,GlobalWorkspaceIndexerSchedulable
,OdfRefTableDataSynchronizationSchedulable
,SendInvitationsSchedulable
,SiteIndexerSchedulable
public abstract class AbstractSendingMailSchedulable
extends AbstractStaticSchedulable
implements Initializable
Abstract schedulable that send an email at the end of the execution
By default, the email is sent to the user that launched the schedulable. This behavior can be overridden thanks to the
_getRecipient(JobExecutionContext)
method
If this user has no email address and there is an error during the execution, an email is sent to the system administrator-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
AbstractStaticSchedulable.SchedulableParameterParser
-
Field Summary
Modifier and TypeFieldDescriptionprotected CurrentUserProvider
Current user providerprotected I18nUtils
The utils for i18nprotected String
Mail senderprotected String
Sys admin mailprotected UserHelper
User helperFields inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
_acceptConcurrentExecution, _context, _description, _iconGlyph, _iconLarge, _iconMedium, _iconSmall, _id, _label, _parameters, _pluginName, _private, _schedulableParameterTypeExtensionPoint, _smanager, _userManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
_doExecute
(JobExecutionContext context) Executes the schedulable.protected abstract I18nizableText
_getErrorMailBody
(JobExecutionContext context, Throwable throwable) Retrieves the body of the error mailprotected abstract I18nizableText
_getErrorMailSubject
(JobExecutionContext context) Retrieves the subject of the error mail_getRecipient
(JobExecutionContext context) Retrieves the optional recipient of the mailprotected abstract I18nizableText
_getSuccessMailBody
(JobExecutionContext context) Retrieves the body of the success mailprotected abstract I18nizableText
Retrieves the subject of the success mailprotected boolean
_isMailBodyInHTML
(JobExecutionContext context) Determines if the mail body is in HTMLprotected void
_sendMail
(I18nizableText subject, I18nizableText body, String recipient, JobExecutionContext context) Send an emailvoid
execute
(JobExecutionContext context) The action to perform when a trigger is fired.void
void
service
(ServiceManager manager) Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, configure, contextualize, getDescription, getIconGlyph, getIconLarge, getIconMedium, getIconSmall, getId, getLabel, getParameters, isPrivate, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_i18nUtils
The utils for i18n -
_mailSender
Mail sender -
_sysadminMail
Sys admin mail -
_currentUserProvider
Current user provider -
_userHelper
User helper
-
-
Constructor Details
-
AbstractSendingMailSchedulable
public AbstractSendingMailSchedulable()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSchedulable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
execute
Description copied from interface:Schedulable
The action to perform when a trigger is fired. Do not manually call this method.- Specified by:
execute
in interfaceSchedulable
- Specified by:
execute
in classAbstractStaticSchedulable
- Parameters:
context
- the context- Throws:
Exception
- if an error occured
-
_doExecute
Executes the schedulable.- Parameters:
context
- the context- Throws:
Exception
- if an error occurred
-
_getRecipient
Retrieves the optional recipient of the mail- Parameters:
context
- the context- Returns:
- the optional recipient of the mail
-
_isMailBodyInHTML
Determines if the mail body is in HTML- Parameters:
context
- the context- Returns:
true
if the mail body is in HTML,false
otherwise- Throws:
Exception
- If an error occurs while retrieving if mail body should be HTML
-
_getSuccessMailSubject
protected abstract I18nizableText _getSuccessMailSubject(JobExecutionContext context) throws Exception Retrieves the subject of the success mail- Parameters:
context
- the context- Returns:
- the subject of the success mail
- Throws:
Exception
- If an error occurs while building the mail subject
-
_getSuccessMailBody
Retrieves the body of the success mail- Parameters:
context
- the context- Returns:
- the body of the success mail
- Throws:
Exception
- If an error occurs while building the mail body
-
_getErrorMailSubject
protected abstract I18nizableText _getErrorMailSubject(JobExecutionContext context) throws Exception Retrieves the subject of the error mail- Parameters:
context
- the context- Returns:
- the subject of the error mail
- Throws:
Exception
- If an error occurs while building the mail subject
-
_getErrorMailBody
protected abstract I18nizableText _getErrorMailBody(JobExecutionContext context, Throwable throwable) throws Exception Retrieves the body of the error mail- Parameters:
context
- the contextthrowable
- the error- Returns:
- the body of the error mail
- Throws:
Exception
- If an error occurs while building the mail body
-
_sendMail
protected void _sendMail(I18nizableText subject, I18nizableText body, String recipient, JobExecutionContext context) Send an email- Parameters:
subject
- the email's subjectbody
- the email's bodyrecipient
- the recipient addresscontext
- the context
-