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 WorkspaceModuleExtensionPoint
_moduleManagerEP
The workspace module managers EPprotected String
_pluginName
The name of current pluginprotected ProjectManager
_projectManager
The project managerprotected RenderingContextHandler
_renderingContextHandler
The rendering context handlerprotected AmetysObjectResolver
_resolver
The Ametys Object Resolverprotected RightManager
_rightManager
The rights managerprotected 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
_getPath(String rootPath, String path)
format the path without the root pathvoid
contextualize(Context context)
protected String
getDefaultLanguage()
Get the default language to resolve module's pageprotected List<String>
getMailCommonParams(Project project, User issuer, String explorerNodeId)
Get the common mail parametersprotected Page
getModulePage(Project project, String moduleId)
Get the module's pageprotected String
getModuleUrl(Project project, String moduleId, String objectId)
Get the absolute full url of module'pageint
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 String
getProjectUrl(Project project)
Get the absolute url of projectprotected abstract String
getRightIdForNotify()
Get the right to check allowed users to notify by mailprotected abstract String
getUrl(Project project, String objectId)
Get the URL of project to insert in email bodyprotected List<UserIdentity>
getUsersToNotify(String eventId, AmetysObject object)
Get the users allowed to be notifiedprotected abstract void
notifyEvent(Project project, String eventId, Map<String,Object> eventParams, User issuer)
Notify email by mailvoid
observe(Event event, Map<String,Object> transientVars)
Observes an event.protected void
sendMail(String eventId, List<UserIdentity> recipients, String mailBodyi18nKey, String mailSubjecti18nKey, List<String> mailBodyParams, List<String> mailSubjectParams)
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
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys Object Resolver
-
_userManager
protected UserManager _userManager
The users manager
-
_rightManager
protected RightManager _rightManager
The rights manager
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils
-
_projectManager
protected ProjectManager _projectManager
The project manager
-
_renderingContextHandler
protected RenderingContextHandler _renderingContextHandler
The rendering context handler
-
_pluginName
protected String _pluginName
The name of current plugin
-
_moduleManagerEP
protected WorkspaceModuleExtensionPoint _moduleManagerEP
The workspace module managers EP
-
-
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 abstract void notifyEvent(Project project, String eventId, Map<String,Object> eventParams, User issuer)
Notify email by mail- Parameters:
project
- The projecteventId
- The id of eventeventParams
- The event's argumentsissuer
- The issuer
-
getProject
protected Project getProject(Event event)
Get the project from event- Parameters:
event
- The event- Returns:
- the project or null if not found
-
getMailCommonParams
protected List<String> getMailCommonParams(Project project, User issuer, String explorerNodeId)
Get the common mail parameters- Parameters:
project
- The parent projectissuer
- The user responsible of the actionexplorerNodeId
- the id of the explorer node. Can be null.- Returns:
- an array of strings used in every mail
-
getDefaultLanguage
protected String getDefaultLanguage()
Get the default language to resolve module's page- Returns:
- The default language
-
getModulePage
protected Page getModulePage(Project project, String moduleId)
Get the module's page- Parameters:
project
- The projectmoduleId
- The module- Returns:
- The page or
null
if not found
-
getModuleUrl
protected String getModuleUrl(Project project, String moduleId, String objectId)
Get the absolute full url of module'page- Parameters:
project
- The projectmoduleId
- The module. Can not be nullobjectId
- The id of concerned object. Can be null.- Returns:
- The
-
getProjectUrl
protected String getProjectUrl(Project project)
Get the absolute url of project- Parameters:
project
- The project- Returns:
- the project's url
-
getUrl
protected abstract String getUrl(Project project, String objectId)
Get the URL of project to insert in email body- Parameters:
project
- The projectobjectId
- The id of concerned object- Returns:
- The full URL
-
sendMail
protected void sendMail(String eventId, List<UserIdentity> recipients, String mailBodyi18nKey, String mailSubjecti18nKey, List<String> mailBodyParams, List<String> mailSubjectParams)
Sent an email- Parameters:
eventId
- The id of eventrecipients
- The recipients of the mailmailBodyi18nKey
- i18n key for the bodymailSubjecti18nKey
- i18n key for the subjectmailBodyParams
- parameters for the bodymailSubjectParams
- parameters for the subject
-
getUsersToNotify
protected List<UserIdentity> getUsersToNotify(String eventId, AmetysObject object)
Get the users allowed to be notified- Parameters:
eventId
- The id of eventobject
- The object on which to test rights- Returns:
- The allowed users
-
getRightIdForNotify
protected abstract String getRightIdForNotify()
Get the right to check allowed users to notify by mail- Returns:
- the right id to check
-
-