Package org.ametys.cms.alerts
Class AlertEngine
- java.lang.Object
-
- org.ametys.cms.alerts.AlertEngine
-
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
AlertEngine
public class AlertEngine extends Object implements Runnable
Alerts engine: sends alerts mail.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AlertEngine.BinaryExpression
Binary date expression: test on two metadatas.
-
Field Summary
Fields Modifier and Type Field Description protected static ExpressionContext
__VALIDATION_ALERT_EXPR_CONTEXT
The context used for validation alerts expressionsprotected AmetysObjectResolver
_ametysResolver
The ametys object resolver.protected String
_awaitingValidationBody
The "waiting for validation" e-mail body i18n key.protected Set<String>
_awaitingValidationRights
The "waiting for validation" e-mail will be sent to users that have at least one of this rights.protected String
_awaitingValidationSubject
The "waiting for validation" e-mail subject i18n key.protected String
_baseUrl
The server base URL.protected Context
_context
The avalon context.protected Context
_environmentContext
The cocoon environment context.protected I18nUtils
_i18nUtils
The i18n utils.protected boolean
_initialized
Is the engine initialized ?protected String
_instantAlertBody
The instant alert e-mail body i18n key.protected Set<String>
_instantAlertRights
The instant alert e-mail will be sent to users that have this at least one of this rights.protected String
_instantAlertSubject
The instant alert e-mail subject i18n key.protected boolean
_instantMode
True if the engine was been run in instant mode (for instant alerts only)protected static org.slf4j.Logger
_LOGGER
The logger.protected String
_mailFrom
The content of "from" field in emails.protected ServiceManager
_manager
The service manager.protected String
_reminderBody
The reminder e-mail body i18n key.protected Set<String>
_reminderRights
The reminder e-mail will be sent to users that have this at least one of this rights.protected String
_reminderSubject
The reminder e-mail subject i18n key.protected RightManager
_rightManager
The rights manager.protected String
_scheduledArchivingReminderBody
The scheduled archiving reminder e-mail body i18n key.protected Set<String>
_scheduledArchivingReminderRights
The scheduled archiving reminder e-mail will be sent to users that have this at least one of this rights.protected String
_scheduledArchivingReminderSubject
The scheduled archiving reminder e-mail subject i18n key.protected String
_unmodifiedContentBody
The "unmodified content" e-mail body i18n key.protected Set<String>
_unmodifiedContentRights
The "unmodified content" e-mail will be sent to users that have at least one of this rights.protected int[]
_unmodifiedContentStepIds
Only contents in this steps will be taken into account for the "unmodified content" alert.protected String
_unmodifiedContentSubject
The "unmodified content" e-mail subject i18n key.protected UserManager
_userManager
The users manager.
-
Constructor Summary
Constructors Constructor Description AlertEngine()
Default constructorAlertEngine(List<String> contentIds, String message)
Constructor used to send instant alerts
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_checkInitialization()
Check the initialization and throw an exception if not initialized.protected void
_dispose()
Dispose of the resources and looked-up components.protected List<String>
_getAdditionalParams(Content content)
Get the additional i18n parameters for contentprotected List<String>
_getAwaitingValidationParams(Content content)
Get the mail parameters.protected String
_getContentUrl(Content content)
Get the URL to the given content tool.protected List<String>
_getInstantAlertParams(Content content, String message)
Get the mail parameters for instant alert.protected List<String>
_getReminderParams(Content content)
Get the mail parameters.protected Set<String>
_getRightsFromConf(Configuration configuration)
Get a set of rights from a configuration.protected List<String>
_getScheduledArchivingReminderParams(ModifiableContent content)
Get the mail parameters.protected List<String>
_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
_sendAlerts()
Send all the alerts.protected void
_sendAwaitingValidationAlerts()
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()
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
_sendReminders()
Send the content reminders.protected void
_sendScheduledArchivingReminderEmail(ModifiableContent content)
Send a "scheduled archiving reminder" e-mail to all the users who have the right to archive.protected void
_sendScheduledArchivingReminders()
Send the scheduled archiving reminders on contents.protected void
_sendUnmodifiedAlerts()
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 Detail
-
_LOGGER
protected static final org.slf4j.Logger _LOGGER
The logger.
-
__VALIDATION_ALERT_EXPR_CONTEXT
protected static final ExpressionContext __VALIDATION_ALERT_EXPR_CONTEXT
The context used for validation alerts expressions
-
_manager
protected ServiceManager _manager
The service manager.
-
_initialized
protected boolean _initialized
Is the engine initialized ?
-
_environmentContext
protected Context _environmentContext
The cocoon environment context.
-
_ametysResolver
protected AmetysObjectResolver _ametysResolver
The ametys object resolver.
-
_rightManager
protected RightManager _rightManager
The rights manager.
-
_userManager
protected UserManager _userManager
The users manager.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_awaitingValidationRights
protected Set<String> _awaitingValidationRights
The "waiting for validation" e-mail will be sent to users that have at least one of this rights.
-
_awaitingValidationSubject
protected String _awaitingValidationSubject
The "waiting for validation" e-mail subject i18n key.
-
_awaitingValidationBody
protected String _awaitingValidationBody
The "waiting for validation" e-mail body i18n key.
-
_unmodifiedContentStepIds
protected int[] _unmodifiedContentStepIds
Only contents in this steps will be taken into account for the "unmodified content" alert.
-
_unmodifiedContentRights
protected Set<String> _unmodifiedContentRights
The "unmodified content" e-mail will be sent to users that have at least one of this rights.
-
_unmodifiedContentSubject
protected String _unmodifiedContentSubject
The "unmodified content" e-mail subject i18n key.
-
_unmodifiedContentBody
protected String _unmodifiedContentBody
The "unmodified content" e-mail body i18n key.
-
_reminderRights
protected Set<String> _reminderRights
The reminder e-mail will be sent to users that have this at least one of this rights.
-
_reminderSubject
protected String _reminderSubject
The reminder e-mail subject i18n key.
-
_reminderBody
protected String _reminderBody
The reminder e-mail body i18n key.
-
_scheduledArchivingReminderRights
protected Set<String> _scheduledArchivingReminderRights
The scheduled archiving reminder e-mail will be sent to users that have this at least one of this rights.
-
_scheduledArchivingReminderSubject
protected String _scheduledArchivingReminderSubject
The scheduled archiving reminder e-mail subject i18n key.
-
_scheduledArchivingReminderBody
protected String _scheduledArchivingReminderBody
The scheduled archiving reminder e-mail body i18n key.
-
_instantAlertRights
protected Set<String> _instantAlertRights
The instant alert e-mail will be sent to users that have this at least one of this rights.
-
_instantAlertSubject
protected String _instantAlertSubject
The instant alert e-mail subject i18n key.
-
_instantAlertBody
protected String _instantAlertBody
The instant alert e-mail body i18n key.
-
_instantMode
protected boolean _instantMode
True if the engine was been run in instant mode (for instant alerts only)
-
-
Constructor Detail
-
AlertEngine
public AlertEngine()
Default constructor
-
AlertEngine
public AlertEngine(List<String> contentIds, String message)
Constructor used to send instant alerts- Parameters:
contentIds
- The content's idmessage
- the message
-
-
Method Detail
-
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
public void configure(Configuration configuration) throws ConfigurationException
Configure the engine (called by the scheduler).- Parameters:
configuration
- the component configuration.- Throws:
ConfigurationException
- if the configuration is not valid
-
_checkInitialization
protected void _checkInitialization()
Check the initialization and throw an exception if not initialized.
-
_setRequestAttributes
protected void _setRequestAttributes(Content content)
Set the necessary request attributes- Parameters:
content
- The content
-
_dispose
protected void _dispose()
Dispose of the resources and looked-up components.
-
_sendAlerts
protected void _sendAlerts() throws AmetysRepositoryException
Send all the alerts. Can be overridden to add alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendInstantAlerts
protected void _sendInstantAlerts() throws AmetysRepositoryException
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
protected void _sendAwaitingValidationAlerts() throws AmetysRepositoryException
Send the "awaiting validation" alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendUnmodifiedAlerts
protected void _sendUnmodifiedAlerts() throws AmetysRepositoryException
Send the unmodified content alerts.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendReminders
protected void _sendReminders() throws AmetysRepositoryException
Send the content reminders.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendScheduledArchivingReminders
protected void _sendScheduledArchivingReminders() throws AmetysRepositoryException
Send the scheduled archiving reminders on contents.- Throws:
AmetysRepositoryException
- if an error occurs.
-
_sendAwaitingValidationEmail
protected void _sendAwaitingValidationEmail(Content content) throws AmetysRepositoryException
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
protected void _sendUnmodifiedContentEmail(Content content) throws AmetysRepositoryException
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
protected void _sendReminderEmail(Content content) throws AmetysRepositoryException
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
protected String getI18nKeyBody(String bodyI18nKey, Content content)
Get the transform i18n body key for specific content- Parameters:
bodyI18nKey
- the original body keycontent
- the content- Returns:
- the transform i18n body key
-
_getInstantAlertParams
protected List<String> _getInstantAlertParams(Content content, String message)
Get the mail parameters for instant alert.- Parameters:
content
- the content.message
- the message- Returns:
- the parameters.
-
_getAdditionalParams
protected List<String> _getAdditionalParams(Content content)
Get the additional i18n parameters for content- Parameters:
content
- The content- Returns:
- The additional i18n parameters
-
_getAwaitingValidationParams
protected List<String> _getAwaitingValidationParams(Content content)
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getUnmodifiedContentParams
protected List<String> _getUnmodifiedContentParams(Content content)
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getReminderParams
protected List<String> _getReminderParams(Content content)
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_getScheduledArchivingReminderParams
protected List<String> _getScheduledArchivingReminderParams(ModifiableContent content)
Get the mail parameters.- Parameters:
content
- the content.- Returns:
- the parameters.
-
_sendMails
protected void _sendMails(String subject, String body, Set<UserIdentity> users, String from)
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
protected String _getContentUrl(Content content)
Get the URL to the given content tool.- Parameters:
content
- the content.- Returns:
- the content URL.
-
_removeTimeParts
protected void _removeTimeParts(Calendar calendar)
Remove the time parts from a calendar, leaving only date parts.- Parameters:
calendar
- the calendar.
-
_getRightsFromConf
protected Set<String> _getRightsFromConf(Configuration configuration) throws ConfigurationException
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.
-
-