public final class ProjectPermissions
extends java.lang.Object
ProjectKey
using this object as the
input parameter to ProjectKey.getNewOrExisting(DbControl, ProjectPermissions)
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.
ProjectKey
Modifier and Type | Field and Description |
---|---|
private java.util.Map<ProjectData,java.lang.Integer> |
originalPermissions |
private java.util.Map<ProjectData,java.lang.Integer> |
projectPermissions |
Constructor and Description |
---|
ProjectPermissions()
Create a new empty object.
|
ProjectPermissions(ProjectKey projectKey)
Create a new object, and initialise it with the permissions from a
ProjectKey . |
Modifier and Type | Method and Description |
---|---|
void |
addPermissions(Project project,
java.util.Set<Permission> permissions)
Grant permissions to a project, keeping those that have already been set.
|
(package private) java.util.Map<ProjectData,java.lang.Integer> |
getOriginalPermissions()
Get the internal representation of the original permissions.
|
java.util.Set<Permission> |
getOriginalPermissions(Project project)
Get the original permissions for a project if this object was created with the
ProjectPermissions(ProjectKey) constructor. |
java.util.Set<Permission> |
getPermissions(Project project)
Get the permissions for a project.
|
(package private) java.util.Map<ProjectData,java.lang.Integer> |
getProjectPermissions()
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,
java.util.Set<Permission> permissions)
Grant permissions to a project.
|
int |
size()
Get the number of entries.
|
private final java.util.Map<ProjectData,java.lang.Integer> projectPermissions
private final java.util.Map<ProjectData,java.lang.Integer> originalPermissions
public ProjectPermissions()
public ProjectPermissions(ProjectKey projectKey) throws InvalidDataException
ProjectKey
.projectKey
- The project key from which we take the current permissionsInvalidDataException
- If the project key is nullpublic void merge(ProjectKey projectKey)
projectKey
- A project key (if null, this method simply returns)public void setPermissions(Project project, java.util.Set<Permission> permissions) throws PermissionDeniedException, InvalidDataException
Set
or null
to remove all permissions for the project.project
- The Project
permissions
- The permissions to grantPermissionDeniedException
- If the logged in user doesn't have
Permission.USE
permission for the projectInvalidDataException
- If the project is nullPermission
public void addPermissions(Project project, java.util.Set<Permission> permissions) throws PermissionDeniedException, InvalidDataException
project
- The Project
permissions
- The permissions to grantPermissionDeniedException
- If the logged in user doesn't have
Permission.USE
permission for the projectInvalidDataException
- If the project is nullPermission
public java.util.Set<Permission> getPermissions(Project project) throws InvalidDataException
project
- The Project
for which we want to get the permissionSet
containing the granted permissions, or an
empty set if no permissions have been grantedInvalidDataException
- If the project is nullgetOriginalPermissions(Project)
,
Permission
public java.util.Set<Permission> getOriginalPermissions(Project project)
ProjectPermissions(ProjectKey)
constructor.project
- The Project
for which we want to get the permissionSet
containing the original permissions, or an
empty setInvalidDataException
- If the project is nullgetPermissions(Project)
public boolean hasChanged(Project project)
getPermissions(Project)
returns a set with the same permissions getOriginalPermissions(Project)
.project
- The project to checkInvalidDataException
- If the project is nullpublic int size()
final java.util.Map<ProjectData,java.lang.Integer> getProjectPermissions()
final java.util.Map<ProjectData,java.lang.Integer> getOriginalPermissions()