2.17.2: 2011-06-17

net.sf.basedb.core
Enum Permission

java.lang.Object
  extended by java.lang.Enum<Permission>
      extended by net.sf.basedb.core.Permission
All Implemented Interfaces:
Serializable, Comparable<Permission>

public enum Permission
extends Enum<Permission>

This enumeration defined constants for permissions.

Version:
2.0
Author:
Nicklas
Developer info
Permissions are stored in the database as integers, which means that a given set of permissions must be combined before they are saved. We use the grantValue for this. This value is constructed in such a way that some permissions implicitly activates other permissions as follows: The denyValue is only used by the BasicItem.initPermissions(int, int) method when a subclass needs to deny a permission. This value is constructed in a similiar way:
Last modified
$Date: 2009-04-06 14:52:39 +0200 (Mon, 06 Apr 2009) $

Enum Constant Summary
ACT_AS_ANOTHER_USER
          This permission allows a user act as another user using the SessionControl.impersonateLogin(int, String) method.
CREATE
          This permission allows a user create new items.
DELETE
          This permission allows a user delete an item.
DENIED
          This permission denies a user access to an item.
READ
          This permission allows a user read information about an item.
RESTRICTED_WRITE
          This permission allows a user to update some information about an item.
SELECT_JOBAGENT
          This permission allows a user to specify which job agent a job should be executed on using Job.setJobAgent(JobAgent).
SET_OWNER
          This permission allows a user change the owner of an item.
SET_PERMISSION
          This permission allows a user change the access permission to an item.
SHARE_TO_EVERYONE
          This permission allows a user to share an item to the Group.EVERYONE group.
USE
          This permission allows a user to use/link to an item.
WRITE
          This permission allows a user update the information about an item.
 
Field Summary
private  int denyValue
           
private  String displayValue
           
private  int grantValue
           
 
Method Summary
(package private) static int deny(Permission... permissions)
          Combine the given permissions and convert to the integer deny value.
(package private) static int deny(Permission permission)
          Convert the given permission to the integer deny value.
(package private) static int deny(Set<Permission> permissions)
          Combine the given permission and convert to the integer deny value.
(package private)  int denyValue()
           
static Set<Permission> expand(Set<Permission> permissions)
          Expand the given set of permissions to make sure it includes all implicitely granted permissions.
(package private) static Set<Permission> fromDeniedInt(int permissions)
          Convert an integer value to a set of denied permissions.
(package private) static Set<Permission> fromInt(int permissions)
          Convert an integer value to a set of granted permissions.
(package private) static int grant(Permission... permissions)
          Combine the given permissions and convert to the integer grant value.
(package private) static int grant(Permission permission)
          Convert the given permission to the integer grant value.
(package private) static int grant(Set<Permission> permissions)
          Combine the given permission and convert to the integer grant value.
(package private)  int grantValue()
           
(package private) static boolean hasPermission(int permissions, Permission permission)
          Checks if the given Permission is granted by the permissions code.
(package private) static boolean isDeniedPermission(int permissions, Permission permission)
          Checks if the given Permission is denied by the permissions code.
(package private) static int merge(Integer... permissions)
          Merges a list of integer permission values.
 String toString()
           
static Permission valueOf(String name)
          Returns the enum constant of this type with the specified name.
static Permission[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

READ

public static final Permission READ
This permission allows a user read information about an item.


USE

public static final Permission USE
This permission allows a user to use/link to an item.


RESTRICTED_WRITE

public static final Permission RESTRICTED_WRITE
This permission allows a user to update some information about an item.


WRITE

public static final Permission WRITE
This permission allows a user update the information about an item.


DELETE

public static final Permission DELETE
This permission allows a user delete an item.


SET_OWNER

public static final Permission SET_OWNER
This permission allows a user change the owner of an item.


SET_PERMISSION

public static final Permission SET_PERMISSION
This permission allows a user change the access permission to an item.


CREATE

public static final Permission CREATE
This permission allows a user create new items.


DENIED

public static final Permission DENIED
This permission denies a user access to an item. This permission can only be given to RoleKey:s.


SHARE_TO_EVERYONE

public static final Permission SHARE_TO_EVERYONE
This permission allows a user to share an item to the Group.EVERYONE group. This is a system permission and is only meaningful for the role key for the Item.SYSTEM item.


ACT_AS_ANOTHER_USER

public static final Permission ACT_AS_ANOTHER_USER
This permission allows a user act as another user using the SessionControl.impersonateLogin(int, String) method. This is a system permission and is only meaningful for the role key for the Item.SYSTEM item.


SELECT_JOBAGENT

public static final Permission SELECT_JOBAGENT
This permission allows a user to specify which job agent a job should be executed on using Job.setJobAgent(JobAgent). This is a system permission and is only meaningful for the role key for the Item.SYSTEM item.

Since:
2.8
Field Detail

grantValue

private final int grantValue

denyValue

private final int denyValue

displayValue

private final String displayValue
Method Detail

values

public static Permission[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (Permission c : Permission.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static Permission valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

grantValue

int grantValue()

denyValue

int denyValue()

toString

public String toString()
Overrides:
toString in class Enum<Permission>

expand

public static Set<Permission> expand(Set<Permission> permissions)
Expand the given set of permissions to make sure it includes all implicitely granted permissions. For example if the set contains WRITE it is exapnded to READ, USE, RESTRICTED_WRITE and WRITE.

Parameters:
permissions - The permissions to expand
Returns:
A new set containing the expanded permissions or null if the parameter is null

hasPermission

static boolean hasPermission(int permissions,
                             Permission permission)
Checks if the given Permission is granted by the permissions code.

Parameters:
permissions - The permission combination
permission - The permission to check

isDeniedPermission

static boolean isDeniedPermission(int permissions,
                                  Permission permission)
Checks if the given Permission is denied by the permissions code.

Parameters:
permissions - The permission combination
permission - The permission to check

grant

static int grant(Permission permission)
Convert the given permission to the integer grant value.


grant

static int grant(Permission... permissions)
Combine the given permissions and convert to the integer grant value.


grant

static int grant(Set<Permission> permissions)
Combine the given permission and convert to the integer grant value.


deny

static int deny(Permission permission)
Convert the given permission to the integer deny value.


deny

static int deny(Permission... permissions)
Combine the given permissions and convert to the integer deny value.


deny

static int deny(Set<Permission> permissions)
Combine the given permission and convert to the integer deny value.


fromInt

static Set<Permission> fromInt(int permissions)
Convert an integer value to a set of granted permissions.


fromDeniedInt

static Set<Permission> fromDeniedInt(int permissions)
Convert an integer value to a set of denied permissions.


merge

static int merge(Integer... permissions)
Merges a list of integer permission values.

Parameters:
permissions - The permission values, null values are ignored
Returns:
The combined permissions
Since:
2.8

2.17.2: 2011-06-17