Package net.sf.basedb.core
Class UserPermissions
java.lang.Object
net.sf.basedb.core.UserPermissions
This class is used to specify permissions to share an item to
users. It is a three-step procedure:
- Fill this object with permissions for specific users
- Create a new
ItemKey
using this object as one of the input parameters toItemKey.getNewOrExisting(DbControl, UserPermissions, GroupPermissions)
- Assign the item key to the item:
Shareable.setItemKey(ItemKey)
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2010-06-22 14:51:41 +0200 (ti, 22 jun 2010) $
-
Field Summary
Modifier and TypeFieldDescription -
Constructor Summary
ConstructorDescriptionCreate a new empty object.UserPermissions
(ItemKey itemKey) Create a new object, and initialise it with the permissions from aItemKey
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPermissions
(User user, Set<Permission> permissions) Grant permissions to a user, keeping those that have already been set.Get the internal representation of the original permissions.getOriginalPermissions
(User user) Get the original permissions for a user if this object was created with theUserPermissions(ItemKey)
constructor.getPermissions
(User user) Get the permissions for a user.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 the permissions for all users from the given item key with the permissions in this object.void
setPermissions
(User user, Set<Permission> permissions) Grant permissions to a user.int
size()
Get the number of entries.
-
Field Details
-
userPermissions
-
originalPermissions
-
-
Constructor Details
-
UserPermissions
public UserPermissions()Create a new empty object. -
UserPermissions
Create a new object, and initialise it with the permissions from aItemKey
.- Parameters:
itemKey
- The item key from which we take the current permissions- Throws:
InvalidDataException
- If the item key is null
-
-
Method Details
-
merge
Merge the permissions for all users from the given item key with the permissions in this object. If the item key contains permissions for a user that already has permissions in this object the permissions are combined (added) to create a new permission.- Parameters:
itemKey
- An item key (if null, this method simply returns)- Since:
- 2.16
-
setPermissions
Grant permissions to a user. Use an emptySet
or null to remove all permissions for the user.- Parameters:
user
- TheUser
permissions
- The permissions to grant- Throws:
InvalidDataException
- If the user is null- See Also:
-
addPermissions
Grant permissions to a user, keeping those that have already been set.- Parameters:
user
- TheUser
permissions
- The permissions to grant- Throws:
InvalidDataException
- If the user is null- See Also:
-
getPermissions
Get the permissions for a user.- Parameters:
user
- TheUser
for which we want to get the permission- Returns:
- An
Set
containing the granted permissions, or an empty set if no permissions have been granted - Throws:
InvalidDataException
- If the user is null- See Also:
-
getOriginalPermissions
Get the original permissions for a user if this object was created with theUserPermissions(ItemKey)
constructor.- Parameters:
user
- TheUser
for which we want to get the permission- Returns:
- An
Set
containing the original permissions, or an empty set - Throws:
InvalidDataException
- If the user is null- Since:
- 2.6
- See Also:
-
hasChanged
Check if the current permissions for the user has been changed from the original permissions. This method will return false if thegetPermissions(User)
returns a set with the same permissionsgetOriginalPermissions(User)
.- Parameters:
user
- The user to check- Returns:
- TRUE if the permissions have changed, FALSE otherwise
- Throws:
InvalidDataException
- If the user is null- Since:
- 2.6
-
size
public int size()Get the number of entries. -
getUserPermissions
Get the internal representation of the permissions. -
getOriginalPermissions
Get the internal representation of the original permissions.- Since:
- 2.6
-