Class NotificationPreferenceScriptService

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

    @Component
    @Named("notification.preferences")
    @Singleton
    public class NotificationPreferenceScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Script service for the notification preferences.
    Since:
    9.7RC1
    Version:
    $Id: 1bb72380e831f5a64b62ce9b03da5eaa26af46b8 $
    • Constructor Detail

      • NotificationPreferenceScriptService

        public NotificationPreferenceScriptService()
    • Method Detail

      • saveNotificationPreferences

        public void saveNotificationPreferences​(String json,
                                                org.xwiki.model.reference.DocumentReference userReference)
                                         throws NotificationException,
                                                org.xwiki.security.authorization.AccessDeniedException
        Save preferences given as JSON.
        Parameters:
        json - a list of preferences as JSON
        userReference - reference of the user concerned by the preferences
        Throws:
        NotificationException - if error happens
        org.xwiki.security.authorization.AccessDeniedException - if the current user has not the right to edit the given document
      • saveNotificationPreferences

        public void saveNotificationPreferences​(String json)
                                         throws NotificationException
        Update notification preferences of the given user.
        Parameters:
        json - a list of notification preferences represented as JSON
        Throws:
        NotificationException - if an error occurs
      • saveNotificationPreferencesForCurrentWiki

        public void saveNotificationPreferencesForCurrentWiki​(String json)
                                                       throws NotificationException,
                                                              org.xwiki.security.authorization.AccessDeniedException
        Update notification preferences of the current wiki.
        Parameters:
        json - a list of notification preferences represented as JSON
        Throws:
        NotificationException - if an error occurs
        org.xwiki.security.authorization.AccessDeniedException - if the current user has not the right to administrate the current wiki
      • setStartDate

        public void setStartDate​(Date startDate)
                          throws NotificationException
        Set the start date for the current user.
        Parameters:
        startDate - the date before which we ignore notifications
        Throws:
        NotificationException - if an error occurs
      • setStartDate

        public void setStartDate​(String userId,
                                 Date startDate)
                          throws NotificationException
        Set the start date for every notification preference of the given user.
        Parameters:
        userId - id of the user
        startDate - the date before which we ignore notifications
        Throws:
        NotificationException - if an error occurs
      • hasAnyEnabledNotificationPreferences

        public boolean hasAnyEnabledNotificationPreferences()
                                                     throws NotificationException
        Returns:
        if there is a least one preference enabled
        Throws:
        NotificationException - if an error occurs
        Since:
        9.9RC1
      • getDiffType

        public NotificationEmailDiffType getDiffType()
        Returns:
        the diff type for emails configured for the current user
        Since:
        9.11RC1
      • getDiffType

        public NotificationEmailDiffType getDiffType​(String userId)
        Parameters:
        userId - id of a user
        Returns:
        the diff type for emails configured for the given user
        Since:
        9.11RC1
      • getDiffType

        @Unstable
        public NotificationEmailDiffType getDiffType​(org.xwiki.user.UserReference user)
        Parameters:
        user - reference of a user
        Returns:
        the diff type for emails configured for the given user
        Since:
        14.10
      • getInterval

        @Unstable
        public NotificationEmailInterval getInterval()
        Returns:
        the email notification interval configured for the current user
        Since:
        14.10
      • getInterval

        @Unstable
        public NotificationEmailInterval getInterval​(org.xwiki.user.UserReference user)
        Parameters:
        user - reference of a user
        Returns:
        the notification email interval configured for the given user
        Since:
        14.10
      • isEventTypeEnabled

        public boolean isEventTypeEnabled​(String eventType,
                                          NotificationFormat format,
                                          String wiki)
                                   throws NotificationException,
                                          org.xwiki.security.authorization.AccessDeniedException
        Parameters:
        eventType - an event type
        format - a notification format
        wiki - id of the wiki
        Returns:
        either or not the given event type is enabled by default on the given wiki in the given format
        Throws:
        NotificationException - if an error happens
        org.xwiki.security.authorization.AccessDeniedException - if the current user has not the admin right on the wiki
      • isEventTypeEnabled

        public boolean isEventTypeEnabled​(String eventType,
                                          NotificationFormat format)
                                   throws NotificationException
        Parameters:
        eventType - an event type
        format - a notification format
        Returns:
        either or not the given event type is enabled for the current user in the given format
        Throws:
        NotificationException - if an error happens
      • isEventTypeEnabledForUser

        public boolean isEventTypeEnabledForUser​(String eventType,
                                                 NotificationFormat format,
                                                 org.xwiki.user.UserReference userReference)
                                          throws NotificationException
        Parameters:
        eventType - an event type
        format - a notification format
        userReference - the reference of the user for which to check the event type
        Returns:
        either or not the given event type is enabled for the given user in the given format
        Throws:
        NotificationException - if an error happens
        Since:
        13.2RC1