Package org.ametys.cms.workflow.archive
Class ArchiveContentsSchedulable
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
org.ametys.cms.workflow.archive.ArchiveContentsSchedulable
- All Implemented Interfaces:
Schedulable
,LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ArchiveContentsSchedulable
Runnable engine that archive the contents that have an scheduled archiving
date set before the current date.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
AbstractStaticSchedulable.SchedulableParameterParser
-
Field Summary
Modifier 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 cocoon environment context.protected I18nUtils
The i18n utils.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.Fields inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
_acceptConcurrentExecution, _context, _description, _iconGlyph, _iconLarge, _iconMedium, _iconSmall, _id, _label, _parameters, _pluginName, _private, _schedulableParameterTypeExtensionPoint, _smanager, _userManager
-
Constructor Summary
-
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)void
configure
(Configuration configuration) Configure the engine (called by the scheduler).void
contextualize
(Context context) void
execute
(JobExecutionContext context) The action to perform when a trigger is fired.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 parametersprotected 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.void
service
(ServiceManager manager) protected void
setRequestAttributes
(Request request, Content content) Set the necessary request attributesMethods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, getDescription, getIconGlyph, getIconLarge, getIconMedium, getIconSmall, getId, getLabel, getParameters, isPrivate, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_logger
The logger. -
_manager
The service manager. -
_baseUrl
The server base URL. -
_environmentContext
The cocoon environment context. -
_ametysResolver
The ametys object resolver. -
_sourceResolver
The avalon source resolver. -
_rightManager
The rights 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
-
ArchiveContentsSchedulable
public ArchiveContentsSchedulable()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSchedulable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Overrides:
contextualize
in classAbstractStaticSchedulable
- Throws:
ContextException
-
configure
Configure the engine (called by the scheduler).- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractStaticSchedulable
- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- If an error occurred
-
execute
Description copied from interface:Schedulable
The action to perform when a trigger is fired. Do not manually call this method.- Specified by:
execute
in interfaceSchedulable
- Specified by:
execute
in classAbstractStaticSchedulable
- Parameters:
context
- the context- Throws:
Exception
- if an error occured
-
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.
-