Class ProjectPermissions

java.lang.Object
net.sf.basedb.core.ProjectPermissions

public final class ProjectPermissions extends Object
This class is used to specify permissions to share an item to projects. It is a three-step procedure: Don't forget to commit the transaction.

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 Details

  • Constructor Details

    • ProjectPermissions

      public ProjectPermissions()
      Create a new empty object.
    • ProjectPermissions

      public ProjectPermissions(ProjectKey projectKey) throws InvalidDataException
      Create a new object, and initialise it with the permissions from a ProjectKey.
      Parameters:
      projectKey - The project key from which we take the current permissions
      Throws:
      InvalidDataException - If the project key is null
  • Method Details

    • merge

      public void merge(ProjectKey projectKey)
      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 empty Set or null to remove all permissions for the project.
      Parameters:
      project - The Project
      permissions - The permissions to grant
      Throws:
      PermissionDeniedException - If the logged in user doesn't have Permission.USE permission for the project
      InvalidDataException - 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 - The Project
      permissions - The permissions to grant
      Throws:
      PermissionDeniedException - If the logged in user doesn't have Permission.USE permission for the project
      InvalidDataException - If the project is null
      See Also:
    • getPermissions

      public Set<Permission> getPermissions(Project project) throws InvalidDataException
      Get the permissions for a project.
      Parameters:
      project - The Project 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

      public Set<Permission> getOriginalPermissions(Project project)
      Get the original permissions for a project if this object was created with the ProjectPermissions(ProjectKey) constructor.
      Parameters:
      project - The Project 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

      public boolean hasChanged(Project project)
      Check if the current permissions for the project has been changed from the original permissions. This method will return false if the getPermissions(Project) returns a set with the same permissions getOriginalPermissions(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

      final Map<ProjectData,Integer> getProjectPermissions()
      Get the internal representation of the permissions.
    • getOriginalPermissions

      final Map<ProjectData,Integer> getOriginalPermissions()
      Get the internal representation of the original permissions.
      Since:
      2.6