Enum 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:
    • READ ->
    • USE -> READ
    • RESTRICTED_WRITE -> USE and READ
    • WRITE -> RESTRICTED_WRITE, USE and READ
    • DELETE -> WRITE, RESTRICTED_WRITE, USE and READ
    • SET_OWNER -> WRITE, RESTRICTED_WRITE, USE and READ
    • SET_PERMISSION -> WRITE, RESTRICTED_WRITE, USE and READ
    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:
    • READ -> USE, RESTRICTED_WRITE, WRITE, DELETE, SET_OWNER and SET_PERMISSION
    • USE -> RESTRICTED_WRITE, WRITE, DELETE, SET_OWNER and SET_PERMISSION
    • RESTRICTED_WRITE -> WRITE, DELETE, SET_OWNER and SET_PERMISSION
    • WRITE -> DELETE, SET_OWNER and SET_PERMISSION
    • DELETE ->
    • SET_OWNER ->
    • SET_PERMISSION ->
    Last modified
    $Date: 2016-10-19 14:08:22 +0200 (on, 19 okt 2016) $
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      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.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Permission​(int grantValue, int denyValue, String displayValue)
      Constructor for Permission enums.
    • 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.
      • 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
    • Constructor Detail

      • Permission

        private Permission​(int grantValue,
                           int denyValue,
                           String displayValue)
        Constructor for Permission enums.
    • 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()
      • 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