Class NotificationService
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.platform.ec.notification.service.NotificationService
- All Implemented Interfaces:
NotificationManager
,Adaptable
,Component
,Extensible
,TimestampedService
- Author:
- Narcis Paslaru
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EmailHelper
protected static final String
protected GeneralSettingsDescriptor
protected Map
<String, NotificationListenerHook> static final ComponentName
protected static final String
protected static final String
protected NotificationRegistry
protected static final String
protected List
<NotificationListenerVeto> protected EventProducer
protected String
protected static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate
(ComponentContext context) Activates the component.void
addSubscription
(String username, String notification, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal, String notificationName) Called when a user subscribes to a notification.void
addSubscriptions
(String username, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal) void
deactivate
(ComponentContext context) Deactivates the component.protected static DocumentModel
protected void
protected void
doFireEvent
(Event event) <T> T
getAdapter
(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.Returns the name of theMailSender
that will handle notificationMailMessage
sDeprecated.getNotificationByName
(String selectedNotification) Returns a notification with all data loaded (label, etc).Gets the list of event names used by notifications.getNotificationsForEvents
(String eventId) getNotificationsForSubscriptions
(String parentType) getSubscribedDocuments
(String prefixedPrincipalName, String repositoryName) Returns the list of live docs the user is subscribed to in the given repository .getSubscribers
(String notification, DocumentModel doc) Gets the users that subscribed to a notification on a certain document.getSubscriptionsForUserOnDocument
(String username, DocumentModel doc) Gets the notifications for which a user subscribed for a certain document.getTemplateUrl
(String name) static URL
getTemplateURL
(String name) Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, useNotificationManager.getTemplateUrl(String)
insteadgetUsersSubscribedToNotificationOnDocument
(String notification, DocumentModel doc) Gets all users and groups that subscribed to a notification on a document This is used in management of subscriptions.void
registerContribution
(Object contribution, String xp, ComponentInstance component) void
removeSubscription
(String username, String notification, DocumentModel doc) Called when a user cancels his notification.void
removeSubscriptions
(String username, List<String> notifications, DocumentModel doc) protected void
void
sendDocumentByMail
(DocumentModel doc, String freemarkerTemplateName, String subject, String comment, NuxeoPrincipal sender, List<String> sendTo) Sends an e-mail directly.void
Directly sends a notification to the principal, using the data provided in the mapvoid
setEmailHelper
(EmailHelper emailHelper) void
start
(ComponentContext context) Start the component.void
stop
(ComponentContext context) Stop the component.void
unregisterContribution
(Object contribution, String xp, ComponentInstance component) Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterExtension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
NAME
-
NOTIFICATIONS_EP
- See Also:
-
TEMPLATES_EP
- See Also:
-
GENERAL_SETTINGS_EP
- See Also:
-
NOTIFICATION_HOOK_EP
- See Also:
-
NOTIFICATION_VETO_EP
- See Also:
-
templateUrls
-
emailHelper
-
generalSettings
-
notificationRegistry
-
hookListeners
-
notificationVetos
-
senderName
-
producer
-
-
Constructor Details
-
NotificationService
public NotificationService()
-
-
Method Details
-
getAdapter
Description copied from interface:Adaptable
Returns an object which is an instance of the given class associated with this object. Returnsnull
if no such object can be found.- Specified by:
getAdapter
in interfaceAdaptable
- Overrides:
getAdapter
in classDefaultComponent
- Parameters:
adapter
- the adapter class to look up- Returns:
- a object castable to the given class, or
null
if this object does not have an adapter for the given class
-
activate
Description copied from interface:Component
Activates the component.This method is called by the runtime when a component is activated.
- Specified by:
activate
in interfaceComponent
- Overrides:
activate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
deactivate
Description copied from interface:Component
Deactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivate
in interfaceComponent
- Overrides:
deactivate
in classDefaultComponent
- Parameters:
context
- the runtime context
-
start
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
registerContribution
- Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
- Overrides:
unregisterContribution
in classDefaultComponent
-
getTemplateUrl
- Specified by:
getTemplateUrl
in interfaceNotificationManager
- Parameters:
name
- the template name- Returns:
- the url associated to the template with the given name
-
getSubscribers
Description copied from interface:NotificationManager
Gets the users that subscribed to a notification on a certain document.- Specified by:
getSubscribers
in interfaceNotificationManager
-
getSubscriptionsForUserOnDocument
Description copied from interface:NotificationManager
Gets the notifications for which a user subscribed for a certain document.- Specified by:
getSubscriptionsForUserOnDocument
in interfaceNotificationManager
-
disableEvents
-
restoreEvents
-
addSubscription
public void addSubscription(String username, String notification, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal, String notificationName) Description copied from interface:NotificationManager
Called when a user subscribes to a notification.- Specified by:
addSubscription
in interfaceNotificationManager
-
addSubscriptions
public void addSubscriptions(String username, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal) - Specified by:
addSubscriptions
in interfaceNotificationManager
-
removeSubscriptions
- Specified by:
removeSubscriptions
in interfaceNotificationManager
-
doFireEvent
-
removeSubscription
Description copied from interface:NotificationManager
Called when a user cancels his notification.- Specified by:
removeSubscription
in interfaceNotificationManager
-
getTemplateURL
Deprecated, for removal: This API element is subject to removal in a future version.since 2025.0, useNotificationManager.getTemplateUrl(String)
instead -
getServerUrlPrefix
-
getEMailSubjectPrefix
-
getMailSessionJndiName
Deprecated.since 2023.4 usegetMailSenderName()
instead. -
getMailSenderName
Description copied from interface:NotificationManager
Returns the name of theMailSender
that will handle notificationMailMessage
s- Specified by:
getMailSenderName
in interfaceNotificationManager
-
getNotificationByName
Description copied from interface:NotificationManager
Returns a notification with all data loaded (label, etc).- Specified by:
getNotificationByName
in interfaceNotificationManager
-
sendNotification
public void sendNotification(String notificationName, Map<String, Object> infoMap, String userPrincipal) Description copied from interface:NotificationManager
Directly sends a notification to the principal, using the data provided in the mapThe map should contain at least the userName of the user calling the method stored under the key "author".
infoMap should also contain all the variables that should be used to make up the body of the notifications message.
- Specified by:
sendNotification
in interfaceNotificationManager
- Parameters:
notificationName
- name of notificationinfoMap
- data used to compose the notification bodyuserPrincipal
- recipient used to get the addresses to send emails
-
sendDocumentByMail
public void sendDocumentByMail(DocumentModel doc, String freemarkerTemplateName, String subject, String comment, NuxeoPrincipal sender, List<String> sendTo) Description copied from interface:NotificationManager
Sends an e-mail directly.- Specified by:
sendDocumentByMail
in interfaceNotificationManager
-
getNotificationsForSubscriptions
- Specified by:
getNotificationsForSubscriptions
in interfaceNotificationManager
-
getNotificationsForEvents
- Specified by:
getNotificationsForEvents
in interfaceNotificationManager
-
getEmailHelper
-
setEmailHelper
-
getNotificationEventNames
Description copied from interface:NotificationManager
Gets the list of event names used by notifications.- Specified by:
getNotificationEventNames
in interfaceNotificationManager
-
getListenerHooks
-
getNotificationVetos
-
getUsersSubscribedToNotificationOnDocument
public List<String> getUsersSubscribedToNotificationOnDocument(String notification, DocumentModel doc) Description copied from interface:NotificationManager
Gets all users and groups that subscribed to a notification on a document This is used in management of subscriptions.- Specified by:
getUsersSubscribedToNotificationOnDocument
in interfaceNotificationManager
-
getSubscribedDocuments
public List<DocumentModel> getSubscribedDocuments(String prefixedPrincipalName, String repositoryName) Description copied from interface:NotificationManager
Returns the list of live docs the user is subscribed to in the given repository .- Specified by:
getSubscribedDocuments
in interfaceNotificationManager
-
detachDocumentModel
-
getMailSenderName()
instead.