Class NotificationWatchScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Singleton
    @Named("notification.watch")
    public class NotificationWatchScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Script Service to handle the watched entities. We call `Watched Entities` the locations or the users for that we receive all events.
    Since:
    9.8RC1
    Version:
    $Id: 4df933fb507cf09774d408876e6071d7d13970e5 $
    • Constructor Detail

      • NotificationWatchScriptService

        public NotificationWatchScriptService()
    • Method Detail

      • isEnabled

        public boolean isEnabled()
        Returns:
        if the "watched entities" feature is enabled
      • watchLocation

        public void watchLocation​(org.xwiki.model.reference.EntityReference location)
                           throws org.xwiki.notifications.NotificationException
        Add a filter to watch the specified location.
        Parameters:
        location - the location to watch
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
      • unwatchLocation

        public void unwatchLocation​(org.xwiki.model.reference.EntityReference location)
                             throws org.xwiki.notifications.NotificationException
        Remove a filter to stop watching the specified entity.
        Parameters:
        location - the location
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
      • isLocationWatched

        public boolean isLocationWatched​(org.xwiki.model.reference.EntityReference location)
                                  throws org.xwiki.notifications.NotificationException
        Parameters:
        location - the location
        Returns:
        either or not the location is already watched by the current user for any event type.
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
      • isLocationWatchedWithAllEventTypes

        public boolean isLocationWatchedWithAllEventTypes​(org.xwiki.model.reference.EntityReference location)
                                                   throws org.xwiki.notifications.NotificationException
        Parameters:
        location - the location
        Returns:
        either or not the location is already watched by the current user, only for all events type.
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
        Since:
        12.8RC1
      • isUserWatched

        public boolean isUserWatched​(String userId)
                              throws org.xwiki.notifications.NotificationException
        Parameters:
        userId - id of the user
        Returns:
        either or not the user is already watched by the current user
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
        Since:
        9.10RC1
      • watchUser

        public void watchUser​(String userId)
                       throws org.xwiki.notifications.NotificationException
        Add a filter to watch the specified user.
        Parameters:
        userId - the user to watch
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
        Since:
        9.10RC1
      • unwatchUser

        public void unwatchUser​(String userId)
                         throws org.xwiki.notifications.NotificationException
        Remove a filter to stop watching the specified user.
        Parameters:
        userId - the user to unwatch
        Throws:
        org.xwiki.notifications.NotificationException - if an error happens
        Since:
        9.10RC1
      • getAutomaticWatchMode

        public AutomaticWatchMode getAutomaticWatchMode()
        Returns:
        the automatic watch mode configured for the current user
        Since:
        9.9RC1, 9.8.2
      • getAutomaticWatchMode

        public AutomaticWatchMode getAutomaticWatchMode​(org.xwiki.user.UserReference userReference)
                                                 throws org.xwiki.notifications.NotificationException
        Parameters:
        userReference - the user for which to retrieve the watch mode
        Returns:
        the automatic watch mode configured for the given user
        Throws:
        org.xwiki.notifications.NotificationException
        Since:
        13.2RC1
      • getDefaultAutomaticWatchMode

        public AutomaticWatchMode getDefaultAutomaticWatchMode()
        Returns:
        the default automatic watch mode configured for the current wiki
        Since:
        9.11.8, 10.6RC1
      • getWatchedUsers

        public Collection<String> getWatchedUsers()
                                           throws org.xwiki.notifications.NotificationException
        Returns:
        the user watched by the current user
        Throws:
        org.xwiki.notifications.NotificationException - if an error occurs
        Since:
        10.4RC1