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
public class NotificationService extends DefaultComponent implements NotificationManager
- Author:
- Narcis Paslaru
-
-
Field Summary
Fields Modifier and Type Field Description protected DocumentViewCodecManagerdocLocatorprotected EmailHelperemailHelperprotected static StringGENERAL_SETTINGS_EPprotected GeneralSettingsDescriptorgeneralSettingsprotected Map<String,NotificationListenerHook>hookListenersstatic ComponentNameNAMEprotected static StringNOTIFICATION_HOOK_EPprotected static StringNOTIFICATION_VETO_EPprotected NotificationRegistrynotificationRegistryprotected static StringNOTIFICATIONS_EPprotected NotificationListenerVetoRegistrynotificationVetoRegistryprotected EventProducerproducerstatic StringSUBSCRIPTION_NAMEDeprecated.since 10.2, seems unusedprotected static StringTEMPLATES_EPprotected static Map<String,URL>TEMPLATES_MAP-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description NotificationService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate(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 DocumentModeldetachDocumentModel(DocumentModel doc)protected voiddisableEvents(DocumentModel doc)protected voiddoFireEvent(Event event)<T> TgetAdapter(Class<T> adapter)Returns an object which is an instance of the given class associated with this object.EmailHelpergetEmailHelper()StringgetEMailSubjectPrefix()Collection<NotificationListenerHook>getListenerHooks()StringgetMailSessionJndiName()NotificationgetNotificationByName(String selectedNotification)Returns a notification with all data loaded (label, etc).Set<String>getNotificationEventNames()Gets the list of event names used by notifications.NotificationListenerVetoRegistrygetNotificationListenerVetoRegistry()List<Notification>getNotificationsForEvents(String eventId)List<Notification>getNotificationsForSubscriptions(String parentType)Collection<NotificationListenerVeto>getNotificationVetos()StringgetServerUrlPrefix()List<DocumentModel>getSubscribedDocuments(String prefixedPrincipalName, String repositoryName)Returns the list of live docs the user is subscribed to in the given repository .List<String>getSubscribers(String notification, DocumentModel doc)Gets the users that subscribed to a notification on a certain document.List<String>getSubscriptionsForUserOnDocument(String username, DocumentModel doc)Gets the notifications for which a user subscribed for a certain document.static URLgetTemplateURL(String name)List<String>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.voidregisterExtension(Extension extension)Registers the given extension.protected voidregisterGeneralSettings(GeneralSettingsDescriptor desc)voidremoveSubscription(String username, String notification, DocumentModel doc)Called when a user cancels his notification.voidremoveSubscriptions(String username, List<String> notifications, DocumentModel doc)protected voidrestoreEvents(DocumentModel doc)voidsendDocumentByMail(DocumentModel doc, String freemarkerTemplateName, String subject, String comment, NuxeoPrincipal sender, List<String> sendTo)Sends an e-mail directly.voidsendNotification(String notificationName, Map<String,Object> infoMap, String userPrincipal)Directly sends a notification to the principal, using the data provided in the mapvoidsetEmailHelper(EmailHelper emailHelper)voidunregisterExtension(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, start, 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
applicationStarted, getApplicationStartedOrder
-
Methods inherited from interface org.nuxeo.ecm.platform.notification.api.NotificationManager
getSubscribedDocuments
-
-
-
-
Field Detail
-
NAME
public static final ComponentName NAME
-
SUBSCRIPTION_NAME
@Deprecated public static final String SUBSCRIPTION_NAME
Deprecated.since 10.2, seems unused- See Also:
- Constant Field Values
-
NOTIFICATIONS_EP
protected static final String NOTIFICATIONS_EP
- See Also:
- Constant Field Values
-
TEMPLATES_EP
protected static final String TEMPLATES_EP
- See Also:
- Constant Field Values
-
GENERAL_SETTINGS_EP
protected static final String GENERAL_SETTINGS_EP
- See Also:
- Constant Field Values
-
NOTIFICATION_HOOK_EP
protected static final String NOTIFICATION_HOOK_EP
- See Also:
- Constant Field Values
-
NOTIFICATION_VETO_EP
protected static final String NOTIFICATION_VETO_EP
- See Also:
- Constant Field Values
-
emailHelper
protected EmailHelper emailHelper
-
generalSettings
protected GeneralSettingsDescriptor generalSettings
-
notificationRegistry
protected NotificationRegistry notificationRegistry
-
docLocator
protected DocumentViewCodecManager docLocator
-
hookListeners
protected final Map<String,NotificationListenerHook> hookListeners
-
notificationVetoRegistry
protected NotificationListenerVetoRegistry notificationVetoRegistry
-
producer
protected EventProducer producer
-
-
Method Detail
-
getAdapter
public <T> T getAdapter(Class<T> adapter)
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
public void activate(ComponentContext context)
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
public void deactivate(ComponentContext context)
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
-
registerExtension
public void registerExtension(Extension extension)
Description copied from interface:ExtensibleRegisters the given extension.- Specified by:
registerExtensionin interfaceExtensible- Overrides:
registerExtensionin classDefaultComponent- Parameters:
extension- the extension to register
-
registerGeneralSettings
protected void registerGeneralSettings(GeneralSettingsDescriptor desc)
-
unregisterExtension
public void unregisterExtension(Extension extension)
Description copied from interface:ExtensibleUnregisters the given extension.- Specified by:
unregisterExtensionin interfaceExtensible- Overrides:
unregisterExtensionin classDefaultComponent- Parameters:
extension- the extension to unregister
-
getNotificationListenerVetoRegistry
public NotificationListenerVetoRegistry getNotificationListenerVetoRegistry()
-
getSubscribers
public List<String> getSubscribers(String notification, DocumentModel doc)
Description copied from interface:NotificationManagerGets the users that subscribed to a notification on a certain document.- Specified by:
getSubscribersin interfaceNotificationManager
-
getSubscriptionsForUserOnDocument
public List<String> getSubscriptionsForUserOnDocument(String username, DocumentModel doc)
Description copied from interface:NotificationManagerGets the notifications for which a user subscribed for a certain document.- Specified by:
getSubscriptionsForUserOnDocumentin interfaceNotificationManager
-
disableEvents
protected void disableEvents(DocumentModel doc)
-
restoreEvents
protected void restoreEvents(DocumentModel doc)
-
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
public void removeSubscriptions(String username, List<String> notifications, DocumentModel doc)
- Specified by:
removeSubscriptionsin interfaceNotificationManager
-
doFireEvent
protected void doFireEvent(Event event)
-
removeSubscription
public void removeSubscription(String username, String notification, DocumentModel doc)
Description copied from interface:NotificationManagerCalled when a user cancels his notification.- Specified by:
removeSubscriptionin interfaceNotificationManager
-
getServerUrlPrefix
public String getServerUrlPrefix()
-
getEMailSubjectPrefix
public String getEMailSubjectPrefix()
-
getMailSessionJndiName
public String getMailSessionJndiName()
-
getNotificationByName
public Notification getNotificationByName(String selectedNotification)
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 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:NotificationManagerSends an e-mail directly.- Specified by:
sendDocumentByMailin interfaceNotificationManager
-
getNotificationsForSubscriptions
public List<Notification> getNotificationsForSubscriptions(String parentType)
- Specified by:
getNotificationsForSubscriptionsin interfaceNotificationManager
-
getNotificationsForEvents
public List<Notification> getNotificationsForEvents(String eventId)
- Specified by:
getNotificationsForEventsin interfaceNotificationManager
-
getEmailHelper
public EmailHelper getEmailHelper()
-
setEmailHelper
public void setEmailHelper(EmailHelper emailHelper)
-
getNotificationEventNames
public Set<String> getNotificationEventNames()
Description copied from interface:NotificationManagerGets the list of event names used by notifications.- Specified by:
getNotificationEventNamesin interfaceNotificationManager
-
getListenerHooks
public Collection<NotificationListenerHook> getListenerHooks()
-
getNotificationVetos
public Collection<NotificationListenerVeto> 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 subscritptions.- 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
protected static DocumentModel detachDocumentModel(DocumentModel doc)
-
-