Package org.ametys.cms.alerts
Class AlertSchedulable
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
org.ametys.cms.alerts.AlertSchedulable
- All Implemented Interfaces:
Schedulable
,LogEnabled
,PluginAware
,Initializable
,Component
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
AlertSchedulable
Alerts engine: sends alerts mail.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
Binary date expression: test on two metadatas.Nested classes/interfaces inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
AbstractStaticSchedulable.SchedulableParameterParser
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final ExpressionContext
The context used for validation alerts expressionsprotected String
The "waiting for validation" e-mail body i18n key.The "waiting for validation" e-mail will be sent to users that have at least one of this rights.protected String
The "waiting for validation" e-mail subject i18n key.protected String
The server base URL.protected Context
The cocoon environment context.protected I18nUtils
The i18n utils.protected boolean
Is the engine initialized ?protected String
The instant alert e-mail body i18n key.The instant alert e-mail will be sent to users that have this at least one of this rights.protected String
The instant alert e-mail subject i18n key.protected String
The content of "from" field in emails.protected ServiceManager
The service manager.protected String
The reminder e-mail body i18n key.The reminder e-mail will be sent to users that have this at least one of this rights.protected String
The reminder e-mail subject i18n key.protected AmetysObjectResolver
The ametys object resolver.protected RightManager
The rights manager.protected String
The scheduled archiving reminder e-mail body i18n key.The scheduled archiving reminder e-mail will be sent to users that have this at least one of this rights.protected String
The scheduled archiving reminder e-mail subject i18n key.protected String
The "unmodified content" e-mail body i18n key.The "unmodified content" e-mail will be sent to users that have at least one of this rights.protected int[]
Only contents in this steps will be taken into account for the "unmodified content" alert.protected String
The "unmodified content" e-mail subject i18n key.static final String
The job context param to specify the target contents when using instantModestatic final String
The job context param to set to true when using instantModestatic final String
The job context param to set the message when using instantModestatic final String
The schedulable idFields 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, _userManager, PROGRESSION_TRACKER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_getAdditionalParams
(Content content) Get the additional i18n parameters for content_getAwaitingValidationParams
(Content content) Get the mail parameters.protected String
_getContentUrl
(Content content) Get the URL to the given content tool._getInstantAlertParams
(Content content) Get the mail parameters for instant alert._getReminderParams
(Content content) Get the mail parameters._getRightsFromConf
(Configuration configuration) Get a set of rights from a configuration.Get the mail parameters._getUnmodifiedContentParams
(Content content) Get the mail parameters.protected void
_removeTimeParts
(Calendar calendar) Remove the time parts from a calendar, leaving only date parts.protected void
Send the "awaiting validation" alerts.protected void
_sendAwaitingValidationEmail
(Content content) Send a "waiting for validation" e-mail alert to all the users who have the right to validate.protected void
_sendInstantAlertEmail
(Content content, String message) Send a instant e-mail alert to all the users who have the right to edit the content.protected void
_sendInstantAlerts
(List<String> contentIds, String message) Send instant alerts on contentsprotected void
_sendMails
(String subject, String body, Set<UserIdentity> users, String from) Send the alert emails.protected void
_sendReminderEmail
(Content content) Send a reminder e-mail to all the users who have the right to edit.protected void
Send the content reminders.protected void
Send a "scheduled archiving reminder" e-mail to all the users who have the right to archive.protected void
Send the scheduled archiving reminders on contents.protected void
Send the unmodified content alerts.protected void
_sendUnmodifiedContentEmail
(Content content) Send a "unmodified content" e-mail alert to all the users who have the right to edit.protected void
_setRequestAttributes
(Content content) Set the necessary request attributesvoid
configure
(Configuration configuration) Configure the engine (called by the scheduler).void
execute
(JobExecutionContext context, ContainerProgressionTracker progressionTracker) Send all the alerts.protected String
getI18nKeyBody
(String bodyI18nKey, Content content) Get the transform i18n body key for specific contentvoid
protected boolean
isInstantMode
(JobDataMap jobDataMap) Check if the scheduler was triggered to send an instant alertvoid
service
(ServiceManager manager) Methods inherited from class org.ametys.plugins.core.impl.schedule.AbstractStaticSchedulable
acceptConcurrentExecution, contextualize, getDescription, getIconGlyph, getIconLarge, getIconMedium, getIconSmall, getId, getLabel, getParameters, getProgressionTracker, isPrivate, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
SCHEDULABLE_ID
The schedulable id -
JOBDATAMAP_INSTANT_MODE_KEY
The job context param to set to true when using instantMode- See Also:
-
JOBDATAMAP_CONTENT_IDS_KEY
The job context param to specify the target contents when using instantMode- See Also:
-
JOBDATAMAP_MESSAGE_KEY
The job context param to set the message when using instantMode- See Also:
-
__VALIDATION_ALERT_EXPR_CONTEXT
The context used for validation alerts expressions -
_manager
The service manager. -
_baseUrl
The server base URL. -
_initialized
Is the engine initialized ? -
_environmentContext
The cocoon environment context. -
_resolver
The ametys object resolver. -
_rightManager
The rights manager. -
_i18nUtils
The i18n utils. -
_mailFrom
The content of "from" field in emails. -
_awaitingValidationRights
The "waiting for validation" e-mail will be sent to users that have at least one of this rights. -
_awaitingValidationSubject
The "waiting for validation" e-mail subject i18n key. -
_awaitingValidationBody
The "waiting for validation" e-mail body i18n key. -
_unmodifiedContentStepIds
Only contents in this steps will be taken into account for the "unmodified content" alert. -
_unmodifiedContentRights
The "unmodified content" e-mail will be sent to users that have at least one of this rights. -
_unmodifiedContentSubject
The "unmodified content" e-mail subject i18n key. -
_unmodifiedContentBody
The "unmodified content" e-mail body i18n key. -
_reminderRights
The reminder e-mail will be sent to users that have this at least one of this rights. -
_reminderSubject
The reminder e-mail subject i18n key. -
_reminderBody
The reminder e-mail body i18n key. -
_scheduledArchivingReminderRights
The scheduled archiving reminder e-mail will be sent to users that have this at least one of this rights. -
_scheduledArchivingReminderSubject
The scheduled archiving reminder e-mail subject i18n key. -
_scheduledArchivingReminderBody
The scheduled archiving reminder e-mail body i18n key. -
_instantAlertRights
The instant alert e-mail will be sent to users that have this at least one of this rights. -
_instantAlertSubject
The instant alert e-mail subject i18n key. -
_instantAlertBody
The instant alert e-mail body i18n key.
-
-
Constructor Details
-
AlertSchedulable
public AlertSchedulable()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractStaticSchedulable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
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 the configuration is not valid
-
_setRequestAttributes
Set the necessary request attributes- Parameters:
content
- The content
-
execute
public void execute(JobExecutionContext context, ContainerProgressionTracker progressionTracker) throws Exception Send all the alerts. Can be overridden to add alerts.- Specified by:
execute
in interfaceSchedulable
- Parameters:
context
- the contextprogressionTracker
- The progression tracker- Throws:
AmetysRepositoryException
- if an error occurs.Exception
- if an error occurred
-
isInstantMode
Check if the scheduler was triggered to send an instant alert- Parameters:
jobDataMap
- the job data map- Returns:
- true if the scheduler was triggered to send an instant alert
-
_sendInstantAlerts
protected void _sendInstantAlerts(List<String> contentIds, String message) throws AmetysRepositoryException Send instant alerts on contents- Parameters:
contentIds
- The contents to alert onmessage
- The custom message to add to the mail- Throws:
AmetysRepositoryException
- if an error occurred
-
_sendInstantAlertEmail
protected void _sendInstantAlertEmail(Content content, String message) throws AmetysRepositoryException Send a instant e-mail alert to all the users who have the right to edit the content.- Parameters:
content
- the content about which to send the alert.message
- the message- Throws:
AmetysRepositoryException
- if an error occurred
-
_sendAwaitingValidationAlerts
Send the "awaiting validation" alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendUnmodifiedAlerts
Send the unmodified content alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendReminders
Send the content reminders.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendScheduledArchivingReminders
Send the scheduled archiving reminders on contents.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendAwaitingValidationEmail
Send a "waiting for validation" e-mail alert to all the users who have the right to validate.- Parameters:
content
- the content about which to send the alert.- Throws:
AmetysRepositoryException
- if an error occured on the repository
-
_sendUnmodifiedContentEmail
Send a "unmodified content" e-mail alert to all the users who have the right to edit.- Parameters:
content
- the content about which to send the alert.- Throws:
AmetysRepositoryException
- if an error occured on the repository
-
_sendReminderEmail
Send a reminder e-mail to all the users who have the right to edit.- Parameters:
content
- the content about which to send the reminder.- Throws:
AmetysRepositoryException
- if an error occured on the repository
-
_sendScheduledArchivingReminderEmail
protected void _sendScheduledArchivingReminderEmail(ModifiableContent content) throws AmetysRepositoryException Send a "scheduled archiving reminder" e-mail to all the users who have the right to archive.- Parameters:
content
- the content about which to send the alert.- Throws:
AmetysRepositoryException
- if an error occured on the repository
-
getI18nKeyBody
Get the transform i18n body key for specific content- Parameters:
bodyI18nKey
- the original body keycontent
- the content- Returns:
- the transform i18n body key
-
_getInstantAlertParams
Get the mail parameters for instant alert.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getAdditionalParams
Get the additional i18n parameters for content- Parameters:
content
- The content- Returns:
- The additional i18n parameters
-
_getAwaitingValidationParams
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getUnmodifiedContentParams
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getReminderParams
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getScheduledArchivingReminderParams
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_sendMails
Send the alert emails.- 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.
-
_getContentUrl
Get the URL to the given content tool.- Parameters:
content
- the content.- Returns:
- the content URL.
-
_removeTimeParts
Remove the time parts from a calendar, leaving only date parts.- Parameters:
calendar
- the calendar.
-
_getRightsFromConf
Get a set of rights from a configuration.- Parameters:
configuration
- the configuration.- Returns:
- the set of rights.
- Throws:
ConfigurationException
- if the configuration is not valid.
-