Enum RoleWithHierarchy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<RoleWithHierarchy>

    public enum RoleWithHierarchy
    extends java.lang.Enum<RoleWithHierarchy>
    implements java.io.Serializable
    Hierarchical role. Combines RoleWithHierarchy.RoleCode with RoleWithHierarchy.RoleLevel and a set of RoleWithHierarchys that are stronger.

    Available roles can:

    1. be presented to the user
    2. be easily mapped to database structure
    3. be used to restrict access to server methods
    4. define the role hierarchy by specifying which roles are stronger (users that have only the "stronger" role will also be able to access given server method)

    Example:

    To annotate an interface method with a new role e.g. SECRET_AGENT:
    1. Add SECRET_AGENT to RoleWithHierarchy.RoleCode enumerator.
    2. Add SECRET_AGENT to authorization_role domain in the database (and prepare migration).
    3. Add INSTANCE_SECRET_AGENT (or SPACE_SECRET_AGENT) to RoleWithHierarchy enumerator and define the "stronger" roles.
    4. Use the new RoleWithHierarchy to annotate the interface method.
    • Method Detail

      • values

        public static RoleWithHierarchy[] 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 (RoleWithHierarchy c : RoleWithHierarchy.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static RoleWithHierarchy valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isInstanceLevel

        public boolean isInstanceLevel()
      • isSpaceLevel

        public boolean isSpaceLevel()
      • isProjectLevel

        public boolean isProjectLevel()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Enum<RoleWithHierarchy>