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
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolverThe ametys object resolver.The user e-mail notification will be sent to users that have this at least one of this rights.protected StringThe server base URL.protected ContentHelperThe content helperprotected ContextThe cocoon environment context.protected I18nUtilsThe i18n utils.protected org.slf4j.LoggerThe logger.protected StringThe content of "from" field in emails.protected ServiceManagerThe service manager.protected RightManagerThe rights managerprotected SourceResolverThe avalon source resolver.protected StringThe sysadmin mail address, to which will be sent the report e-mail.protected StringThe user notification error mail body i18n key.protected StringThe user notification error mail subject i18n key.protected StringThe user notification mail body i18n key.protected StringThe 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, _startTime, _userLanguagesManager, _userManager, PROGRESSION_TRACKER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the authorized contributors to receive mail notificationprotected String_getContentsListAsString(List<Content> contents, Locale locale) Get the contents list as Stringprotected String_getContentTitle(Content content, Locale locale) Get content title for mailprotected String_getRequestURI(Content content) Get the request URI to set in mailprotected voidSend the emails to users (contributors)voidconfigure(Configuration configuration) Configure the engine (called by the scheduler).voidcontextualize(Context context) voidexecute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) The action to perform when a trigger is fired.Get the report e-mail parameters.protected StringgetArchiveActionUri(String contentId) Get the pipeline uri for the archive actiongetBodyParamsForContributors(Content content, boolean archived, Locale locale) Get email body parametersprotected StringgetContentUri(Content content, boolean archived) Get the content uriprotected voidSend 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 voidSend the mail to alert users that the content has been archived.voidservice(ServiceManager manager) protected voidsetRequestAttributes(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, getProgressionTracker, isPrivate, setPluginInfoMethods 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. -
_contentHelper
The content helper -
_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:
servicein interfaceServiceable- Overrides:
servicein classAbstractStaticSchedulable- Throws:
ServiceException
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Overrides:
contextualizein classAbstractStaticSchedulable- Throws:
ContextException
-
configure
Configure the engine (called by the scheduler).- Specified by:
configurein interfaceConfigurable- Overrides:
configurein classAbstractStaticSchedulable- Parameters:
configuration- the component configuration.- Throws:
ConfigurationException- If an error occurred
-
execute
public void execute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) throws Exception Description copied from interface:SchedulableThe action to perform when a trigger is fired. Do not manually call this method.- Parameters:
context- the contextprogressionTracker- The progression tracker- Throws:
Exception- 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, Locale locale) Get the report e-mail parameters.- Parameters:
archivedContents- The list of archived contentscontentsWithError- The list of contents with errorlocale- The locale- Returns:
- the e-mail parameters.
-
_getContentsListAsString
Get the contents list as String- Parameters:
contents- The contentslocale- The locale in which to get the contents- Returns:
- the list of contents as String
-
_getContentTitle
Get content title for mail- Parameters:
content- the contentlocale- The locale in which to get the content title- Returns:
- the content title
-
_getAuthorizedContributorsByLanguage
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 contentusersByLanguage- The users by language
-
getBodyParamsForContributors
protected List<String> getBodyParamsForContributors(Content content, boolean archived, Locale locale) Get email body parameters- Parameters:
content- the archived contentarchived- true if the content has archivedlocale- The locale of the mail. Cannot be null.- Returns:
- The mail parameters
-
getContentUri
Get the content uri- Parameters:
content- the archived contentarchived- true if the content has archived- Returns:
- the content uri
-
sendErrorMailToContributors
Send the mail to alert users that an error has occurred while trying to archive the content.- Parameters:
content- The contentusersByLanguage- The users by language
-
_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.htmlBody- the e-mail body.users- users to send the mail to.from- the address sending the e-mail.
-