Class NotificationRulesManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.notification.impl.NotificationRulesManagerImpl
-
- All Implemented Interfaces:
EventListener
,NotificationRuleIdProvider
,NotificationRulesListener<Long>
,NotificationRulesManager
,UserGroupNotificationRulesManager
public class NotificationRulesManagerImpl extends Object implements NotificationRulesManager, UserGroupNotificationRulesManager, NotificationRuleIdProvider, NotificationRulesListener<Long>
- Author:
- Pavel.Sher, Maxim Podkolzine Date: 27.10.2006
-
-
Constructor Summary
Constructors Constructor Description NotificationRulesManagerImpl(NotificationRuleFactory rulesFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(NotificationRulesListener<Long> listener)
Registers new user notification rules listenerlong
addNewRule(long userId, String notificatorType, NotificationRule rule)
Adds new rule to the rules of specified user for specified notifier type.long
addNewRule(String groupCode, String notificatorType, NotificationRule rule)
Adds a new rule to the rules of the specified group for the specified notifier type.void
applyOrder(long userId, String notificatorType, long[] ruleIds)
Sort notification rules in the specified ordervoid
applyOrder(String groupCode, String notificatorType, long[] ruleIds)
Sorts the notification rules in the specified orderCollection<Long>
findConflictingRules(long userId, String notificatorType, WatchedBuilds watch)
Searches for rules which intersect with specified watched builds in the list of user rules for specified notifier type.Collection<Long>
findConflictingRules(String groupCode, String notificatorType, WatchedBuilds watch)
Searches for the conflicting rules with the specified watched builds and the notifier type.NotificationRule
findRuleById(long userId, long ruleId)
Searches for a rule with specified id among rules of specified userNotificationRule
findRuleById(String groupCode, long ruleId)
Searches for a rule with specified id among rules of the specified group.Map<Long,List<NotificationRule>>
findRulesByNotificatorType(String notificatorType)
Returns map of user id to list of notification rules for specified notifier type.Collection<UserGroup>
getAllGroupsSorted()
Map<Long,List<NotificationRule>>
getAllRulesByNotificatorType(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.Map<Long,List<NotificationRule>>
getAllRulesByNotificatorType(String notifierType, 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.List<NotificationRule>
getAllUserNotificationRules(long userId, String notifierType)
Returns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.List<NotificationRule>
getDefaultRules()
Returns the list of default notification rules.List<NotificationRule>
getGroupNotificationRules(String groupCode, String notificatorType)
Returns user group notification rules for the specified notifier.List<NotificationRule>
getUserNotificationRules(long userId, String notificatorType)
Returns user notification rules for specified notifier.boolean
isRulesWithEventsConfigured(long userId, String notificatorType)
Returns true if specified user has notification rules with one or more events configured for specified notifier type.long
nextRuleId()
void
notificationRulesChanged(Long holderId, String notificatorType)
Notification rules changed for the notification rules holder.void
removeRule(long userId, long ruleId)
Removes rule with specified id from the list of rules of specified user.void
removeRule(long userId, NotificationRule rule)
Removes the rule.void
removeRule(String groupCode, long ruleId)
Removes the rule with specified id from the list of rules associated with specified group.void
removeRule(String groupCode, NotificationRule rule)
Removes the specified rule from the list of rules associated with specified group.void
setGroupDelegate(GroupNotificationRulesManager groupDelegate)
void
setGroupNotificationRules(String groupCode, String notificatorType, List<NotificationRule> rules)
Sets the group notification rules for the specified notifier.void
setUserDelegate(UserNotificationRulesManager userDelegate)
void
setUserGroupManager(UserGroupManager userGroupManager)
void
setUserModel(UserModelEx userModel)
void
setUserNotificationRules(long userId, String notificatorType, List<NotificationRule> rules)
Sets user notification rules for specified notifiervoid
updateNotificationRule(long userId, String notifierType, NotificationRule rule)
Sets user notification rules for specified notifiervoid
updateNotificationRule(String groupCode, String notifierType, NotificationRule rule)
-
-
-
Constructor Detail
-
NotificationRulesManagerImpl
public NotificationRulesManagerImpl(@NotNull NotificationRuleFactory rulesFactory)
-
-
Method Detail
-
setUserModel
public void setUserModel(UserModelEx userModel)
-
setUserGroupManager
public void setUserGroupManager(UserGroupManager userGroupManager)
-
setUserDelegate
public void setUserDelegate(UserNotificationRulesManager userDelegate)
-
setGroupDelegate
public void setGroupDelegate(GroupNotificationRulesManager groupDelegate)
-
getUserNotificationRules
@NotNull public List<NotificationRule> getUserNotificationRules(long userId, @NotNull String notificatorType) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Returns user notification rules for specified notifier.- Specified by:
getUserNotificationRules
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- 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)
.
-
getGroupNotificationRules
@NotNull public List<NotificationRule> getGroupNotificationRules(@NotNull String groupCode, @NotNull String notificatorType) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Returns user group notification rules for the specified notifier.- Specified by:
getGroupNotificationRules
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group codenotificatorType
- type of the notifier- Returns:
- list of notification rules
- Throws:
UserGroupException
- if user group with the given code does not exist
-
isRulesWithEventsConfigured
public boolean isRulesWithEventsConfigured(long userId, @NotNull String notificatorType) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
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.- Specified by:
isRulesWithEventsConfigured
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- type of the notifier- Returns:
- returns true if user configured his/her rules to receive notifications
- Throws:
UserNotFoundException
- if user does not exist
-
setUserNotificationRules
public void setUserNotificationRules(long userId, @NotNull String notificatorType, @NotNull List<NotificationRule> rules) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Sets user notification rules for specified notifier- Specified by:
setUserNotificationRules
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- type of the notifierrules
- rules to save- Throws:
UserNotFoundException
- if user with specified id does not exist in current login domainUserModel.findUserById(long)
.
-
setGroupNotificationRules
public void setGroupNotificationRules(@NotNull String groupCode, @NotNull String notificatorType, @NotNull List<NotificationRule> rules) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Sets the group notification rules for the specified notifier.- Specified by:
setGroupNotificationRules
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group codenotificatorType
- type of the notifierrules
- the rules to set- Throws:
UserGroupException
- if user group with the given code does not exist
-
updateNotificationRule
public void updateNotificationRule(long userId, @NotNull String notifierType, @NotNull NotificationRule rule) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Sets user notification rules for specified notifier- Specified by:
updateNotificationRule
in interfaceNotificationRulesManager
- 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)
.
-
updateNotificationRule
public void updateNotificationRule(String groupCode, @NotNull String notifierType, @NotNull NotificationRule rule) throws UserNotFoundException
- Throws:
UserNotFoundException
-
findRulesByNotificatorType
public Map<Long,List<NotificationRule>> findRulesByNotificatorType(@NotNull String notificatorType)
Description copied from interface:NotificationRulesManager
Returns map of user id to list of notification rules for specified notifier type.- Specified by:
findRulesByNotificatorType
in interfaceNotificationRulesManager
- Parameters:
notificatorType
- type of the notifier- Returns:
- map of user id to list of notification rules
-
removeRule
public void removeRule(long userId, long ruleId) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Removes rule with specified id from the list of rules of specified user.- Specified by:
removeRule
in interfaceNotificationRulesManager
- 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
public void removeRule(long userId, @NotNull NotificationRule rule) throws UserGroupException
Description copied from interface:NotificationRulesManager
Removes the rule. ThrowsNotificationRuleChangedException
if notification rule with same id was already changed. Does nothing if notification rule doesn't exist.- Specified by:
removeRule
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the userrule
- rule to remove- Throws:
UserGroupException
-
removeRule
public void removeRule(@NotNull String groupCode, long ruleId) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Removes the rule with specified id from the list of rules associated with specified group.- Specified by:
removeRule
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group coderuleId
- id of the rule- Throws:
UserGroupException
- if user group with the given code does not exist
-
removeRule
public void removeRule(@NotNull String groupCode, @NotNull NotificationRule rule) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Removes the specified rule from the list of rules associated with specified group.- Specified by:
removeRule
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group coderule
- rule to remove- Throws:
UserGroupException
- if user group with the given code does not exist
-
applyOrder
public void applyOrder(long userId, @NotNull String notificatorType, @NotNull long[] ruleIds)
Description copied from interface:NotificationRulesManager
Sort notification rules in the specified order- Specified by:
applyOrder
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- type of the notifierruleIds
- ids of the rules in the required order
-
applyOrder
public void applyOrder(@NotNull String groupCode, @NotNull String notificatorType, @NotNull long[] ruleIds)
Description copied from interface:UserGroupNotificationRulesManager
Sorts the notification rules in the specified order- Specified by:
applyOrder
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group codenotificatorType
- type of the notifierruleIds
- ids of the rules in the required order
-
addNewRule
public long addNewRule(long userId, @NotNull String notificatorType, @NotNull NotificationRule rule) throws UserNotFoundException, DuplicateNotificationRuleException
Description copied from interface:NotificationRulesManager
Adds new rule to the rules of specified user for specified notifier type.- Specified by:
addNewRule
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- 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
-
addNewRule
public long addNewRule(@NotNull String groupCode, @NotNull String notificatorType, @NotNull NotificationRule rule) throws UserGroupException, DuplicateNotificationRuleException
Description copied from interface:UserGroupNotificationRulesManager
Adds a new rule to the rules of the specified group for the specified notifier type.- Specified by:
addNewRule
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group codenotificatorType
- type of the notifierrule
- rule to add- Returns:
- id of a newly created rule
- Throws:
UserGroupException
- if user group with the given code does not existDuplicateNotificationRuleException
- if similar rule already exists
-
findConflictingRules
public Collection<Long> findConflictingRules(long userId, @NotNull String notificatorType, @NotNull WatchedBuilds watch) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
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.- Specified by:
findConflictingRules
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the usernotificatorType
- type of the notifierwatch
- watched builds- Returns:
- list of conflicting rules ids
- Throws:
UserNotFoundException
- if user does not exist
-
findConflictingRules
public Collection<Long> findConflictingRules(@NotNull String groupCode, @NotNull String notificatorType, @NotNull WatchedBuilds watch) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Searches for the conflicting rules with the specified watched builds and the notifier type.- Specified by:
findConflictingRules
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group codenotificatorType
- type of the notifierwatch
- watched builds- Returns:
- list of conflicting rules ids
- Throws:
UserGroupException
- if user group with the given code does not exist
-
findRuleById
public NotificationRule findRuleById(long userId, long ruleId) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Searches for a rule with specified id among rules of specified user- Specified by:
findRuleById
in interfaceNotificationRulesManager
- Parameters:
userId
- id of the userruleId
- id of the rule- Returns:
- a found rule, or null
- Throws:
UserNotFoundException
- if user does not exist
-
findRuleById
public NotificationRule findRuleById(@NotNull String groupCode, long ruleId) throws UserGroupException
Description copied from interface:UserGroupNotificationRulesManager
Searches for a rule with specified id among rules of the specified group.- Specified by:
findRuleById
in interfaceUserGroupNotificationRulesManager
- Parameters:
groupCode
- the group coderuleId
- id of the rule- Returns:
- a found rule, or null
- Throws:
UserGroupException
- if user group with the given code does not exist
-
notificationRulesChanged
public void notificationRulesChanged(@NotNull Long holderId, String notificatorType)
Description copied from interface:NotificationRulesListener
Notification rules changed for the notification rules holder.- Specified by:
notificationRulesChanged
in interfaceNotificationRulesListener<Long>
- Parameters:
holderId
- given holder id.notificatorType
- notificator type for which rules changed.
-
nextRuleId
public long nextRuleId()
- Specified by:
nextRuleId
in interfaceNotificationRuleIdProvider
-
addListener
public void addListener(@NotNull NotificationRulesListener<Long> listener)
Description copied from interface:NotificationRulesManager
Registers new user notification rules listener- Specified by:
addListener
in interfaceNotificationRulesManager
- Parameters:
listener
- new listener.
-
getAllRulesByNotificatorType
@NotNull public Map<Long,List<NotificationRule>> getAllRulesByNotificatorType(@NotNull String notifierType)
Description copied from interface:NotificationRulesManager
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.
- Specified by:
getAllRulesByNotificatorType
in interfaceNotificationRulesManager
- Parameters:
notifierType
- type of the notifier- Returns:
- map of user id to list of notification rules
-
getAllUserNotificationRules
@NotNull public List<NotificationRule> getAllUserNotificationRules(long userId, @NotNull String notifierType) throws UserNotFoundException
Description copied from interface:NotificationRulesManager
Returns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.- Specified by:
getAllUserNotificationRules
in interfaceNotificationRulesManager
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)
.
-
getAllRulesByNotificatorType
public Map<Long,List<NotificationRule>> getAllRulesByNotificatorType(String notifierType, Filter<NotificationRule> notificationRuleFilter)
Description copied from interface:NotificationRulesManager
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.
- Specified by:
getAllRulesByNotificatorType
in interfaceNotificationRulesManager
- Parameters:
notifierType
- type of the notifiernotificationRuleFilter
- notification rule filter- Returns:
- list of notification rules for specified notifier
-
getAllGroupsSorted
public Collection<UserGroup> getAllGroupsSorted()
-
getDefaultRules
@NotNull public List<NotificationRule> getDefaultRules()
Description copied from interface:UserGroupNotificationRulesManager
Returns the list of default notification rules.- Specified by:
getDefaultRules
in interfaceUserGroupNotificationRulesManager
- Returns:
- the list of default notification rules
-
-