Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ec.notification.service
Class NotificationService

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.platform.ec.notification.service.NotificationService
All Implemented Interfaces:
NotificationManager, Adaptable, Component, Extensible

public class NotificationService
extends DefaultComponent
implements NotificationManager

Author:
Narcis Paslaru

Field Summary
static ComponentName NAME
           
static String SUBSCRIPTION_NAME
           
 
Constructor Summary
NotificationService()
           
 
Method Summary
 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 deactivate(ComponentContext context)
          Deactivates the component.
<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.
 NotificationRegistry getNotificationRegistry()
          Returns the notification manager.
 List<Notification> getNotificationsForEvents(String eventId)
           
 List<Notification> getNotificationsForSubscriptions(String parentType)
           
 String getServerUrlPrefix()
           
 List<String> getSubscribers(String notification, String docId)
          Gets the users that subscribed to a notification on a certain document.
 List<String> getSubscriptionsForUserOnDocument(String username, String docId)
          Gets the notifications for which a user subscribed for a certain document.
static URL getTemplateURL(String name)
           
 List<String> getUsersSubscribedToNotificationOnDocument(String notification, String docId)
          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.
 void removeSubscription(String username, String notification, String docId)
          Called when a user cancels his notification.
 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 map
 void setEmailHelper(EmailHelper emailHelper)
           
 void unregisterExtension(Extension extension)
          Unregisters the given extension.
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
applicationStarted, registerContribution, unregisterContribution
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final ComponentName NAME

SUBSCRIPTION_NAME

public static final String SUBSCRIPTION_NAME
See Also:
Constant Field Values
Constructor Detail

NotificationService

public NotificationService()
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. Returns null if no such object can be found.

Specified by:
getAdapter in interface Adaptable
Overrides:
getAdapter in class DefaultComponent
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)
              throws Exception
Description copied from interface: Component
Activates the component.

This method is called by the runtime when a component is activated.

Specified by:
activate in interface Component
Overrides:
activate in class DefaultComponent
Parameters:
context - the runtime context
Throws:
Exception - if an error occurs during activation

deactivate

public void deactivate(ComponentContext context)
                throws Exception
Description copied from interface: Component
Deactivates the component.

This method is called by the runtime when a component is deactivated.

Specified by:
deactivate in interface Component
Overrides:
deactivate in class DefaultComponent
Parameters:
context - the runtime context
Throws:
Exception - if an error occurs during activation

registerExtension

public void registerExtension(Extension extension)
                       throws Exception
Description copied from interface: Extensible
Registers the given extension.

Specified by:
registerExtension in interface Extensible
Overrides:
registerExtension in class DefaultComponent
Parameters:
extension - the extension to register
Throws:
Exception - if any error occurs

unregisterExtension

public void unregisterExtension(Extension extension)
                         throws Exception
Description copied from interface: Extensible
Unregisters the given extension.

Specified by:
unregisterExtension in interface Extensible
Overrides:
unregisterExtension in class DefaultComponent
Parameters:
extension - the extension to unregister
Throws:
Exception - if any error occurs

getNotificationRegistry

public NotificationRegistry getNotificationRegistry()
Description copied from interface: NotificationManager
Returns the notification manager.

Specified by:
getNotificationRegistry in interface NotificationManager

getSubscribers

public List<String> getSubscribers(String notification,
                                   String docId)
                            throws ClientException
Description copied from interface: NotificationManager
Gets the users that subscribed to a notification on a certain document.

Specified by:
getSubscribers in interface NotificationManager
Throws:
ClientException

getSubscriptionsForUserOnDocument

public List<String> getSubscriptionsForUserOnDocument(String username,
                                                      String docId)
                                               throws ClassNotFoundException,
                                                      ClientException
Description copied from interface: NotificationManager
Gets the notifications for which a user subscribed for a certain document.

Specified by:
getSubscriptionsForUserOnDocument in interface NotificationManager
Throws:
ClassNotFoundException
ClientException

addSubscription

public void addSubscription(String username,
                            String notification,
                            DocumentModel doc,
                            Boolean sendConfirmationEmail,
                            NuxeoPrincipal principal,
                            String notificationName)
                     throws ClientException
Description copied from interface: NotificationManager
Called when a user subscribes to a notification.

Specified by:
addSubscription in interface NotificationManager
Throws:
ClientException

removeSubscription

public void removeSubscription(String username,
                               String notification,
                               String docId)
                        throws ClientException
Description copied from interface: NotificationManager
Called when a user cancels his notification.

Specified by:
removeSubscription in interface NotificationManager
Throws:
ClientException

getUsersSubscribedToNotificationOnDocument

public List<String> getUsersSubscribedToNotificationOnDocument(String notification,
                                                               String docId)
                                                        throws ClientException
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 interface NotificationManager
Throws:
ClientException

getTemplateURL

public static URL getTemplateURL(String name)

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 interface NotificationManager

sendNotification

public void sendNotification(String notificationName,
                             Map<String,Object> infoMap,
                             String userPrincipal)
                      throws ClientException
Description copied from interface: NotificationManager
Directly sends a notification to the principal, using the data provided in the map

The 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 interface NotificationManager
Parameters:
notificationName - name of notification
infoMap - data used to compose the notification body
userPrincipal - recipient used to get the adress(es) to send emails
Throws:
ClientException

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 interface NotificationManager

getNotificationsForSubscriptions

public List<Notification> getNotificationsForSubscriptions(String parentType)
Specified by:
getNotificationsForSubscriptions in interface NotificationManager

getNotificationsForEvents

public List<Notification> getNotificationsForEvents(String eventId)
Specified by:
getNotificationsForEvents in interface NotificationManager

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 interface NotificationManager

getListenerHooks

public Collection<NotificationListenerHook> getListenerHooks()

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.