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 EmailHelperprotected static final Stringprotected GeneralSettingsDescriptorprotected Map<String, NotificationListenerHook> static final ComponentNameprotected static final Stringprotected static final Stringprotected NotificationRegistryprotected static final Stringprotected List<NotificationListenerVeto> protected EventProducerprotected Stringprotected static final StringFields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(ComponentContext context) Activates the component.voidaddSubscription(String username, String notification, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal, String notificationName) Called when a user subscribes to a notification.voidaddSubscriptions(String username, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal) voiddeactivate(ComponentContext context) Deactivates the component.protected static DocumentModelprotected voidprotected voiddoFireEvent(Event event) <T> TgetAdapter(Class<T> adapter) Returns an object which is an instance of the given class associated with this object.Returns the name of theMailSenderthat will handle notificationMailMessagesDeprecated.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 URLgetTemplateURL(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.voidregisterContribution(Object contribution, String xp, ComponentInstance component) voidremoveSubscription(String username, String notification, DocumentModel doc) Called when a user cancels his notification.voidremoveSubscriptions(String username, List<String> notifications, DocumentModel doc) protected voidvoidsendDocumentByMail(DocumentModel doc, String freemarkerTemplateName, String subject, String comment, NuxeoPrincipal sender, List<String> sendTo) Sends an e-mail directly.voidDirectly sends a notification to the principal, using the data provided in the mapvoidsetEmailHelper(EmailHelper emailHelper) voidstart(ComponentContext context) Start the component.voidstop(ComponentContext context) Stop the component.voidunregisterContribution(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, unregisterExtensionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:AdaptableReturns an object which is an instance of the given class associated with this object. Returnsnullif no such object can be found.- Specified by:
getAdapterin interfaceAdaptable- Overrides:
getAdapterin classDefaultComponent- Parameters:
adapter- the adapter class to look up- Returns:
- a object castable to the given class, or
nullif this object does not have an adapter for the given class
-
activate
Description copied from interface:ComponentActivates the component.This method is called by the runtime when a component is activated.
- Specified by:
activatein interfaceComponent- Overrides:
activatein classDefaultComponent- Parameters:
context- the runtime context
-
deactivate
Description copied from interface:ComponentDeactivates the component.This method is called by the runtime when a component is deactivated.
- Specified by:
deactivatein interfaceComponent- Overrides:
deactivatein classDefaultComponent- Parameters:
context- the runtime context
-
start
Description copied from interface:ComponentStart the component. This method is called after all the components were resolved and activated- Specified by:
startin interfaceComponent- Overrides:
startin classDefaultComponent
-
stop
Description copied from interface:ComponentStop the component.- Specified by:
stopin interfaceComponent- Overrides:
stopin classDefaultComponent
-
registerContribution
- Overrides:
registerContributionin classDefaultComponent
-
unregisterContribution
- Overrides:
unregisterContributionin classDefaultComponent
-
getTemplateUrl
- Specified by:
getTemplateUrlin interfaceNotificationManager- Parameters:
name- the template name- Returns:
- the url associated to the template with the given name
-
getSubscribers
Description copied from interface:NotificationManagerGets the users that subscribed to a notification on a certain document.- Specified by:
getSubscribersin interfaceNotificationManager
-
getSubscriptionsForUserOnDocument
Description copied from interface:NotificationManagerGets the notifications for which a user subscribed for a certain document.- Specified by:
getSubscriptionsForUserOnDocumentin interfaceNotificationManager
-
disableEvents
-
restoreEvents
-
addSubscription
public void addSubscription(String username, String notification, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal, String notificationName) Description copied from interface:NotificationManagerCalled when a user subscribes to a notification.- Specified by:
addSubscriptionin interfaceNotificationManager
-
addSubscriptions
public void addSubscriptions(String username, DocumentModel doc, Boolean sendConfirmationEmail, NuxeoPrincipal principal) - Specified by:
addSubscriptionsin interfaceNotificationManager
-
removeSubscriptions
- Specified by:
removeSubscriptionsin interfaceNotificationManager
-
doFireEvent
-
removeSubscription
Description copied from interface:NotificationManagerCalled when a user cancels his notification.- Specified by:
removeSubscriptionin 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:NotificationManagerReturns the name of theMailSenderthat will handle notificationMailMessages- Specified by:
getMailSenderNamein interfaceNotificationManager
-
getNotificationByName
Description copied from interface:NotificationManagerReturns a notification with all data loaded (label, etc).- Specified by:
getNotificationByNamein interfaceNotificationManager
-
sendNotification
public void sendNotification(String notificationName, Map<String, Object> infoMap, String userPrincipal) Description copied from interface:NotificationManagerDirectly 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:
sendNotificationin 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:NotificationManagerSends an e-mail directly.- Specified by:
sendDocumentByMailin interfaceNotificationManager
-
getNotificationsForSubscriptions
- Specified by:
getNotificationsForSubscriptionsin interfaceNotificationManager
-
getNotificationsForEvents
- Specified by:
getNotificationsForEventsin interfaceNotificationManager
-
getEmailHelper
-
setEmailHelper
-
getNotificationEventNames
Description copied from interface:NotificationManagerGets the list of event names used by notifications.- Specified by:
getNotificationEventNamesin interfaceNotificationManager
-
getListenerHooks
-
getNotificationVetos
-
getUsersSubscribedToNotificationOnDocument
public List<String> getUsersSubscribedToNotificationOnDocument(String notification, DocumentModel doc) Description copied from interface:NotificationManagerGets all users and groups that subscribed to a notification on a document This is used in management of subscriptions.- Specified by:
getUsersSubscribedToNotificationOnDocumentin interfaceNotificationManager
-
getSubscribedDocuments
public List<DocumentModel> getSubscribedDocuments(String prefixedPrincipalName, String repositoryName) Description copied from interface:NotificationManagerReturns the list of live docs the user is subscribed to in the given repository .- Specified by:
getSubscribedDocumentsin interfaceNotificationManager
-
detachDocumentModel
-
getMailSenderName()instead.