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
Modifier and TypeFieldDescriptionprotected DocumentViewCodecManager
protected EmailHelper
protected static final String
protected GeneralSettingsDescriptor
protected final Map<String,
NotificationListenerHook> static final ComponentName
protected static final String
protected static final String
protected NotificationRegistry
protected static final String
protected NotificationListenerVetoRegistry
protected EventProducer
protected String
static final String
Deprecated.since 10.2, seems unusedprotected static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
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.since 2023.4 usegetMailSenderName()
instead.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.static URL
getTemplateURL
(String name) getUsersSubscribedToNotificationOnDocument
(String notification, DocumentModel doc) Gets all users and groups that subscribed to a notification on a document This is used in management of subscritptions.void
registerExtension
(Extension extension) Registers the given extension.protected void
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
unregisterExtension
(Extension extension) Unregisters the given extension.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
addRuntimeMessage, addRuntimeMessage, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, setLastModified, setModifiedNow, setName, stop, unregister, unregisterContribution
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
-
SUBSCRIPTION_NAME
Deprecated.since 10.2, seems unused- See Also:
-
NOTIFICATIONS_EP
- See Also:
-
TEMPLATES_EP
- See Also:
-
GENERAL_SETTINGS_EP
- See Also:
-
NOTIFICATION_HOOK_EP
- See Also:
-
NOTIFICATION_VETO_EP
- See Also:
-
TEMPLATES_MAP
-
emailHelper
-
generalSettings
-
notificationRegistry
-
docLocator
-
hookListeners
-
notificationVetoRegistry
-
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
-
registerExtension
Description copied from interface:Extensible
Registers the given extension.- Specified by:
registerExtension
in interfaceExtensible
- Overrides:
registerExtension
in classDefaultComponent
- Parameters:
extension
- the extension to register
-
registerGeneralSettings
-
unregisterExtension
Description copied from interface:Extensible
Unregisters the given extension.- Specified by:
unregisterExtension
in interfaceExtensible
- Overrides:
unregisterExtension
in classDefaultComponent
- Parameters:
extension
- the extension to unregister
-
getNotificationListenerVetoRegistry
-
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
-
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 adress(es) 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 subscritptions.- 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
-