jetbrains.buildServer.notification
Interface NotificationRulesManager


public interface NotificationRulesManager

Manages user notification rules.

See Also:
UserGroupNotificationRulesManager

Method Summary
 void addListener(NotificationRulesListener<java.lang.Long> listener)
          Registers new user notification rules listener
 long addNewRule(long userId, java.lang.String notifierType, NotificationRule rule)
          Adds new rule to the rules of specified user for specified notifier type.
 void applyOrder(long userId, java.lang.String notifierType, long[] ruleIds)
          Sort notification rules in the specified order
 java.util.Collection<java.lang.Long> findConflictingRules(long userId, java.lang.String notifierType, WatchedBuilds watch)
          Searches for rules which intersect with specified watched builds in the list of user rules for specified notifier type.
 NotificationRule findRuleById(long userId, long ruleId)
          Searches for a rule with specified id among rules of specified user
 java.util.Map<java.lang.Long,java.util.List<NotificationRule>> findRulesByNotificatorType(java.lang.String notifierType)
          Returns map of user id to list of notification rules for specified notifier type.
 java.util.Map<java.lang.Long,java.util.List<NotificationRule>> getAllRulesByNotificatorType(java.lang.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.
 java.util.List<NotificationRule> getAllUserNotificationRules(long userId, java.lang.String notifierType)
          Returns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.
 java.util.List<NotificationRule> getUserNotificationRules(long userId, java.lang.String notifierType)
          Returns user notification rules for specified notifier.
 boolean isRulesWithEventsConfigured(long userId, java.lang.String notifierType)
          Returns true if specified user has notification rules with one or more events configured for specified notifier type.
 void removeRule(long userId, long ruleId)
          Removes rule with specified id from the list of rules of specified user.
 void setUserNotificationRules(long userId, java.lang.String notifierType, java.util.List<NotificationRule> rules)
          Sets user notification rules for specified notifier
 

Method Detail

getUserNotificationRules

@NotNull
java.util.List<NotificationRule> getUserNotificationRules(long userId,
                                                                  @NotNull
                                                                  java.lang.String notifierType)
                                                          throws UserNotFoundException
Returns user notification rules for specified notifier.

Parameters:
userId - id of the user
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).

isRulesWithEventsConfigured

boolean isRulesWithEventsConfigured(long userId,
                                    @NotNull
                                    java.lang.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

setUserNotificationRules

void setUserNotificationRules(long userId,
                              @NotNull
                              java.lang.String notifierType,
                              @NotNull
                              java.util.List<NotificationRule> rules)
                              throws UserNotFoundException
Sets user notification rules for specified notifier

Parameters:
userId - id of the user
notifierType - type of the notifier
rules - rules to save
Throws:
UserNotFoundException - if user with specified id does not exist in current login domain UserModel.findUserById(long).

findRulesByNotificatorType

java.util.Map<java.lang.Long,java.util.List<NotificationRule>> findRulesByNotificatorType(@NotNull
                                                                                          java.lang.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

removeRule

void removeRule(long userId,
                long ruleId)
                throws UserNotFoundException
Removes rule with specified id from the list of rules of specified user.

Parameters:
userId - id of the user
ruleId - id of the rule
Throws:
UserNotFoundException - if user with specified id does not exist in current login domain UserModel.findUserById(long).

applyOrder

void applyOrder(long userId,
                @NotNull
                java.lang.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

addNewRule

long addNewRule(long userId,
                @NotNull
                java.lang.String notifierType,
                @NotNull
                NotificationRule rule)
                throws UserNotFoundException,
                       DuplicateNotificationRuleException
Adds new rule to the rules of specified user for specified notifier type.

Parameters:
userId - id of the user
notifierType - type of the notifier
rule - rule to add
Returns:
id of the newly created rule
Throws:
UserNotFoundException - if user with specified id does not exist in current login domain UserModel.findUserById(long).
DuplicateNotificationRuleException - if similar rule already exists

findConflictingRules

@Nullable
java.util.Collection<java.lang.Long> findConflictingRules(long userId,
                                                                   @NotNull
                                                                   java.lang.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<java.lang.Long> listener)
Registers new user notification rules listener

Parameters:
listener - new listener.

getAllRulesByNotificatorType

@NotNull
java.util.Map<java.lang.Long,java.util.List<NotificationRule>> getAllRulesByNotificatorType(@NotNull
                                                                                                    java.lang.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. User rules are guaranteed to preceed group rules.

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

getAllUserNotificationRules

@NotNull
java.util.List<NotificationRule> getAllUserNotificationRules(long userId,
                                                                     @NotNull
                                                                     java.lang.String notifierType)
                                                             throws UserNotFoundException
Returns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.

Parameters:
userId - id of the user
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