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
Runnable engine that archive the contents that have an scheduled archiving
date set before the current date.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolver.The user e-mail notification will be sent to users that have this at least one of this rights.protected String
The server base URL.protected Context
The avalon context.protected Context
The cocoon environment context.protected I18nUtils
The i18n utils.protected boolean
Is the engine initialized ?protected Logger
The logger.protected String
The content of "from" field in emails.protected ServiceManager
The service manager.protected RightManager
The rights managerprotected SourceResolver
The avalon source resolver.protected String
The sysadmin mail address, to which will be sent the report e-mail.protected String
The user notification error mail body i18n key.protected String
The user notification error mail subject i18n key.protected String
The user notification mail body i18n key.protected String
The user notification mail subject i18n key.protected UserManager
The users manager. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 void
archiveContents
(Request request) Get the contents that need to be archived, and archive them.protected void
Check the initialization and throw an exception if not initialized.void
configure
(Configuration configuration) Configure the engine (called by the scheduler).protected void
dispose()
Dispose of the resources and looked-up components.getAdminEmailParams
(List<Content> archivedContents, List<Content> contentsWithError) Get the report e-mail parameters.protected String
getArchiveActionUri
(String contentId) Get the pipeline uri for the archive actiongetBodyParamsForContributors
(Content content, boolean archived) Get email body parametersvoid
initialize
(ServiceManager manager, Context context) Initialize the archive engine.void
run()
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.protected void
sendMailToAdministrator
(List<Content> archivedContents, List<Content> contentsWithError) Send the archive report e-mail.protected void
sendMailToContributors
(Content content, Set<UserIdentity> users) Send the mail to alert users that the content has been archived.protected void
setRequestAttributes
(Request request, Content content) Set the necessary request attributes
-
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. -
_rightManager
The rights manager -
_userManager
The users manager. -
_i18nUtils
The i18n utils. -
_mailFrom
The content of "from" field in emails. -
_sysadminMail
The sysadmin mail address, to which will be sent the report e-mail. -
_archiveRights
The user e-mail notification will be sent to users that have this at least one of this rights. -
_userMailBody
The user notification mail body i18n key. -
_userMailSubject
The user notification mail subject i18n key. -
_userErrorMailBody
The user notification error mail body i18n key. -
_userErrorMailSubject
The user notification error mail subject i18n key.
-
-
Constructor Details
-
ArchiveContentsEngine
public ArchiveContentsEngine()
-
-
Method Details
-
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
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- 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. -
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
Set the necessary request attributes- Parameters:
request
- The requestcontent
- The content
-
getArchiveActionUri
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
Get the contents list as String- Parameters:
contents
- The contents- Returns:
- the list of contents as String
-
_getAuthorizedContributors
Get the authorized contributors to receive mail notification- Parameters:
content
- The content to be archived- Returns:
- The user logins
-
sendMailToContributors
Send the mail to alert users that the content has been archived.- Parameters:
content
- The archived contentusers
- The users
-
getBodyParamsForContributors
Get email body parameters- Parameters:
content
- the archived contentarchived
- true if the content has archived- Returns:
- The mail parameters
-
sendErrorMailToContributors
Send the mail to alert users that an error has occurred while trying to archive the content.- Parameters:
content
- The contentusers
- The users
-
_getRequestURI
Get the request URI to set in mail- Parameters:
content
- The content. Can be null- Returns:
- the request URI
-
_sendMailsToUsers
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.
-