Package jetbrains.buildServer.users.impl
Class RolesHolderImpl<T>
- java.lang.Object
-
- jetbrains.buildServer.users.impl.RolesHolderImpl<T>
-
- Type Parameters:
T
- the type of holder id (for instance, Long for User)
- All Implemented Interfaces:
Loggable
,RolesHolder
,RolesHolderEx
,UserRolesInit
public abstract class RolesHolderImpl<T> extends Object implements RolesHolderEx, UserRolesInit
Actual roles holders (like user and group) are expected to delegateRolesHolder
operations, rather than inherit fromRolesHolderImpl
. AnywayRolesHolderImpl
is thread-safe, no surronding locks are needed.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RolesHolderImpl(SecurityContext securityContext, RolesUpdate<T> rolesUpdater, RolesManager rolesManager, RolesConverter rolesConverter, ProjectManagerEx projectManager)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addRole(RoleScope scope, Role role)
Adds role with specified scopeCollection<RoleScope>
computeExistingScopes(Map<RoleScope,Set<String>> rolesMap)
Collection<RolesHolder>
getAllParentHolders()
Returns all parent holders including transitive onesabstract T
getHolderId()
Returns id used to store rolesint
getNumberOfRolesChanges()
abstract Collection<RolesHolder>
getParentHolders()
Returns direct (non transitive) parent holders.Collection<RoleEntry>
getRoles()
Returns roles with their scopesCollection<Role>
getRolesWithScope(RoleScope scope)
Returns all roles with specified scope.Collection<RoleScope>
getScopes()
Returns all scopes with assigned rolesMap<RoleScope,Collection<Role>>
getUnfilteredRoles()
Collection<RoleScope>
getUnfilteredScopes()
boolean
isSystemAdministratorRoleGranted()
Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders.boolean
isSystemAdministratorRoleGrantedDirectly()
Returns true if this roles holder contains system administrator role granted directly.boolean
isSystemAdministratorRoleInherited()
Returns true if one of the parents (transitively) of this roles holder contains system administrator role.abstract Map<RoleScope,Set<Role>>
loadRoles()
void
removeRole(Role role)
Removes specified role.void
removeRole(RoleScope scope, Role role)
Removes role with specified scopevoid
removeRoles(RoleScope scope)
Removes all of the roles having the specified scope.void
resetRoles()
Causes roles reloading from the database.
-
-
-
Constructor Detail
-
RolesHolderImpl
protected RolesHolderImpl(@NotNull SecurityContext securityContext, @NotNull RolesUpdate<T> rolesUpdater, @NotNull RolesManager rolesManager, @NotNull RolesConverter rolesConverter, @NotNull ProjectManagerEx projectManager)
-
-
Method Detail
-
getRolesWithScope
@NotNull public Collection<Role> getRolesWithScope(@NotNull RoleScope scope)
Description copied from interface:RolesHolder
Returns all roles with specified scope.- Specified by:
getRolesWithScope
in interfaceRolesHolder
- Parameters:
scope
- roles scope- Returns:
- all roles with specified scope.
-
getScopes
public Collection<RoleScope> getScopes()
Description copied from interface:RolesHolder
Returns all scopes with assigned roles- Specified by:
getScopes
in interfaceRolesHolder
- Returns:
- all scopes with assigned roles
-
getUnfilteredScopes
@NotNull public Collection<RoleScope> getUnfilteredScopes()
- Specified by:
getUnfilteredScopes
in interfaceRolesHolderEx
- Returns:
- unfiltered role scopes for this roles holder, unfiltered scopes include scopes for projects current user from security context does not have access too
-
computeExistingScopes
@NotNull public Collection<RoleScope> computeExistingScopes(@NotNull Map<RoleScope,Set<String>> rolesMap)
-
getUnfilteredRoles
@NotNull public Map<RoleScope,Collection<Role>> getUnfilteredRoles()
- Specified by:
getUnfilteredRoles
in interfaceRolesHolderEx
- Returns:
- unfiltered map of role for this roles holder, unfiltered map include roles for projects current user from security context does not have access too
-
getRoles
@NotNull public Collection<RoleEntry> getRoles()
Description copied from interface:RolesHolder
Returns roles with their scopes- Specified by:
getRoles
in interfaceRolesHolder
- Returns:
- roles with their scopes
-
addRole
public void addRole(@NotNull RoleScope scope, @NotNull Role role)
Description copied from interface:RolesHolder
Adds role with specified scope- Specified by:
addRole
in interfaceRolesHolder
- Parameters:
scope
- scope of the rolerole
- role
-
removeRole
public void removeRole(@NotNull RoleScope scope, @NotNull Role role)
Description copied from interface:RolesHolder
Removes role with specified scope- Specified by:
removeRole
in interfaceRolesHolder
- Parameters:
scope
- scope of the rolerole
- role
-
removeRole
public void removeRole(@NotNull Role role)
Description copied from interface:RolesHolder
Removes specified role. If the role is associated with several scopes all of these roles will be removed.- Specified by:
removeRole
in interfaceRolesHolder
- Parameters:
role
- role to remove
-
removeRoles
public void removeRoles(@NotNull RoleScope scope)
Description copied from interface:RolesHolder
Removes all of the roles having the specified scope.- Specified by:
removeRoles
in interfaceRolesHolder
- Parameters:
scope
- scope of the role
-
isSystemAdministratorRoleGranted
public boolean isSystemAdministratorRoleGranted()
Description copied from interface:RolesHolder
Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders. Same as:isSystemAdministratorRoleGrantedDirectly() || isSystemAdministratorRoleInherited()
- Specified by:
isSystemAdministratorRoleGranted
in interfaceRolesHolder
- Returns:
- see above.
-
isSystemAdministratorRoleGrantedDirectly
public boolean isSystemAdministratorRoleGrantedDirectly()
Description copied from interface:RolesHolder
Returns true if this roles holder contains system administrator role granted directly.- Specified by:
isSystemAdministratorRoleGrantedDirectly
in interfaceRolesHolder
- Returns:
- see above.
-
isSystemAdministratorRoleInherited
public boolean isSystemAdministratorRoleInherited()
Description copied from interface:RolesHolder
Returns true if one of the parents (transitively) of this roles holder contains system administrator role.- Specified by:
isSystemAdministratorRoleInherited
in interfaceRolesHolder
- Returns:
- see above
-
resetRoles
public void resetRoles()
Description copied from interface:UserRolesInit
Causes roles reloading from the database.- Specified by:
resetRoles
in interfaceUserRolesInit
-
getHolderId
public abstract T getHolderId()
Returns id used to store roles- Returns:
- roles holder id
-
getParentHolders
@NotNull public abstract Collection<RolesHolder> getParentHolders()
Description copied from interface:RolesHolder
Returns direct (non transitive) parent holders.- Specified by:
getParentHolders
in interfaceRolesHolder
- Returns:
- parent holders
-
getAllParentHolders
@NotNull public Collection<RolesHolder> getAllParentHolders()
Description copied from interface:RolesHolder
Returns all parent holders including transitive ones- Specified by:
getAllParentHolders
in interfaceRolesHolder
- Returns:
- all parent holders
-
getNumberOfRolesChanges
public int getNumberOfRolesChanges()
-
-