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 DocumentViewCodecManager
docLocator
protected EmailHelper
emailHelper
protected static String
GENERAL_SETTINGS_EP
protected GeneralSettingsDescriptor
generalSettings
protected Map<String,NotificationListenerHook>
hookListeners
static ComponentName
NAME
protected static String
NOTIFICATION_HOOK_EP
protected static String
NOTIFICATION_VETO_EP
protected NotificationRegistry
notificationRegistry
protected static String
NOTIFICATIONS_EP
protected NotificationListenerVetoRegistry
notificationVetoRegistry
protected EventProducer
producer
static String
SUBSCRIPTION_NAME
Deprecated.since 10.2, seems unusedprotected static String
TEMPLATES_EP
protected 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 void
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
detachDocumentModel(DocumentModel doc)
protected void
disableEvents(DocumentModel doc)
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.EmailHelper
getEmailHelper()
String
getEMailSubjectPrefix()
Collection<NotificationListenerHook>
getListenerHooks()
String
getMailSessionJndiName()
Notification
getNotificationByName(String selectedNotification)
Returns a notification with all data loaded (label, etc).Set<String>
getNotificationEventNames()
Gets the list of event names used by notifications.NotificationListenerVetoRegistry
getNotificationListenerVetoRegistry()
List<Notification>
getNotificationsForEvents(String eventId)
List<Notification>
getNotificationsForSubscriptions(String parentType)
Collection<NotificationListenerVeto>
getNotificationVetos()
String
getServerUrlPrefix()
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 URL
getTemplateURL(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.void
registerExtension(Extension extension)
Registers the given extension.protected void
registerGeneralSettings(GeneralSettingsDescriptor desc)
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
restoreEvents(DocumentModel doc)
void
sendDocumentByMail(DocumentModel doc, String freemarkerTemplateName, String subject, String comment, NuxeoPrincipal sender, List<String> sendTo)
Sends an e-mail directly.void
sendNotification(String notificationName, Map<String,Object> infoMap, String userPrincipal)
Directly sends a notification to the principal, using the data provided in the mapvoid
setEmailHelper(EmailHelper emailHelper)
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, 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: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
public void activate(ComponentContext context)
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
public void deactivate(ComponentContext context)
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
-
registerExtension
public void registerExtension(Extension extension)
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
protected void registerGeneralSettings(GeneralSettingsDescriptor desc)
-
unregisterExtension
public void unregisterExtension(Extension extension)
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
public NotificationListenerVetoRegistry getNotificationListenerVetoRegistry()
-
getSubscribers
public List<String> getSubscribers(String notification, DocumentModel doc)
Description copied from interface:NotificationManager
Gets the users that subscribed to a notification on a certain document.- Specified by:
getSubscribers
in interfaceNotificationManager
-
getSubscriptionsForUserOnDocument
public List<String> getSubscriptionsForUserOnDocument(String username, DocumentModel doc)
Description copied from interface:NotificationManager
Gets the notifications for which a user subscribed for a certain document.- Specified by:
getSubscriptionsForUserOnDocument
in 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: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
public void removeSubscriptions(String username, List<String> notifications, DocumentModel doc)
- Specified by:
removeSubscriptions
in interfaceNotificationManager
-
doFireEvent
protected void doFireEvent(Event event)
-
removeSubscription
public void removeSubscription(String username, String notification, DocumentModel doc)
Description copied from interface:NotificationManager
Called when a user cancels his notification.- Specified by:
removeSubscription
in interfaceNotificationManager
-
getServerUrlPrefix
public String getServerUrlPrefix()
-
getEMailSubjectPrefix
public String getEMailSubjectPrefix()
-
getMailSessionJndiName
public String getMailSessionJndiName()
-
getNotificationByName
public Notification getNotificationByName(String selectedNotification)
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
public List<Notification> getNotificationsForSubscriptions(String parentType)
- Specified by:
getNotificationsForSubscriptions
in interfaceNotificationManager
-
getNotificationsForEvents
public List<Notification> getNotificationsForEvents(String eventId)
- Specified by:
getNotificationsForEvents
in interfaceNotificationManager
-
getEmailHelper
public EmailHelper getEmailHelper()
-
setEmailHelper
public void setEmailHelper(EmailHelper emailHelper)
-
getNotificationEventNames
public Set<String> getNotificationEventNames()
Description copied from interface:NotificationManager
Gets the list of event names used by notifications.- Specified by:
getNotificationEventNames
in interfaceNotificationManager
-
getListenerHooks
public Collection<NotificationListenerHook> getListenerHooks()
-
getNotificationVetos
public Collection<NotificationListenerVeto> 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
protected static DocumentModel detachDocumentModel(DocumentModel doc)
-
-