Package org.ametys.cms.workflow.purge
Class PurgeContentsEngine
java.lang.Object
org.ametys.cms.workflow.purge.PurgeContentsEngine
- All Implemented Interfaces:
Runnable
Runnable engine that removes old versions of contents.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolver.protected String
The server base URL.protected Context
The avalon context.protected Context
The cocoon environment context.protected int
The count of oldest versions to keep.protected I18nUtils
The i18n utils.protected boolean
Is the engine initialized ?protected static final Logger
The logger.protected String
The content of "from" field in emails.protected ServiceManager
The service manager.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 provider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check the initialization and throw an exception if not initialized.void
configure
(Configuration configuration) Configure the engine (called by the scheduler).configureValidationStepId
(Configuration configuration) Get the validation step ID by workflow from the component configuration.protected void
dispose()
Dispose of the resources and looked-up components.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
initialize
(ServiceManager manager, Context context) Initialize the purge engine.protected void
Get all the contents and purge the old versions.void
run()
protected void
sendErrorMail
(Date startDate, Throwable throwable) Send the error e-mail.protected void
Send the purge report e-mail.
-
Field Details
-
_LOGGER
The logger. -
_context
The avalon context. -
_manager
The service manager. -
_baseUrl
The server base URL. -
_initialized
Is the engine initialized ? -
_environmentContext
The cocoon environment context. -
_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
-
PurgeContentsEngine
public PurgeContentsEngine()
-
-
Method Details
-
initialize
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException Initialize the purge engine.- Parameters:
manager
- the avalon service manager.context
- the avalon context.- Throws:
ContextException
- If an error occurredServiceException
- If an error occurred
-
configure
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- If an error occurred
-
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
-
checkInitialization
Check the initialization and throw an exception if not initialized. -
run
-
dispose
Dispose of the resources and looked-up components. -
purgeContents
Get all the contents and purge the old versions.- Throws:
AmetysRepositoryException
- if an error occurs.
-
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
-