Package net.sf.basedb.core
Class ProjectPermissions
java.lang.Object
net.sf.basedb.core.ProjectPermissions
This class is used to specify permissions to share an item to
projects. It is a three-step procedure:
- Fill this object with permissions for specific projects
- Create a new
ProjectKey
using this object as the input parameter toProjectKey.getNewOrExisting(DbControl, ProjectPermissions)
- Assign the project key to the item:
Shareable.setProjectKey(ProjectKey)
NOTE! As of BASE 2.6 this class is final because of a security issue. Existing code that has subclassed this class will no longer work. There is no workaround.
- 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 TypeFieldDescriptionprivate final Map<ProjectData,
Integer> private final Map<ProjectData,
Integer> -
Constructor Summary
ConstructorDescriptionCreate a new empty object.ProjectPermissions
(ProjectKey projectKey) Create a new object, and initialise it with the permissions from aProjectKey
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPermissions
(Project project, Set<Permission> permissions) Grant permissions to a project, keeping those that have already been set.(package private) final Map<ProjectData,
Integer> Get the internal representation of the original permissions.getOriginalPermissions
(Project project) Get the original permissions for a project if this object was created with theProjectPermissions(ProjectKey)
constructor.getPermissions
(Project project) Get the permissions for a project.(package private) final Map<ProjectData,
Integer> Get the internal representation of the permissions.boolean
hasChanged
(Project project) Check if the current permissions for the project has been changed from the original permissions.void
merge
(ProjectKey projectKey) Merge the permissions for all projects from the given project key with the permissions in this object.void
setPermissions
(Project project, Set<Permission> permissions) Grant permissions to a project.int
size()
Get the number of entries.
-
Field Details
-
projectPermissions
-
originalPermissions
-
-
Constructor Details
-
ProjectPermissions
public ProjectPermissions()Create a new empty object. -
ProjectPermissions
Create a new object, and initialise it with the permissions from aProjectKey
.- Parameters:
projectKey
- The project key from which we take the current permissions- Throws:
InvalidDataException
- If the project key is null
-
-
Method Details
-
merge
Merge the permissions for all projects from the given project key with the permissions in this object. If the project key contains permissions for a project that already has permissions in this object the permissions are combined (added) to create a new permission.- Parameters:
projectKey
- A project key (if null, this method simply returns)- Since:
- 2.16
-
setPermissions
public void setPermissions(Project project, Set<Permission> permissions) throws PermissionDeniedException, InvalidDataException Grant permissions to a project. Use an emptySet
or null to remove all permissions for the project.- Parameters:
project
- TheProject
permissions
- The permissions to grant- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.USE
permission for the projectInvalidDataException
- If the project is null- See Also:
-
addPermissions
public void addPermissions(Project project, Set<Permission> permissions) throws PermissionDeniedException, InvalidDataException Grant permissions to a project, keeping those that have already been set.- Parameters:
project
- TheProject
permissions
- The permissions to grant- Throws:
PermissionDeniedException
- If the logged in user doesn't havePermission.USE
permission for the projectInvalidDataException
- If the project is null- See Also:
-
getPermissions
Get the permissions for a project.- Parameters:
project
- TheProject
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 project is null- See Also:
-
getOriginalPermissions
Get the original permissions for a project if this object was created with theProjectPermissions(ProjectKey)
constructor.- Parameters:
project
- TheProject
for which we want to get the permission- Returns:
- An
Set
containing the original permissions, or an empty set - Throws:
InvalidDataException
- If the project is null- Since:
- 2.6
- See Also:
-
hasChanged
Check if the current permissions for the project has been changed from the original permissions. This method will return false if thegetPermissions(Project)
returns a set with the same permissionsgetOriginalPermissions(Project)
.- Parameters:
project
- The project to check- Returns:
- TRUE if the permissions have changed, FALSE otherwise
- Throws:
InvalidDataException
- If the project is null- Since:
- 2.6
-
size
public int size()Get the number of entries. -
getProjectPermissions
Get the internal representation of the permissions. -
getOriginalPermissions
Get the internal representation of the original permissions.- Since:
- 2.6
-