Package org.ametys.cms.workflow.purge
Class PurgeContentsSchedulable
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
org.ametys.cms.workflow.purge.PurgeContentsSchedulable
- All Implemented Interfaces:
Schedulable
,LogEnabled
,PluginAware
,Initializable
,Component
,Configurable
,Contextualizable
,Serviceable
Schedulable that removes old versions of contents.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
AbstractStaticSchedulable.SchedulableParameterParser
-
Field Summary
Modifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolver.protected String
The server base URL.protected int
The count of oldest versions to keep.protected I18nUtils
The i18n utils.protected String
The content of "from" field in emails.protected SourceResolver
The avalon source resolver.protected String
The sysadmin mail address, to which will be sent the report e-mail.A Map of the validation step ID by workflow name.protected PurgeVersionsManager
The version purger.protected WorkflowProvider
The workflow providerFields 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 TypeMethodDescriptionvoid
configure
(Configuration configuration) configureValidationStepId
(Configuration configuration) Get the validation step ID by workflow from the component configuration.void
execute
(JobExecutionContext context) The action to perform when a trigger is fired.getEmailParams
(Date startDate, Date endDate, int totalContentsPurged, int totalVersionsPurged) Get the report e-mail parameters.getErrorEmailParams
(Date startDate, Throwable throwable) Get the error e-mail parameters.protected String
getErrorMailUri
(Map<String, String> parameters) Get the pipeline uri for error mail body.protected String
getMailBody
(Map<String, String> parameters) Get a mail part.protected String
getMailUri
(Map<String, String> parameters) Get the pipeline uri for mail bodyvoid
protected void
sendErrorMail
(Date startDate, Throwable throwable) Send the error e-mail.protected void
Send the purge report e-mail.void
service
(ServiceManager manager) Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, 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
-
_baseUrl
The server base URL. -
_ametysResolver
The ametys object resolver. -
_sourceResolver
The avalon source resolver. -
_versionPurger
The version purger. -
_workflowProvider
The workflow provider -
_i18nUtils
The i18n utils. -
_validationStepId
A Map of the validation step ID by workflow name. -
_firstVersionsToKeep
The count of oldest versions to keep. -
_mailFrom
The content of "from" field in emails. -
_sysadminMail
The sysadmin mail address, to which will be sent the report e-mail.
-
-
Constructor Details
-
PurgeContentsSchedulable
public PurgeContentsSchedulable()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSchedulable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
configure
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractStaticSchedulable
- Throws:
ConfigurationException
-
configureValidationStepId
protected Map<String,Long> configureValidationStepId(Configuration configuration) throws ConfigurationException Get the validation step ID by workflow from the component configuration.- Parameters:
configuration
- the component configuration.- Returns:
- a Map of the validation step ID by workflow.
- Throws:
ConfigurationException
- If an error occurred
-
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
-
sendMail
protected void sendMail(Date startDate, Date endDate, int totalContentsPurged, int totalVersionsPurged) Send the purge report e-mail.- Parameters:
startDate
- the purge start date.endDate
- the purge end date.totalContentsPurged
- the total count of contents of which versions were purged.totalVersionsPurged
- the total count of content versions removed.
-
sendErrorMail
Send the error e-mail.- Parameters:
startDate
- the purge start date.throwable
- the error.
-
getEmailParams
protected Map<String,String> getEmailParams(Date startDate, Date endDate, int totalContentsPurged, int totalVersionsPurged) Get the report e-mail parameters.- Parameters:
startDate
- the purge start date.endDate
- the purge end date.totalContentsPurged
- the total count of contents of which versions were purged.totalVersionsPurged
- the total count of content versions removed.- Returns:
- the e-mail parameters.
-
getErrorEmailParams
Get the error e-mail parameters.- Parameters:
startDate
- the purge start date.throwable
- the error.- Returns:
- the e-mail parameters.
-
getMailBody
Get a mail part.- Parameters:
parameters
- the pipeline parameters.- Returns:
- the mail part.
- Throws:
IOException
- If an error occurred
-
getMailUri
Get the pipeline uri for mail body- Parameters:
parameters
- the mail parameters- Returns:
- a pipeline uri
-
getErrorMailUri
Get the pipeline uri for error mail body.- Parameters:
parameters
- the mail parameters- Returns:
- a pipeline uri
-