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
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolverThe ametys object resolver.protected StringThe server base URL.protected intThe count of oldest versions to keep.protected I18nUtilsThe i18n utils.protected StringThe content of "from" field in emails.protected SourceResolverThe avalon source resolver.protected StringThe sysadmin mail address, to which will be sent the report e-mail.A Map of the validation step ID by workflow name.protected PurgeVersionsManagerThe version purger.protected WorkflowProviderThe 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, _startTime, _userManager, PROGRESSION_TRACKER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(Configuration configuration) configureValidationStepId(Configuration configuration) Get the validation step ID by workflow from the component configuration.voidexecute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) 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 StringgetErrorMailUri(Map<String, String> parameters) Get the pipeline uri for error mail body.protected StringgetMailBody(Map<String, String> parameters) Get a mail part.protected StringgetMailUri(Map<String, String> parameters) Get the pipeline uri for mail bodyvoidprotected voidsendErrorMail(Date startDate, Throwable throwable) Send the error e-mail.protected voidSend the purge report e-mail.voidservice(ServiceManager manager) Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, 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
-
_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:
servicein interfaceServiceable- Overrides:
servicein classAbstractStaticSchedulable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
configure
- Specified by:
configurein interfaceConfigurable- Overrides:
configurein 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
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
-
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
-