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 classAlertEngine.BinaryExpressionBinary date expression: test on two metadatas.
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver_ametysResolverThe ametys object resolver.protected String_awaitingValidationBodyThe "waiting for validation" e-mail body i18n key.protected Set<String>_awaitingValidationRightsThe "waiting for validation" e-mail will be sent to users that have at least one of this rights.protected String_awaitingValidationSubjectThe "waiting for validation" e-mail subject i18n key.protected String_baseUrlThe server base URL.protected Context_contextThe avalon context.protected Context_environmentContextThe cocoon environment context.protected I18nUtils_i18nUtilsThe i18n utils.protected boolean_initializedIs the engine initialized ?protected String_instantAlertBodyThe instant alert e-mail body i18n key.private List<String>_instantAlertContentIdsThe list of contents' id (for instant alerts only)private String_instantAlertMessageThe email message (for instant alerts only)protected Set<String>_instantAlertRightsThe instant alert e-mail will be sent to users that have this at least one of this rights.protected String_instantAlertSubjectThe instant alert e-mail subject i18n key.protected boolean_instantModeTrue if the engine was been run in instant mode (for instant alerts only)protected static org.slf4j.Logger_LOGGERThe logger.protected String_mailFromThe content of "from" field in emails.protected ServiceManager_managerThe service manager.protected String_reminderBodyThe reminder e-mail body i18n key.protected Set<String>_reminderRightsThe reminder e-mail will be sent to users that have this at least one of this rights.protected String_reminderSubjectThe reminder e-mail subject i18n key.protected RightManager_rightManagerThe rights manager.protected String_scheduledArchivingReminderBodyThe scheduled archiving reminder e-mail body i18n key.protected Set<String>_scheduledArchivingReminderRightsThe scheduled archiving reminder e-mail will be sent to users that have this at least one of this rights.protected String_scheduledArchivingReminderSubjectThe scheduled archiving reminder e-mail subject i18n key.protected String_unmodifiedContentBodyThe "unmodified content" e-mail body i18n key.protected Set<String>_unmodifiedContentRightsThe "unmodified content" e-mail will be sent to users that have at least one of this rights.protected int[]_unmodifiedContentStepIdsOnly contents in this steps will be taken into account for the "unmodified content" alert.protected String_unmodifiedContentSubjectThe "unmodified content" e-mail subject i18n key.protected UserManager_userManagerThe 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 attributesvoidconfigure(Configuration configuration)Configure the engine (called by the scheduler).protected StringgetI18nKeyBody(String bodyI18nKey, Content content)Get the transform i18n body key for specific contentvoidinitialize(ServiceManager manager, Context context)Initialize the alert engine.voidrun()
-
-
-
Field Detail
-
_LOGGER
protected static final org.slf4j.Logger _LOGGER
The logger.
-
_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)
-
_instantAlertContentIds
private List<String> _instantAlertContentIds
The list of contents' id (for instant alerts only)
-
_instantAlertMessage
private String _instantAlertMessage
The email message (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.
-
-