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,MCCValidatedPDFSchedulable,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
FieldsModifier and TypeFieldDescriptionprotected CurrentUserProviderCurrent user providerprotected I18nUtilsThe utils for i18nprotected StringMail senderprotected StringSys admin mailprotected UserHelperUser 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, _startTime, _userManager, PROGRESSION_TRACKER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void_doExecute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) Executes the schedulable.protected abstract String_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 String_getSuccessMailBody(JobExecutionContext context) Retrieves the body of the success mailprotected abstract I18nizableTextRetrieves the subject of the success mailprotected boolean_isMailBodyInHTML(JobExecutionContext context) Determines if the mail body is in HTMLprotected void_sendMail(I18nizableText subject, String body, String recipient, JobExecutionContext context) Send an emailvoidexecute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) The action to perform when a trigger is fired.voidvoidservice(ServiceManager manager) Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, configure, contextualize, getDescription, getIconGlyph, getIconLarge, getIconMedium, getIconSmall, getId, getLabel, getParameters, getProgressionTracker, isPrivate, setPluginInfoMethods 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:
servicein interfaceServiceable- Overrides:
servicein classAbstractStaticSchedulable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
execute
public void execute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) throws Exception Description copied from interface:SchedulableThe action to perform when a trigger is fired. Do not manually call this method.- Specified by:
executein interfaceSchedulable- Parameters:
context- the contextprogressionTracker- The progression tracker- Throws:
Exception- if an error occurred
-
_doExecute
protected abstract void _doExecute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) throws Exception Executes the schedulable.- Parameters:
context- the contextprogressionTracker- The progression tracker- 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:
trueif the mail body is in HTML,falseotherwise- 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 String _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, String body, String recipient, JobExecutionContext context) Send an email- Parameters:
subject- the email's subjectbody- the email's body (to HTML or text format depending on_isMailBodyInHTML(JobExecutionContext)recipient- the recipient addresscontext- the context
-