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
,GlobalWorkspaceIndexerSchedulable
,SiteIndexerSchedulable
public abstract class AbstractSendingMailSchedulable extends AbstractStaticSchedulable implements Initializable
Abstract schedulable that send an email at the end of the execution The email is send to the user that launched the schedulable If this user has no email address and there is an error during the execution, an email is send to the system administrator
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
AbstractStaticSchedulable.SchedulableParameterParser
-
-
Field Summary
Fields Modifier and Type Field Description protected I18nUtils
_i18nUtils
The utils for i18nprotected String
_mailSender
Mail senderprotected String
_sysadminMail
Sys admin mail-
Fields 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
Constructors Constructor Description AbstractSendingMailSchedulable()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
_doExecute(JobExecutionContext context)
Executes the schedulable.protected abstract I18nizableText
_getErrorMailBody(JobExecutionContext context)
Retrieves the body of the error mailprotected abstract I18nizableText
_getErrorMailSubject(JobExecutionContext context)
Retrieves the subject of the error mailprotected abstract I18nizableText
_getSuccessMailBody(JobExecutionContext context)
Retrieves the body of the success mailprotected abstract I18nizableText
_getSuccessMailSubject(JobExecutionContext context)
Retrieves the subject of the success mailprotected void
_sendMail(I18nizableText subject, I18nizableText body, Optional<String> additionalMessage, String recipient)
Send an emailvoid
execute(JobExecutionContext context)
The action to perform when a trigger is fired.void
initialize()
void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
_getLaunchUser, _getLaunchUserIdentity, 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 Detail
-
_i18nUtils
protected I18nUtils _i18nUtils
The utils for i18n
-
_mailSender
protected String _mailSender
Mail sender
-
_sysadminMail
protected String _sysadminMail
Sys admin mail
-
-
Constructor Detail
-
AbstractSendingMailSchedulable
public AbstractSendingMailSchedulable()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSchedulable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
execute
public void execute(JobExecutionContext context) throws Exception
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
protected abstract void _doExecute(JobExecutionContext context) throws Exception
Executes the schedulable.- Parameters:
context
- the context- Throws:
Exception
- if an error occurred
-
_getSuccessMailSubject
protected abstract I18nizableText _getSuccessMailSubject(JobExecutionContext context)
Retrieves the subject of the success mail- Parameters:
context
- the context- Returns:
- the subject of the success mail
-
_getSuccessMailBody
protected abstract I18nizableText _getSuccessMailBody(JobExecutionContext context)
Retrieves the body of the success mail- Parameters:
context
- the context- Returns:
- the body of the success mail
-
_getErrorMailSubject
protected abstract I18nizableText _getErrorMailSubject(JobExecutionContext context)
Retrieves the subject of the error mail- Parameters:
context
- the context- Returns:
- the subject of the error mail
-
_getErrorMailBody
protected abstract I18nizableText _getErrorMailBody(JobExecutionContext context)
Retrieves the body of the error mail- Parameters:
context
- the context- Returns:
- the body of the error mail
-
_sendMail
protected void _sendMail(I18nizableText subject, I18nizableText body, Optional<String> additionalMessage, String recipient)
Send an email- Parameters:
subject
- the email's subjectbody
- the email's bodyadditionalMessage
- an optional message to add to the email's bodyrecipient
- the recipient address
-
-