Interface NotificationRulesManager
-
public interface NotificationRulesManager
Manages user notification rules.- See Also:
UserGroupNotificationRulesManager
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addListener(NotificationRulesListener<java.lang.Long> listener)
Registers new user notification rules listenerlong
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 orderjava.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 userjava.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.Map<java.lang.Long,java.util.List<NotificationRule>>
getAllRulesByNotificatorType(java.lang.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.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
removeRule(long holderId, NotificationRule rule)
Removes the rule.void
setUserNotificationRules(long userId, java.lang.String notifierType, java.util.List<NotificationRule> rules)
Sets user notification rules for specified notifiervoid
updateNotificationRule(long userId, java.lang.String notifierType, NotificationRule rule)
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 usernotifierType
- 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 domainUserModel.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 usernotifierType
- 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 usernotifierType
- type of the notifierrules
- rules to save- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.findUserById(long)
.
-
updateNotificationRule
void updateNotificationRule(long userId, @NotNull java.lang.String notifierType, @NotNull NotificationRule rule) throws UserNotFoundException
Sets user notification rules for specified notifier- Parameters:
userId
- id of the usernotifierType
- type of the notifierrule
- rule to update- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.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 userruleId
- id of the rule- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.findUserById(long)
.
-
removeRule
void removeRule(long holderId, @NotNull NotificationRule rule) throws UserNotFoundException
Removes the rule. ThrowsNotificationRuleChangedException
if notification rule with same id was already changed. Does nothing if notification rule doesn't exist.- Parameters:
holderId
- id of the userrule
- rule to remove- Throws:
UserNotFoundException
-
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 usernotifierType
- type of the notifierruleIds
- 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 usernotifierType
- type of the notifierrule
- rule to add- Returns:
- id of the newly created rule
- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.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 usernotifierType
- type of the notifierwatch
- 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 userruleId
- 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. 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 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:
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 domainUserModel.findUserById(long)
.- Since:
- 4.5
-
getAllRulesByNotificatorType
java.util.Map<java.lang.Long,java.util.List<NotificationRule>> getAllRulesByNotificatorType(java.lang.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 notifiernotificationRuleFilter
- notification rule filter- Returns:
- list of notification rules for specified notifier
- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.findUserById(long)
.- Since:
- 2018.2
-
-