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 voidaddListener(NotificationRulesListener<Long> listener)Registers new user notification rules listenerlongaddNewRule(long userId, String notificatorType, NotificationRule rule)Adds new rule to the rules of specified user for specified notifier type.longaddNewRule(String groupCode, String notificatorType, NotificationRule rule)Adds a new rule to the rules of the specified group for the specified notifier type.voidapplyOrder(long userId, String notificatorType, long[] ruleIds)Sort notification rules in the specified ordervoidapplyOrder(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.NotificationRulefindRuleById(long userId, long ruleId)Searches for a rule with specified id among rules of specified userNotificationRulefindRuleById(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.booleanisRulesWithEventsConfigured(long userId, String notificatorType)Returns true if specified user has notification rules with one or more events configured for specified notifier type.longnextRuleId()voidnotificationRulesChanged(Long holderId, String notificatorType)Notification rules changed for the notification rules holder.voidremoveRule(long userId, long ruleId)Removes rule with specified id from the list of rules of specified user.voidremoveRule(long userId, NotificationRule rule)Removes the rule.voidremoveRule(String groupCode, long ruleId)Removes the rule with specified id from the list of rules associated with specified group.voidremoveRule(String groupCode, NotificationRule rule)Removes the specified rule from the list of rules associated with specified group.voidsetGroupDelegate(GroupNotificationRulesManager groupDelegate)voidsetGroupNotificationRules(String groupCode, String notificatorType, List<NotificationRule> rules)Sets the group notification rules for the specified notifier.voidsetUserDelegate(UserNotificationRulesManager userDelegate)voidsetUserGroupManager(UserGroupManager userGroupManager)voidsetUserModel(UserModelEx userModel)voidsetUserNotificationRules(long userId, String notificatorType, List<NotificationRule> rules)Sets user notification rules for specified notifiervoidupdateNotificationRule(long userId, String notifierType, NotificationRule rule)Sets user notification rules for specified notifiervoidupdateNotificationRule(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:NotificationRulesManagerReturns user notification rules for specified notifier.- Specified by:
getUserNotificationRulesin 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:UserGroupNotificationRulesManagerReturns user group notification rules for the specified notifier.- Specified by:
getGroupNotificationRulesin 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 UserNotFoundExceptionDescription copied from interface:NotificationRulesManagerReturns 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:
isRulesWithEventsConfiguredin 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 UserNotFoundExceptionDescription copied from interface:NotificationRulesManagerSets user notification rules for specified notifier- Specified by:
setUserNotificationRulesin 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 UserGroupExceptionDescription copied from interface:UserGroupNotificationRulesManagerSets the group notification rules for the specified notifier.- Specified by:
setGroupNotificationRulesin 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 UserNotFoundExceptionDescription copied from interface:NotificationRulesManagerSets user notification rules for specified notifier- Specified by:
updateNotificationRulein 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:NotificationRulesManagerReturns map of user id to list of notification rules for specified notifier type.- Specified by:
findRulesByNotificatorTypein 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 UserNotFoundExceptionDescription copied from interface:NotificationRulesManagerRemoves rule with specified id from the list of rules of specified user.- Specified by:
removeRulein 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 UserGroupExceptionDescription copied from interface:NotificationRulesManagerRemoves the rule. ThrowsNotificationRuleChangedExceptionif notification rule with same id was already changed. Does nothing if notification rule doesn't exist.- Specified by:
removeRulein interfaceNotificationRulesManager- Parameters:
userId- id of the userrule- rule to remove- Throws:
UserGroupException
-
removeRule
public void removeRule(@NotNull String groupCode, long ruleId) throws UserGroupExceptionDescription copied from interface:UserGroupNotificationRulesManagerRemoves the rule with specified id from the list of rules associated with specified group.- Specified by:
removeRulein 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 UserGroupExceptionDescription copied from interface:UserGroupNotificationRulesManagerRemoves the specified rule from the list of rules associated with specified group.- Specified by:
removeRulein 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:NotificationRulesManagerSort notification rules in the specified order- Specified by:
applyOrderin 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:UserGroupNotificationRulesManagerSorts the notification rules in the specified order- Specified by:
applyOrderin 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, DuplicateNotificationRuleExceptionDescription copied from interface:NotificationRulesManagerAdds new rule to the rules of specified user for specified notifier type.- Specified by:
addNewRulein 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, DuplicateNotificationRuleExceptionDescription copied from interface:UserGroupNotificationRulesManagerAdds a new rule to the rules of the specified group for the specified notifier type.- Specified by:
addNewRulein 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:NotificationRulesManagerSearches 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:
findConflictingRulesin 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:UserGroupNotificationRulesManagerSearches for the conflicting rules with the specified watched builds and the notifier type.- Specified by:
findConflictingRulesin 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:NotificationRulesManagerSearches for a rule with specified id among rules of specified user- Specified by:
findRuleByIdin 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:UserGroupNotificationRulesManagerSearches for a rule with specified id among rules of the specified group.- Specified by:
findRuleByIdin 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:NotificationRulesListenerNotification rules changed for the notification rules holder.- Specified by:
notificationRulesChangedin interfaceNotificationRulesListener<Long>- Parameters:
holderId- given holder id.notificatorType- notificator type for which rules changed.
-
nextRuleId
public long nextRuleId()
- Specified by:
nextRuleIdin interfaceNotificationRuleIdProvider
-
addListener
public void addListener(@NotNull NotificationRulesListener<Long> listener)Description copied from interface:NotificationRulesManagerRegisters new user notification rules listener- Specified by:
addListenerin interfaceNotificationRulesManager- Parameters:
listener- new listener.
-
getAllRulesByNotificatorType
@NotNull public Map<Long,List<NotificationRule>> getAllRulesByNotificatorType(@NotNull String notifierType)
Description copied from interface:NotificationRulesManagerReturns 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:
getAllRulesByNotificatorTypein 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:NotificationRulesManagerReturns all user notification rules (including the rules of all groups containing the user) for the specified notifier type.- Specified by:
getAllUserNotificationRulesin interfaceNotificationRulesManagernotifierType- 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:NotificationRulesManagerReturns 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:
getAllRulesByNotificatorTypein 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:UserGroupNotificationRulesManagerReturns the list of default notification rules.- Specified by:
getDefaultRulesin interfaceUserGroupNotificationRulesManager- Returns:
- the list of default notification rules
-
-