Package org.ametys.cms.workflow.archive
Class ArchiveContentsEngine
- java.lang.Object
-
- org.ametys.cms.workflow.archive.ArchiveContentsEngine
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
ArchiveContentsEngine
public class ArchiveContentsEngine extends Object implements Runnable
Runnable engine that archive the contents that have an scheduled archiving date set before the current date.
-
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver_ametysResolverThe ametys object resolver.protected Set<String>_archiveRightsThe user e-mail notification will be sent to users that have this at least one of this rights.protected String_baseUrlThe server base URL.protected Context_contextThe avalon context.protected Context_environmentContextThe cocoon environment context.protected I18nUtils_i18nUtilsThe i18n utils.protected boolean_initializedIs the engine initialized ?protected org.slf4j.Logger_loggerThe logger.protected String_mailFromThe content of "from" field in emails.protected ServiceManager_managerThe service manager.protected RightManager_rightManagerThe rights managerprotected SourceResolver_sourceResolverThe avalon source resolver.protected String_sysadminMailThe sysadmin mail address, to which will be sent the report e-mail.protected String_userErrorMailBodyThe user notification error mail body i18n key.protected String_userErrorMailSubjectThe user notification error mail subject i18n key.protected String_userMailBodyThe user notification mail body i18n key.protected String_userMailSubjectThe user notification mail subject i18n key.protected UserManager_userManagerThe users manager.
-
Constructor Summary
Constructors Constructor Description ArchiveContentsEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<UserIdentity>_getAuthorizedContributors(Content content)Get the authorized contributors to receive mail notificationprotected String_getContentsListAsString(List<Content> contents)Get the contents list as Stringprotected String_getRequestURI(Content content)Get the request URI to set in mailprotected void_sendMailsToUsers(String subject, String body, Set<UserIdentity> users, String from)Send the emails to users (contributors)protected voidarchiveContents(Request request)Get the contents that need to be archived, and archive them.protected voidcheckInitialization()Check the initialization and throw an exception if not initialized.voidconfigure(Configuration configuration)Configure the engine (called by the scheduler).protected voiddispose()Dispose of the resources and looked-up components.protected List<String>getAdminEmailParams(List<Content> archivedContents, List<Content> contentsWithError)Get the report e-mail parameters.protected StringgetArchiveActionUri(String contentId)Get the pipeline uri for the archive actionprotected List<String>getBodyParamsForContributors(Content content, boolean archived)Get email body parametersvoidinitialize(ServiceManager manager, Context context)Initialize the archive engine.voidrun()protected voidsendErrorMailToContributors(Content content, Set<UserIdentity> users)Send the mail to alert users that an error has occurred while trying to archive the content.protected voidsendMailToAdministrator(List<Content> archivedContents, List<Content> contentsWithError)Send the archive report e-mail.protected voidsendMailToContributors(Content content, Set<UserIdentity> users)Send the mail to alert users that the content has been archived.protected voidsetRequestAttributes(Request request, Content content)Set the necessary request attributes
-
-
-
Field Detail
-
_logger
protected org.slf4j.Logger _logger
The logger.
-
_manager
protected ServiceManager _manager
The service manager.
-
_initialized
protected boolean _initialized
Is the engine initialized ?
-
_environmentContext
protected Context _environmentContext
The cocoon environment context.
-
_ametysResolver
protected AmetysObjectResolver _ametysResolver
The ametys object resolver.
-
_sourceResolver
protected SourceResolver _sourceResolver
The avalon source resolver.
-
_rightManager
protected RightManager _rightManager
The rights manager
-
_userManager
protected UserManager _userManager
The users manager.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_sysadminMail
protected String _sysadminMail
The sysadmin mail address, to which will be sent the report e-mail.
-
_archiveRights
protected Set<String> _archiveRights
The user e-mail notification will be sent to users that have this at least one of this rights.
-
_userMailBody
protected String _userMailBody
The user notification mail body i18n key.
-
_userMailSubject
protected String _userMailSubject
The user notification mail subject i18n key.
-
_userErrorMailBody
protected String _userErrorMailBody
The user notification error mail body i18n key.
-
_userErrorMailSubject
protected String _userErrorMailSubject
The user notification error mail subject i18n key.
-
-
Constructor Detail
-
ArchiveContentsEngine
public ArchiveContentsEngine()
-
-
Method Detail
-
initialize
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException
Initialize the archive engine.- Parameters:
manager- the avalon service manager.context- the avalon context.- Throws:
ContextException- If an error occurredServiceException- If an error occurred
-
configure
public void configure(Configuration configuration) throws ConfigurationException
Configure the engine (called by the scheduler).- Parameters:
configuration- the component configuration.- Throws:
ConfigurationException- If an error occurred
-
checkInitialization
protected void checkInitialization()
Check the initialization and throw an exception if not initialized.
-
dispose
protected void dispose()
Dispose of the resources and looked-up components.
-
archiveContents
protected void archiveContents(Request request) throws AmetysRepositoryException, MalformedURLException, IOException
Get the contents that need to be archived, and archive them.- Parameters:
request- The current request object- Throws:
AmetysRepositoryException- if an error occurs.IOException- If an error occurredMalformedURLException- If an error occurred
-
setRequestAttributes
protected void setRequestAttributes(Request request, Content content)
Set the necessary request attributes- Parameters:
request- The requestcontent- The content
-
getArchiveActionUri
protected String getArchiveActionUri(String contentId)
Get the pipeline uri for the archive action- Parameters:
contentId- the current contend id- Returns:
- a pipeline uri
-
sendMailToAdministrator
protected void sendMailToAdministrator(List<Content> archivedContents, List<Content> contentsWithError)
Send the archive report e-mail.- Parameters:
archivedContents- The list of archived contentscontentsWithError- The list of contents with error
-
getAdminEmailParams
protected List<String> getAdminEmailParams(List<Content> archivedContents, List<Content> contentsWithError)
Get the report e-mail parameters.- Parameters:
archivedContents- The list of archived contentscontentsWithError- The list of contents with error- Returns:
- the e-mail parameters.
-
_getContentsListAsString
protected String _getContentsListAsString(List<Content> contents)
Get the contents list as String- Parameters:
contents- The contents- Returns:
- the list of contents as String
-
_getAuthorizedContributors
protected Set<UserIdentity> _getAuthorizedContributors(Content content)
Get the authorized contributors to receive mail notification- Parameters:
content- The content to be archived- Returns:
- The user logins
-
sendMailToContributors
protected void sendMailToContributors(Content content, Set<UserIdentity> users)
Send the mail to alert users that the content has been archived.- Parameters:
content- The archived contentusers- The users
-
getBodyParamsForContributors
protected List<String> getBodyParamsForContributors(Content content, boolean archived)
Get email body parameters- Parameters:
content- the archived contentarchived- true if the content has archived- Returns:
- The mail parameters
-
sendErrorMailToContributors
protected void sendErrorMailToContributors(Content content, Set<UserIdentity> users)
Send the mail to alert users that an error has occurred while trying to archive the content.- Parameters:
content- The contentusers- The users
-
_getRequestURI
protected String _getRequestURI(Content content)
Get the request URI to set in mail- Parameters:
content- The content. Can be null- Returns:
- the request URI
-
_sendMailsToUsers
protected void _sendMailsToUsers(String subject, String body, Set<UserIdentity> users, String from)
Send the emails to users (contributors)- Parameters:
subject- the e-mail subject.body- the e-mail body.users- users to send the mail to.from- the address sending the e-mail.
-
-