Class UserGroupManagerImpl
- java.lang.Object
-
- jetbrains.buildServer.groups.impl.UserGroupManagerImpl
-
- All Implemented Interfaces:
UserGroupManager
public class UserGroupManagerImpl extends Object implements UserGroupManager
UserGroupManager implementation. Thread-safe.Note: to avoid dead-locks don't use nested locking (see
MANAGER_LOCK
andUserGroupImpl.USERGROUP_LOCK
). If you have to, please readUserGroupImpl
comments.The best practise would be not to call
UserGroupImpl
locking methods at all. Currently it is justsetName
fromrenameUserGroup(String, String)
method.- Author:
- Maxim Podkolzine (maxim.podkolzine@jetbrains.com)
-
-
Field Summary
Fields Modifier and Type Field Description static String
ALL_USERS_GROUP_DSCR
static String
ALL_USERS_GROUP_KEY
static String
ALL_USERS_GROUP_NAME
-
Fields inherited from interface jetbrains.buildServer.groups.UserGroupManager
MAX_GROUP_KEY_LENGTH
-
-
Constructor Summary
Constructors Constructor Description UserGroupManagerImpl(EventDispatcher<ProjectsImportListener> projectImportEventDispatcher, EventDispatcher<UserGroupListener> eventDispatcher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addUserGroupListener(UserGroupListener listener)
Adds the specified listener to the manager's list.void
clearCaches()
SUserGroup
createUserGroup(String key, String name, String description)
Creates a new user group.void
deleteUserGroup(SUserGroup group)
Deletes a user group.SUserGroup
findUserGroupByKey(String key)
Given a group key method finds the corresponding user group.SUserGroup
findUserGroupByName(String name)
Given a group name method finds the corresponding user group.Set<SUserGroup>
findUserGroupsByPropertyValue(PropertyKey propertyKey, String propertyValue, boolean caseSensitive)
Returns set of the user groups having specified property.List<UserGroup>
getAllHostGroupsOf(User user)
Returns topologically ordered list of all groups containing specified user, directly or through intermediate subgroups.SUserGroup
getAllUsersGroup()
Returns the all-users group.List<UserGroup>
getHostGroupsOf(User user)
Returns the list of groups that host specified user (directly).Collection<SUserGroup>
getRootUserGroups()
Returns the collection of root user groups, i.e.Collection<SUserGroup>
getUserGroups()
Returns the collection of all user groups.boolean
isAllUsersGroup(SUserGroup group)
Returns true, if the specified group is the all-users group.void
notifyCreated(UserGroup created)
void
notifyDeleted(UserGroup deleted)
void
notifyModified(UserGroup deleted)
void
notifyUserAdded(UserGroup userGroup, SUser user)
void
notifyUserRemoved(UserGroup userGroup, SUser user)
void
removeUserGroupListener(UserGroupListener listener)
Removes the listener from the manager's list.void
renameUserGroup(String key, String name)
Renames a user group.void
setAuditLogFactory(AuditLogFactory auditLogFactory)
void
setFactory(UserGroupFactory factory)
void
setNodeEvents(UserGroupsCrossNodesEvents nodeEvents)
void
setUpdater(UserGroupUpdater updater)
-
-
-
Field Detail
-
ALL_USERS_GROUP_KEY
public static final String ALL_USERS_GROUP_KEY
- See Also:
- Constant Field Values
-
ALL_USERS_GROUP_NAME
public static final String ALL_USERS_GROUP_NAME
- See Also:
- Constant Field Values
-
ALL_USERS_GROUP_DSCR
public static final String ALL_USERS_GROUP_DSCR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UserGroupManagerImpl
public UserGroupManagerImpl(@NotNull EventDispatcher<ProjectsImportListener> projectImportEventDispatcher, @NotNull EventDispatcher<UserGroupListener> eventDispatcher)
-
-
Method Detail
-
setNodeEvents
public void setNodeEvents(@NotNull UserGroupsCrossNodesEvents nodeEvents)
-
setFactory
public void setFactory(@NotNull UserGroupFactory factory)
-
setUpdater
public void setUpdater(@NotNull UserGroupUpdater updater)
-
setAuditLogFactory
public void setAuditLogFactory(@NotNull AuditLogFactory auditLogFactory)
-
createUserGroup
@NotNull public SUserGroup createUserGroup(@NotNull String key, @NotNull String name, @NotNull String description) throws UserGroupException
Description copied from interface:UserGroupManager
Creates a new user group.The
key
is specified by user, but must be unique among all user groups. An attempt to create a user group with existing key results in exception.The
name
must be unique too. Similarly, in case of duplication an exception is thrown.- Specified by:
createUserGroup
in interfaceUserGroupManager
- Parameters:
key
- user group keyname
- user group namedescription
- user group description- Returns:
- a newly created user group
- Throws:
UserGroupException
- if specified key already exists
-
deleteUserGroup
public void deleteUserGroup(@NotNull SUserGroup group)
Description copied from interface:UserGroupManager
Deletes a user group.Note: the
group
would be deleted from all parent groups automatically, and all subgroups will be reattached to thegroup
's parents.group
's direct users aren't moved anywhere.- Specified by:
deleteUserGroup
in interfaceUserGroupManager
- Parameters:
group
- a group to delete
-
renameUserGroup
public void renameUserGroup(@NotNull String key, @NotNull String name) throws UserGroupException
Description copied from interface:UserGroupManager
Renames a user group.- Specified by:
renameUserGroup
in interfaceUserGroupManager
- Parameters:
key
- the group keyname
- new group name- Throws:
UserGroupException
- if the group is not found, or cannot be renamed- See Also:
SUserGroup.setName(String)
-
getUserGroups
@NotNull public Collection<SUserGroup> getUserGroups()
Description copied from interface:UserGroupManager
Returns the collection of all user groups.- Specified by:
getUserGroups
in interfaceUserGroupManager
- Returns:
- collection of user groups
- See Also:
UserGroupManager.getRootUserGroups()
-
getRootUserGroups
@NotNull public Collection<SUserGroup> getRootUserGroups()
Description copied from interface:UserGroupManager
Returns the collection of root user groups, i.e. the ones that are not included in any other group.- Specified by:
getRootUserGroups
in interfaceUserGroupManager
- Returns:
- collection of root user groups
- See Also:
UserGroupManager.getUserGroups()
-
getHostGroupsOf
@NotNull public List<UserGroup> getHostGroupsOf(@NotNull User user)
Description copied from interface:UserGroupManager
Returns the list of groups that host specified user (directly).- Specified by:
getHostGroupsOf
in interfaceUserGroupManager
- Parameters:
user
- the user- Returns:
- list of host groups
-
getAllHostGroupsOf
@NotNull public List<UserGroup> getAllHostGroupsOf(@NotNull User user)
Description copied from interface:UserGroupManager
Returns topologically ordered list of all groups containing specified user, directly or through intermediate subgroups.- Specified by:
getAllHostGroupsOf
in interfaceUserGroupManager
- Parameters:
user
- the user- Returns:
- list of all groups containing the user
-
findUserGroupByKey
@Nullable public SUserGroup findUserGroupByKey(@NotNull String key)
Description copied from interface:UserGroupManager
Given a group key method finds the corresponding user group.- Specified by:
findUserGroupByKey
in interfaceUserGroupManager
- Parameters:
key
- the user group key- Returns:
- user group, or null
-
findUserGroupByName
public SUserGroup findUserGroupByName(@NotNull String name)
Description copied from interface:UserGroupManager
Given a group name method finds the corresponding user group.- Specified by:
findUserGroupByName
in interfaceUserGroupManager
- Parameters:
name
- the user group name- Returns:
- user group, or null
-
findUserGroupsByPropertyValue
@NotNull public Set<SUserGroup> findUserGroupsByPropertyValue(@NotNull PropertyKey propertyKey, @Nullable String propertyValue, boolean caseSensitive)
Description copied from interface:UserGroupManager
Returns set of the user groups having specified property.- Specified by:
findUserGroupsByPropertyValue
in interfaceUserGroupManager
- Parameters:
propertyKey
- property keypropertyValue
- property valuecaseSensitive
- whether to perform case sensitive search- Returns:
- see above
-
addUserGroupListener
public void addUserGroupListener(@NotNull UserGroupListener listener)
Description copied from interface:UserGroupManager
Adds the specified listener to the manager's list.- Specified by:
addUserGroupListener
in interfaceUserGroupManager
- Parameters:
listener
- the listener to add
-
removeUserGroupListener
public void removeUserGroupListener(@NotNull UserGroupListener listener)
Description copied from interface:UserGroupManager
Removes the listener from the manager's list.- Specified by:
removeUserGroupListener
in interfaceUserGroupManager
- Parameters:
listener
- the listener to remove
-
getAllUsersGroup
@NotNull public SUserGroup getAllUsersGroup()
Description copied from interface:UserGroupManager
Returns the all-users group.- Specified by:
getAllUsersGroup
in interfaceUserGroupManager
- Returns:
- the all-users group
-
isAllUsersGroup
public boolean isAllUsersGroup(@NotNull SUserGroup group)
Description copied from interface:UserGroupManager
Returns true, if the specified group is the all-users group.- Specified by:
isAllUsersGroup
in interfaceUserGroupManager
- Parameters:
group
- the group to check- Returns:
- true if the specified group is the all-users group, false otherwise
-
clearCaches
public void clearCaches()
-
notifyCreated
public void notifyCreated(UserGroup created)
-
notifyDeleted
public void notifyDeleted(UserGroup deleted)
-
notifyModified
public void notifyModified(UserGroup deleted)
-
-