public class PurgeContentsEngine extends Object implements Runnable
Modifier and Type | Field and Description |
---|---|
protected AmetysObjectResolver |
_ametysResolver
The ametys object resolver.
|
protected String |
_baseUrl
The server base URL.
|
protected Context |
_context
The avalon context.
|
protected Context |
_environmentContext
The cocoon environment context.
|
protected int |
_firstVersionsToKeep
The count of oldest versions to keep.
|
protected I18nUtils |
_i18nUtils
The i18n utils.
|
protected boolean |
_initialized
Is the engine initialized ?
|
protected static Logger |
_LOGGER
The logger.
|
protected String |
_mailFrom
The content of "from" field in emails.
|
protected ServiceManager |
_manager
The service manager.
|
protected SourceResolver |
_sourceResolver
The avalon source resolver.
|
protected String |
_sysadminMail
The sysadmin mail address, to which will be sent the report e-mail.
|
protected Map<String,Long> |
_validationStepId
A Map of the validation step ID by workflow name.
|
protected PurgeVersionsManager |
_versionPurger
The version purger.
|
protected WorkflowProvider |
_workflowProvider
The workflow provider
|
Constructor and Description |
---|
PurgeContentsEngine() |
Modifier and Type | Method and Description |
---|---|
protected void |
checkInitialization()
Check the initialization and throw an exception if not initialized.
|
void |
configure(Configuration configuration)
Configure the engine (called by the scheduler).
|
protected Map<String,Long> |
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.
|
protected Map<String,String> |
getEmailParams(Date startDate,
Date endDate,
int totalContentsPurged,
int totalVersionsPurged)
Get the report e-mail parameters.
|
protected Map<String,String> |
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.
|
private String |
getMailBody(String uri,
Map<String,String> parameters)
Get a mail part.
|
protected String |
getMailUri(Map<String,String> parameters)
Get the pipeline uri for mail body
|
void |
initialize(ServiceManager manager,
Context context)
Initialize the purge engine.
|
protected void |
purgeContents()
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 |
sendMail(Date startDate,
Date endDate,
int totalContentsPurged,
int totalVersionsPurged)
Send the purge report e-mail.
|
protected ServiceManager _manager
protected boolean _initialized
protected Context _environmentContext
protected AmetysObjectResolver _ametysResolver
protected SourceResolver _sourceResolver
protected PurgeVersionsManager _versionPurger
protected WorkflowProvider _workflowProvider
protected I18nUtils _i18nUtils
protected Map<String,Long> _validationStepId
protected int _firstVersionsToKeep
protected String _sysadminMail
public PurgeContentsEngine()
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
manager
- the avalon service manager.context
- the avalon context.ContextException
- If an error occurredServiceException
- If an error occurredpublic void configure(Configuration configuration) throws ConfigurationException
configuration
- the component configuration.ConfigurationException
- If an error occurredprotected Map<String,Long> configureValidationStepId(Configuration configuration) throws ConfigurationException
configuration
- the component configuration.ConfigurationException
- If an error occurredprotected void checkInitialization()
protected void dispose()
protected void purgeContents() throws AmetysRepositoryException
AmetysRepositoryException
- if an error occurs.protected void sendMail(Date startDate, Date endDate, int totalContentsPurged, int totalVersionsPurged)
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.protected void sendErrorMail(Date startDate, Throwable throwable)
startDate
- the purge start date.throwable
- the error.protected Map<String,String> getEmailParams(Date startDate, Date endDate, int totalContentsPurged, int totalVersionsPurged)
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.protected Map<String,String> getErrorEmailParams(Date startDate, Throwable throwable)
startDate
- the purge start date.throwable
- the error.protected String getMailBody(Map<String,String> parameters) throws IOException
parameters
- the pipeline parameters.IOException
- If an error occurredprivate String getMailBody(String uri, Map<String,String> parameters) throws IOException
uri
- The url where to get the body of the mailparameters
- the pipeline parameters.IOException
- If an error occurredprotected String getMailUri(Map<String,String> parameters)
parameters
- the mail parametersprotected String getErrorMailUri(Map<String,String> parameters)
parameters
- the mail parameters