Class AbstractSendNotificationObserver
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.workspaces.project.notification.AbstractSendNotificationObserver
-
- All Implemented Interfaces:
Observer
,LogEnabled
,PluginAware
,Contextualizable
,Serviceable
- Direct Known Subclasses:
ResourcesMailNotifierObserver
,TaskMailNotifierObserver
,ThreadsMailNotifierObserver
public abstract class AbstractSendNotificationObserver extends AbstractLogEnabled implements Observer, Serviceable, Contextualizable, PluginAware
Observer
for observing events on resources project
-
-
Field Summary
Fields Modifier and Type Field Description protected Context
_context
The avalon contextprotected I18nUtils
_i18nUtils
The i18n utilsprotected JSONUtils
_jsonUtils
The JSONUtilsprotected NotificationPreferencesHelper
_notificationPrefHelper
The notification helperprotected String
_pluginName
The name of current pluginprotected RenderingContextHandler
_renderingContextHandler
The rendering context handlerprotected AmetysObjectResolver
_resolver
The Ametys Object Resolverprotected RightManager
_rightManager
The right managerprotected SourceResolver
_srcResolver
Source Resolverprotected UserManager
_userManager
The users manager-
Fields inherited from interface org.ametys.core.observation.Observer
MAX_PRIORITY, MIN_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractSendNotificationObserver()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
_getRelativePath(String rootPath, String path)
format the path without the root pathvoid
contextualize(Context context)
protected abstract AmetysObject
getEventAmetysObject(Event event)
Get the AmetysObject that triggered the event to compute the rightsprotected abstract I18nizableText
getI18nSubject(Event event, Project project)
Get theI18nizableText
for mail subjectprotected abstract String
getMailBodyURI(Event event, Project project)
Returns the URI for HTML mail bodyint
getPriority(Event event)
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.protected Project
getProject(Event event)
Get the project from eventprotected abstract String
getRightIdForNotify()
Get the right to check allowed users to notify by mailprotected List<UserIdentity>
getUsersToNotify(String eventId, AmetysObject object, Project project)
Get the users allowed to be notifiedprotected void
notifyEvent(Project project, Event event, List<UserIdentity> recipients)
Notify email by mailvoid
observe(Event event, Map<String,Object> transientVars)
Observes an event.protected void
sendMail(List<UserIdentity> recipients, String subject, String htmlMailBody)
Sent an emailvoid
service(ServiceManager manager)
void
setPluginInfo(String pluginName, String featureName, String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils
-
_jsonUtils
protected JSONUtils _jsonUtils
The JSONUtils
-
_renderingContextHandler
protected RenderingContextHandler _renderingContextHandler
The rendering context handler
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys Object Resolver
-
_rightManager
protected RightManager _rightManager
The right manager
-
_srcResolver
protected SourceResolver _srcResolver
Source Resolver
-
_userManager
protected UserManager _userManager
The users manager
-
_notificationPrefHelper
protected NotificationPreferencesHelper _notificationPrefHelper
The notification helper
-
_pluginName
protected String _pluginName
The name of current plugin
-
-
Constructor Detail
-
AbstractSendNotificationObserver
public AbstractSendNotificationObserver()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
getPriority
public int getPriority(Event event)
Description copied from interface:Observer
Retrieves the priority to observe this event.
This can be used to process a supported event before others observers.- Specified by:
getPriority
in interfaceObserver
- Parameters:
event
- the event.- Returns:
- the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
-
observe
public void observe(Event event, Map<String,Object> transientVars)
Description copied from interface:Observer
Observes an event.
-
notifyEvent
protected void notifyEvent(Project project, Event event, List<UserIdentity> recipients)
Notify email by mail- Parameters:
project
- The projectevent
- The eventrecipients
- The users to notify
-
getEventAmetysObject
protected abstract AmetysObject getEventAmetysObject(Event event)
Get the AmetysObject that triggered the event to compute the rights- Parameters:
event
- the event- Returns:
- the AmetysObject
-
getMailBodyURI
protected abstract String getMailBodyURI(Event event, Project project)
Returns the URI for HTML mail body- Parameters:
event
- the eventproject
- the project- Returns:
- The URI for HTML mail body
-
getI18nSubject
protected abstract I18nizableText getI18nSubject(Event event, Project project)
Get theI18nizableText
for mail subject- Parameters:
event
- the eventproject
- the project- Returns:
- the
I18nizableText
for subject
-
getUsersToNotify
protected List<UserIdentity> getUsersToNotify(String eventId, AmetysObject object, Project project)
Get the users allowed to be notified- Parameters:
eventId
- The id of eventobject
- The object on which to test rightsproject
- The project of the event to test user pref- Returns:
- The allowed users
-
getProject
protected Project getProject(Event event)
Get the project from event- Parameters:
event
- The event- Returns:
- the project or null if not found
-
sendMail
protected void sendMail(List<UserIdentity> recipients, String subject, String htmlMailBody)
Sent an email- Parameters:
recipients
- The recipients of the mailsubject
- The subject of the mailhtmlMailBody
- The HTML mail body
-
getRightIdForNotify
protected abstract String getRightIdForNotify()
Get the right to check allowed users to notify by mail- Returns:
- the right id to check
-
_getRelativePath
protected String _getRelativePath(String rootPath, String path)
format the path without the root path- Parameters:
rootPath
- The root path to removepath
- The absolute path- Returns:
- the local path
-
-