Package org.ametys.cms.alerts
Class AlertEngine
java.lang.Object
org.ametys.cms.alerts.AlertEngine
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
AlertEngine
Alerts engine: sends alerts mail.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Binary date expression: test on two metadatas. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final ExpressionContext
The context used for validation alerts expressionsprotected AmetysObjectResolver
The ametys object resolver.protected 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 avalon context.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 boolean
True if the engine was been run in instant mode (for instant alerts only)protected static final Logger
The logger.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 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.protected UserManager
The users manager. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructorAlertEngine
(List<String> contentIds, String message) Constructor used to send instant alerts -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Check the initialization and throw an exception if not initialized.protected void
_dispose()
Dispose of the resources and looked-up components._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, String message) 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 all the alerts.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
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).protected String
getI18nKeyBody
(String bodyI18nKey, Content content) Get the transform i18n body key for specific contentvoid
initialize
(ServiceManager manager, Context context) Initialize the alert engine.void
run()
-
Field Details
-
_LOGGER
The logger. -
__VALIDATION_ALERT_EXPR_CONTEXT
The context used for validation alerts expressions -
_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. -
_rightManager
The rights manager. -
_userManager
The users 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. -
_instantMode
True if the engine was been run in instant mode (for instant alerts only)
-
-
Constructor Details
-
AlertEngine
public AlertEngine()Default constructor -
AlertEngine
Constructor used to send instant alerts- Parameters:
contentIds
- The content's idmessage
- the message
-
-
Method Details
-
initialize
public void initialize(ServiceManager manager, Context context) throws ContextException, ServiceException Initialize the alert engine.- Parameters:
manager
- the avalon service manager.context
- the avalon context.- Throws:
ContextException
- if the CONTEXT_ENVIRONMENT_CONTEXT cannot be foundServiceException
- if some components cannot be resolved
-
configure
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- if the configuration is not valid
-
_checkInitialization
Check the initialization and throw an exception if not initialized. -
run
-
_setRequestAttributes
Set the necessary request attributes- Parameters:
content
- The content
-
_dispose
Dispose of the resources and looked-up components. -
_sendAlerts
Send all the alerts. Can be overridden to add alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendInstantAlerts
Send instant alerts on contents- 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.message
- the message- 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.
-