Interface NotificationRulesManager

    • Method Detail

      • isRulesWithEventsConfigured

        boolean isRulesWithEventsConfigured​(long userId,
                                            @NotNull
                                            String notifierType)
                                     throws UserNotFoundException
        Returns true if specified user has notification rules with one or more events configured for specified notifier type. In other words this method returns true if user configured his/her rules to receive notifications.
        Parameters:
        userId - id of the user
        notifierType - type of the notifier
        Returns:
        returns true if user configured his/her rules to receive notifications
        Throws:
        UserNotFoundException - if user does not exist
      • findRulesByNotificatorType

        Map<Long,​List<NotificationRule>> findRulesByNotificatorType​(@NotNull
                                                                          String notifierType)
        Returns map of user id to list of notification rules for specified notifier type.
        Parameters:
        notifierType - type of the notifier
        Returns:
        map of user id to list of notification rules
      • applyOrder

        void applyOrder​(long userId,
                        @NotNull
                        String notifierType,
                        @NotNull
                        long[] ruleIds)
        Sort notification rules in the specified order
        Parameters:
        userId - id of the user
        notifierType - type of the notifier
        ruleIds - ids of the rules in the required order
      • findConflictingRules

        @Nullable
        Collection<Long> findConflictingRules​(long userId,
                                              @NotNull
                                              String notifierType,
                                              @NotNull
                                              WatchedBuilds watch)
                                       throws UserNotFoundException
        Searches for rules which intersect with specified watched builds in the list of user rules for specified notifier type. Rules intersect if they watch for same object, i.e. for same build configuration or for same project or if they both watch for builds with changes.
        Parameters:
        userId - id of the user
        notifierType - type of the notifier
        watch - watched builds
        Returns:
        list of conflicting rules ids
        Throws:
        UserNotFoundException - if user does not exist
      • findRuleById

        @Nullable
        NotificationRule findRuleById​(long userId,
                                      long ruleId)
                               throws UserNotFoundException
        Searches for a rule with specified id among rules of specified user
        Parameters:
        userId - id of the user
        ruleId - id of the rule
        Returns:
        a found rule, or null
        Throws:
        UserNotFoundException - if user does not exist
      • addListener

        void addListener​(@NotNull
                         NotificationRulesListener<Long> listener)
        Registers new user notification rules listener
        Parameters:
        listener - new listener.
      • getAllRulesByNotificatorType

        @NotNull
        Map<Long,​List<NotificationRule>> getAllRulesByNotificatorType​(@NotNull
                                                                            String notifierType)
        Returns a map of user id to list of all notification rules (including the rules of all groups containing the user) for the specified notifier type.

        The rules corresponding to one usergroup are grouped together, but the order of usergroups isn't well-defined. Guaranteed preceding the user rules of group rules.

        Parameters:
        notifierType - type of the notifier
        Returns:
        map of user id to list of notification rules
        Since:
        4.5
      • getAllUserNotificationRules

        @NotNull
        List<NotificationRule> getAllUserNotificationRules​(long userId,
                                                           @NotNull
                                                           String notifierType)
                                                    throws UserNotFoundException
        Returns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.
        Parameters:
        notifierType - type of the notifier
        Returns:
        list of notification rules for specified notifier
        Throws:
        UserNotFoundException - if user with specified id does not exist in current login domain UserModel.findUserById(long).
        Since:
        4.5
      • getAllRulesByNotificatorType

        Map<Long,​List<NotificationRule>> getAllRulesByNotificatorType​(String notificatorType,
                                                                            Filter<NotificationRule> notificationRuleFilter)
        Returns a map of user id to list of all notification rules (including the rules of all groups containing the user) for the specified notifier type filtered with provided filter.

        The rules corresponding to one usergroup are grouped together, but the order of usergroups isn't well-defined. Guaranteed preceding the user rules of group rules.

        Parameters:
        notificatorType - type of the notifier
        notificationRuleFilter - notification rule filter
        Returns:
        list of notification rules for specified notifier
        Throws:
        UserNotFoundException - if user with specified id does not exist in current login domain UserModel.findUserById(long).
        Since:
        2018.2