org.openwms.core.domain.system.usermanagement
Class Role

java.lang.Object
  extended by org.openwms.core.domain.AbstractEntity
      extended by org.openwms.core.domain.system.usermanagement.SecurityObject
          extended by org.openwms.core.domain.system.usermanagement.Role
All Implemented Interfaces:
Serializable, DomainObject<Long>

public class Role
extends SecurityObject

A Role is a group of Users. Basically more than one User belong to a Role. Security access policies are assigned to Roles instead of Users.

Since:
0.1
Version:
$Revision: 1595 $
Author:
Heiko Scherrer
See Also:
SecurityObject, User, Role, Serialized Form

Nested Class Summary
static class Role.Builder
          A builder class to construct Role instances.
 
Nested classes/interfaces inherited from class org.openwms.core.domain.AbstractEntity
AbstractEntity.AbstractEntityListener
 
Field Summary
static String NQ_FIND_ALL
          Query to find all Roles.
static String NQ_FIND_BY_UNIQUE_QUERY
          Query to find one Role by its natural key.
static String ROLE_PREFIX
          The default prefix String for each created Role.
 
Fields inherited from class org.openwms.core.domain.AbstractEntity
FIND_ALL, FIND_BY_ID
 
Constructor Summary
Role(String name)
          Create a new Role with a name.
Role(String name, String description)
          Create a new Role with a name and a description.
 
Method Summary
 boolean addGrant(SecurityObject grant)
          Add an existing SecurityObject to the Role.
 boolean addUser(User user)
          Add an existing User to the Role.
 boolean equals(Object obj)
           Compare the uid property field.
 Set<SecurityObject> getGrants()
          Return an unmodifiable Set of all SecurityObjects belonging to the Role.
 Boolean getImmutable()
          Get the immutable.
 Set<RolePreference> getPreferences()
          Return all RolePreferences of the Role.
 Set<User> getUsers()
          Return an unmodifiable Set of all Users assigned to the Role.
 int hashCode()
           Use the uid to calculate the hashCode.
 boolean removeGrant(SecurityObject grant)
          Add an existing SecurityObject to the Role.
 void removeUser(User user)
          Remove a User from the Role.
 void setGrants(Set<SecurityObject> grants)
          Set all SecurityObjects assigned to the Role.
 void setPreferences(Set<RolePreference> preferences)
          Set all RolePreferences belonging to the Role.
 void setUsers(Set<User> users)
          Set all Users belonging to this Role.
 
Methods inherited from class org.openwms.core.domain.system.usermanagement.SecurityObject
getDescription, getId, getName, getVersion, isNew, setDescription, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ROLE_PREFIX

public static final String ROLE_PREFIX
The default prefix String for each created Role. Name is * * * "ROLE_" .

See Also:
Constant Field Values

NQ_FIND_ALL

public static final String NQ_FIND_ALL
Query to find all Roles. Name is "Role.findAll" .

See Also:
Constant Field Values

NQ_FIND_BY_UNIQUE_QUERY

public static final String NQ_FIND_BY_UNIQUE_QUERY
Query to find one Role by its natural key.
  • Query parameter index 1 : The name of the Role to search for.
  • Name is "Role.findByRolename" .

    See Also:
    Constant Field Values
    Constructor Detail

    Role

    public Role(String name)
    Create a new Role with a name.

    Parameters:
    name - The name of the Role
    Throws:
    IllegalArgumentException - when name is null or empty

    Role

    public Role(String name,
                String description)
    Create a new Role with a name and a description.

    Parameters:
    name - The name of the Role
    description - The description text of the Role
    Throws:
    IllegalArgumentException - when name is null or empty
    Method Detail

    getImmutable

    public Boolean getImmutable()
    Get the immutable.

    Returns:
    the immutable.

    getUsers

    public Set<User> getUsers()
    Return an unmodifiable Set of all Users assigned to the Role.

    Returns:
    A Set of all Users assigned to the Role

    addUser

    public boolean addUser(User user)
    Add an existing User to the Role.

    Parameters:
    user - The User to be added
    Returns:
    true if the User was new in the collection of Users, otherwise false
    Throws:
    IllegalArgumentException - if user is null

    removeUser

    public void removeUser(User user)
    Remove a User from the Role.

    Parameters:
    user - The User to be removed
    Throws:
    IllegalArgumentException - if user is null

    setUsers

    public void setUsers(Set<User> users)
    Set all Users belonging to this Role.

    Parameters:
    users - A Set of Users to be assigned to the Role
    Throws:
    IllegalArgumentException - if users is null

    getPreferences

    public Set<RolePreference> getPreferences()
    Return all RolePreferences of the Role.

    Returns:
    A Set of all RolePreferences assigned to the Role

    setPreferences

    public void setPreferences(Set<RolePreference> preferences)
    Set all RolePreferences belonging to the Role.

    Parameters:
    preferences - A Set of RolePreferences to be assigned to the Role

    getGrants

    public Set<SecurityObject> getGrants()
    Return an unmodifiable Set of all SecurityObjects belonging to the Role.

    Returns:
    A Set of all SecurityObjects belonging to this Role

    addGrant

    public boolean addGrant(SecurityObject grant)
    Add an existing SecurityObject to the Role.

    Parameters:
    grant - The SecurityObject to be added to the Role.
    Returns:
    true if the SecurityObject was new to the collection of SecurityObjects, otherwise false
    Throws:
    IllegalArgumentException - if grant is null

    removeGrant

    public boolean removeGrant(SecurityObject grant)
    Add an existing SecurityObject to the Role.

    Parameters:
    grant - The SecurityObject to be added to the Role
    Returns:
    true if the SecurityObject was successfully removed from the Set of SecurityObjects, otherwise false
    Throws:
    IllegalArgumentException - if grant is null

    setGrants

    public void setGrants(Set<SecurityObject> grants)
    Set all SecurityObjects assigned to the Role. Already existing SecurityObjects will be removed.

    Parameters:
    grants - A Set of SecurityObjects to be assigned to the Role
    Throws:
    IllegalArgumentException - if grants is null

    hashCode

    public int hashCode()
    Use the uid to calculate the hashCode. Delegates to the superclass and uses the hashCode of the String ROLE for calculation.

    Overrides:
    hashCode in class SecurityObject
    See Also:
    Object.hashCode()

    equals

    public boolean equals(Object obj)
    Compare the uid property field. Compare the name. Does not delegate to the SecurityObject.equals(Object) and uses the name for comparison.

    Overrides:
    equals in class SecurityObject
    See Also:
    Object.equals(java.lang.Object)


    Copyright © 2005-2011 openwms.org. All Rights Reserved.