Package net.sf.basedb.core
Class GroupPermissions
- java.lang.Object
-
- net.sf.basedb.core.GroupPermissions
-
public class GroupPermissions extends Object
This class is used to specify permissions to share an item to groups. It is a three-step procedure:- Fill this object with permissions for specific groups
- Create a new
ItemKey
using this object as one of the input parameters toItemKey.getNewOrExisting(DbControl, UserPermissions, GroupPermissions)
- Assign the key to the item:
Shareable.setItemKey(ItemKey)
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
ItemKey
,UserPermissions
- Last modified
- $Date: 2010-06-22 14:51:41 +0200 (ti, 22 jun 2010) $
-
-
Field Summary
Fields Modifier and Type Field Description private Map<GroupData,Integer>
groupPermissions
private Map<GroupData,Integer>
originalPermissions
-
Constructor Summary
Constructors Constructor Description GroupPermissions()
Create a new empty object.GroupPermissions(ItemKey itemKey)
Create a new object, and initialise it with the permissions from aItemKey
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPermissions(Group group, Set<Permission> permissions)
Grant permissions to a group, keeping those that have already been set.(package private) Map<GroupData,Integer>
getGroupPermissions()
Get the internal representation of the permissions.(package private) Map<GroupData,Integer>
getOriginalPermissions()
Get the internal representation of the original permissions.Set<Permission>
getOriginalPermissions(Group group)
Get the original permissions for a group if this object was created with theGroupPermissions(ItemKey)
constructor.Set<Permission>
getPermissions(Group group)
Get the permissions for a group.boolean
hasChanged(Group group)
Check if the current permissions for the group has been changed from the original permissions.void
merge(ItemKey itemKey)
Merge the permissions for all groups from the given item key with the permissions in this object.void
setPermissions(Group group, Set<Permission> permissions)
Grant permissions to a group.int
size()
Get the number of entries.
-
-
-
Constructor Detail
-
GroupPermissions
public GroupPermissions()
Create a new empty object.
-
GroupPermissions
public GroupPermissions(ItemKey itemKey) throws InvalidDataException
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 Detail
-
merge
public void merge(ItemKey itemKey)
Merge the permissions for all groups from the given item key with the permissions in this object. If the item key contains permissions for a group 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
public void setPermissions(Group group, Set<Permission> permissions) throws InvalidDataException
Grant permissions to a group. Use an emptySet
or null to remove all permissions for the group.- Parameters:
group
- TheGroup
permissions
- The permissions to grant- Throws:
InvalidDataException
- If the group is null- See Also:
Permission
-
addPermissions
public void addPermissions(Group group, Set<Permission> permissions) throws InvalidDataException
Grant permissions to a group, keeping those that have already been set.- Parameters:
group
- TheGroup
permissions
- The permissions to grant- Throws:
InvalidDataException
- If the user is null- See Also:
Permission
-
getPermissions
public Set<Permission> getPermissions(Group group) throws InvalidDataException
Get the permissions for a group.- Parameters:
group
- TheGroup
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 group is null- See Also:
getOriginalPermissions(Group)
,Permission
-
getOriginalPermissions
public Set<Permission> getOriginalPermissions(Group group)
Get the original permissions for a group if this object was created with theGroupPermissions(ItemKey)
constructor.- Parameters:
group
- TheGroup
for which we want to get the permission- Returns:
- An
Set
containing the original permissions, or an empty set - Throws:
InvalidDataException
- If the group is null- Since:
- 2.6
- See Also:
getPermissions(Group)
-
hasChanged
public boolean hasChanged(Group group)
Check if the current permissions for the group has been changed from the original permissions. This method will return false if thegetPermissions(Group)
returns a set with the same permissionsgetOriginalPermissions(Group)
.- Parameters:
group
- The group to check- Returns:
- TRUE if the permissions have changed, FALSE otherwise
- Throws:
InvalidDataException
- If the group is null- Since:
- 2.6
-
size
public int size()
Get the number of entries.
-
getGroupPermissions
final Map<GroupData,Integer> getGroupPermissions()
Get the internal representation of the permissions.
-
-