public class UserPermissions
extends java.lang.Object
ItemKey
using this object as one of the
input parameters to ItemKey.getNewOrExisting(DbControl, UserPermissions, GroupPermissions)
Shareable.setItemKey(ItemKey)
ItemKey
,
GroupPermissions
,
ProjectPermissions
Modifier and Type | Field and Description |
---|---|
private java.util.Map<UserData,java.lang.Integer> |
originalPermissions |
private java.util.Map<UserData,java.lang.Integer> |
userPermissions |
Constructor and Description |
---|
UserPermissions()
Create a new empty object.
|
UserPermissions(ItemKey itemKey)
Create a new object, and initialise it with the permissions from a
ItemKey . |
Modifier and Type | Method and Description |
---|---|
void |
addPermissions(User user,
java.util.Set<Permission> permissions)
Grant permissions to a user, keeping those that have already been set.
|
(package private) java.util.Map<UserData,java.lang.Integer> |
getOriginalPermissions()
Get the internal representation of the original permissions.
|
java.util.Set<Permission> |
getOriginalPermissions(User user)
Get the original permissions for a user if this object was created with the
UserPermissions(ItemKey) constructor. |
java.util.Set<Permission> |
getPermissions(User user)
Get the permissions for a user.
|
(package private) java.util.Map<UserData,java.lang.Integer> |
getUserPermissions()
Get the internal representation of the permissions.
|
boolean |
hasChanged(User user)
Check if the current permissions for the user has been changed from the original
permissions.
|
void |
merge(ItemKey itemKey)
Merge the permissions for all users from the given item key with the permissions
in this object.
|
void |
setPermissions(User user,
java.util.Set<Permission> permissions)
Grant permissions to a user.
|
int |
size()
Get the number of entries.
|
private final java.util.Map<UserData,java.lang.Integer> userPermissions
private final java.util.Map<UserData,java.lang.Integer> originalPermissions
public UserPermissions()
public UserPermissions(ItemKey itemKey) throws InvalidDataException
ItemKey
.itemKey
- The item key from which we take the current permissionsInvalidDataException
- If the item key is nullpublic void merge(ItemKey itemKey)
itemKey
- An item key (if null, this method simply returns)public void setPermissions(User user, java.util.Set<Permission> permissions) throws InvalidDataException
Set
or null
to remove all permissions for the user.user
- The User
permissions
- The permissions to grantInvalidDataException
- If the user is nullPermission
public void addPermissions(User user, java.util.Set<Permission> permissions) throws InvalidDataException
user
- The User
permissions
- The permissions to grantInvalidDataException
- If the user is nullPermission
public java.util.Set<Permission> getPermissions(User user) throws InvalidDataException
user
- The User
for which we want to get the permissionSet
containing the granted permissions, or an
empty set if no permissions have been grantedInvalidDataException
- If the user is nullgetOriginalPermissions(User)
,
Permission
public java.util.Set<Permission> getOriginalPermissions(User user)
UserPermissions(ItemKey)
constructor.user
- The User
for which we want to get the permissionSet
containing the original permissions, or an
empty setInvalidDataException
- If the user is nullgetPermissions(User)
public boolean hasChanged(User user)
getPermissions(User)
returns a set with the same permissions getOriginalPermissions(User)
.user
- The user to checkInvalidDataException
- If the user is nullpublic int size()
final java.util.Map<UserData,java.lang.Integer> getUserPermissions()
final java.util.Map<UserData,java.lang.Integer> getOriginalPermissions()