org.openpermis.policy.bean.basic
Class BasicRoleHierarchy

java.lang.Object
  extended by org.openpermis.policy.bean.basic.BasicPart
      extended by org.openpermis.policy.bean.basic.BasicPartBean
          extended by org.openpermis.policy.bean.basic.BasicRoleHierarchy
All Implemented Interfaces:
Serializable, IdentifiableBean, PartBean, RoleHierarchyBean, Identifiable, Part, RoleHierarchy

public class BasicRoleHierarchy
extends BasicPartBean
implements RoleHierarchyBean

A DAG of roles.

See Also:
Serialized Form
Since:
0.1.0

Nested Class Summary
static class BasicRoleHierarchy.Direction
           
 
Constructor Summary
protected BasicRoleHierarchy(SerialNumber serialNumber, URI identity)
          Creates a role hierarchy.
 
Method Summary
 void accept(List<PartBean> parents, MultiPartBeanVisitor visitor)
          Allows traversing the model according to the visitor pattern.
 void addRole(String role)
          Adds a new role in this role hierarchy, if not yet exists.
 void addRole(String role, Set<String> parentRoles)
          Adds a new role in this role hierarchy.
 void addRole(String role, String parentRole)
          Adds a new role in this role hierarchy.
protected  void appendPartDetails(StringBuilder sb)
          Appends the details of this extended part for the string representation of this part.
protected  boolean checkLocalConsistency(PartProblemReporter reporter)
          Checks if the extended state of this part is consistent.
protected  boolean comparablePart(BasicPart part)
          Check if the part specified is comparable to this part.
 boolean connectRoles(String parentRole, String childRole)
          Convenience method: add an edge between two roles.
 boolean disconnectRoles(String parentRole, String childRole)
          Convenience method: remove an edge between two roles.
 PartBean findBySerialNumber(SerialNumber partSerialNumber)
          Returns the part bean corresponding to the specified serial number.
 Set<String> getChildRoles(String role)
          Returns a unmodifiable list of all children.
 Set<String> getLeafRoles()
          Returns a list of all roles with no children.
 Set<String> getParentRoles(String role)
          Returns a unmodifiable list of all parents.
 Set<String> getRoles()
          Returns a unmodifiable list of all roles in this hierarchy.
 Set<String> getRootRoles()
          Returns a list of all roles with no parents.
protected  String getSimpleClassName()
          Returns the simple implementation class name of this class.
 Set<String> getSubRoles(String role)
          Returns all sub roles of 'role' including 'role' itself.
 Set<String> getSuperRoles(String role)
          Returns all superior roles of 'role' including 'role' itself.
 boolean isChildRole(String role, String childRole)
          Returns true if childRole is a child-role of role.
 boolean isLeafRole(String role)
          Returns true if role is leaf, i.e.
 boolean isParentRole(String role, String parentRole)
          Returns true if parentRole is a parent-role of role.
 boolean isRootRole(String role)
          Returns true if role is root, i.e.
 boolean isSubRole(String role, String subRole)
          Returns true if subRole is a sub-role of role.
 boolean isSuperRole(String role, String superRole)
          Returns true if superRole is a super-role of role.
 void removeRole(String role)
          Removes a role from role hierarchy.
 boolean renameRole(String role, String newName)
          Renames an existing role.
 boolean roleExists(String role)
          Checks if a role exists in this role hierarchy.
 void setChildRoles(String role, Set<String> childrenRoles)
          Set new children roles of a role.
 void setParentRoles(String role, Set<String> parentRoles)
          Set new parent roles of a role.
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPartBean
accept, addPropertyChangeListener, equalSerialNumber, firePropertyChange, getPartBeanType, getSerialNumber, getSerialNumberString, instanceOf, notifyIdentityChange, notifyNameChange, removePropertyChangeListener, toShortString
 
Methods inherited from class org.openpermis.policy.bean.basic.BasicPart
appendDetails, areIdentitiesUnique, areNamesUnique, checkLocalPartConsistency, equalPart, equals, getIdentity, getName, hashCode, hasPartIdentity, hasPartName, isIdentityValid, isNameValid, partHashCode, reportProblem, setIdentity, setName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openpermis.policy.bean.PartBean
accept, addPropertyChangeListener, checkLocalPartConsistency, equalSerialNumber, getPartBeanType, getSerialNumber, instanceOf, removePropertyChangeListener, toShortString
 
Methods inherited from interface org.openpermis.policy.Part
equals, hashCode, toString
 
Methods inherited from interface org.openpermis.policy.bean.IdentifiableBean
setIdentity
 
Methods inherited from interface org.openpermis.policy.Identifiable
getIdentity
 

Constructor Detail

BasicRoleHierarchy

protected BasicRoleHierarchy(SerialNumber serialNumber,
                             URI identity)
Creates a role hierarchy.

Parameters:
serialNumber - the serial number of this part.
Method Detail

getSuperRoles

public Set<String> getSuperRoles(String role)
Returns all superior roles of 'role' including 'role' itself.

Specified by:
getSuperRoles in interface RoleHierarchy
Parameters:
role - identifies a role in the hierarchy.
Returns:
all superior roles of 'role' including 'role' itself.
Since:
0.3.0

getSubRoles

public Set<String> getSubRoles(String role)
Returns all sub roles of 'role' including 'role' itself.

Specified by:
getSubRoles in interface RoleHierarchy
Parameters:
role - identifies a role in the hierarchy.
Returns:
all sub roles of 'role' including 'role' itself.
Since:
0.3.0

accept

public void accept(List<PartBean> parents,
                   MultiPartBeanVisitor visitor)
Description copied from interface: PartBean
Allows traversing the model according to the visitor pattern. Visit may be called more than once on each part in the domain model, but it is called exactly once for each tuple (parent path, part).

Each part bean must call method visitor.visit(this)

Specified by:
accept in interface PartBean
Parameters:
parents - the path of parents of this part.
visitor - a PartBeanVisitor.
Since:
0.9.0

roleExists

public boolean roleExists(String role)
Checks if a role exists in this role hierarchy.

Specified by:
roleExists in interface RoleHierarchyBean
Parameters:
role - the role to search.
Returns:
if found * @since 0.3.0

getRoles

public Set<String> getRoles()
Returns a unmodifiable list of all roles in this hierarchy.

Specified by:
getRoles in interface RoleHierarchyBean
Returns:
list of roles in this hierarchy.
Since:
0.1.0

getRootRoles

public Set<String> getRootRoles()
Returns a list of all roles with no parents.

Specified by:
getRootRoles in interface RoleHierarchyBean
Returns:
list of all roles with no parents.
Since:
0.3.0

getLeafRoles

public Set<String> getLeafRoles()
Returns a list of all roles with no children. precondition: role exists.

Specified by:
getLeafRoles in interface RoleHierarchyBean
Returns:
list of all roles with no children.
Since:
0.3.0

getChildRoles

public Set<String> getChildRoles(String role)
Returns a unmodifiable list of all children. precondition: role exists.

Specified by:
getChildRoles in interface RoleHierarchyBean
Returns:
list of children roles.
Since:
0.3.0

getParentRoles

public Set<String> getParentRoles(String role)
Returns a unmodifiable list of all parents. precondition: role exists.

Specified by:
getParentRoles in interface RoleHierarchyBean
Returns:
list of parent roles.
Since:
0.3.0

isRootRole

public boolean isRootRole(String role)
Returns true if role is root, i.e. has no parents. precondition: role exists.

Specified by:
isRootRole in interface RoleHierarchyBean
Parameters:
role - the role to check.
Returns:
true if found.
Since:
0.3.0

isLeafRole

public boolean isLeafRole(String role)
Returns true if role is leaf, i.e. has no children. precondition: role exists.

Specified by:
isLeafRole in interface RoleHierarchyBean
Parameters:
role - the role to check.
Returns:
true if found.
Since:
0.3.0

isSubRole

public boolean isSubRole(String role,
                         String subRole)
Returns true if subRole is a sub-role of role. precondition: both roles exist.

Specified by:
isSubRole in interface RoleHierarchyBean
Parameters:
role - the role to start search from.
subRole - the role to find.
Returns:
true if found.
Since:
0.3.0

isSuperRole

public boolean isSuperRole(String role,
                           String superRole)
Returns true if superRole is a super-role of role. precondition: both roles exist.

Specified by:
isSuperRole in interface RoleHierarchyBean
Parameters:
role - the role to start search from..
superRole - the role to find.
Returns:
true if found.
Since:
0.3.0

isChildRole

public boolean isChildRole(String role,
                           String childRole)
Returns true if childRole is a child-role of role. precondition: both roles exist.

Specified by:
isChildRole in interface RoleHierarchyBean
Parameters:
role - the role to start search from..
childRole - the role to find.
Returns:
true if found.
Since:
0.3.0

isParentRole

public boolean isParentRole(String role,
                            String parentRole)
Returns true if parentRole is a parent-role of role. precondition: both roles exist.

Specified by:
isParentRole in interface RoleHierarchyBean
Parameters:
role - the role to start search from..
parentRole - the role to find.
Returns:
true if found.
Since:
0.3.0

setChildRoles

public void setChildRoles(String role,
                          Set<String> childrenRoles)
Set new children roles of a role. precondition: all roles exist.

Specified by:
setChildRoles in interface RoleHierarchyBean
Parameters:
role - role to set children for.
childrenRoles - children roles to set
Since:
0.3.0

setParentRoles

public void setParentRoles(String role,
                           Set<String> parentRoles)
Set new parent roles of a role. precondition: all roles exist.

Specified by:
setParentRoles in interface RoleHierarchyBean
Parameters:
role - role to set parents for.
parentRoles - parent roles to set
Since:
0.3.0

connectRoles

public boolean connectRoles(String parentRole,
                            String childRole)
Convenience method: add an edge between two roles. Nothing is done if either role is null oder edge already exists.

Specified by:
connectRoles in interface RoleHierarchyBean
Parameters:
parentRole - parent role.
childRole - child role
Returns:
true if edge was added
Since:
0.3.0

disconnectRoles

public boolean disconnectRoles(String parentRole,
                               String childRole)
Convenience method: remove an edge between two roles. Nothing is done if either role is null oder edge not exists.

Specified by:
disconnectRoles in interface RoleHierarchyBean
Parameters:
parentRole - parent role.
childRole - child role
Returns:
true if edge was removed
Since:
0.3.0

addRole

public void addRole(String role)
Adds a new role in this role hierarchy, if not yet exists. precondition: role not yet exists.

Specified by:
addRole in interface RoleHierarchyBean
Parameters:
role - the new role to be added.
Since:
0.3.0

addRole

public void addRole(String role,
                    String parentRole)
Adds a new role in this role hierarchy. precondition: role not yet exists, parentRole exists.

Specified by:
addRole in interface RoleHierarchyBean
Parameters:
role - the new role to be added.
parentRole - the parent where the role is appended.
Since:
0.3.0

addRole

public void addRole(String role,
                    Set<String> parentRoles)
Adds a new role in this role hierarchy. precondition: role not yet exists, parentRoles exist.

Specified by:
addRole in interface RoleHierarchyBean
Parameters:
role - the new role to be added.
parentRoles - the parents where the role is appended.
Since:
0.3.0

removeRole

public void removeRole(String role)
Removes a role from role hierarchy. * precondition: role exists.

Specified by:
removeRole in interface RoleHierarchyBean
Parameters:
role - the role to be removed.
Since:
0.3.0

renameRole

public boolean renameRole(String role,
                          String newName)
Description copied from interface: RoleHierarchyBean
Renames an existing role.

The renamed role will keep its super and sub roles.

Specified by:
renameRole in interface RoleHierarchyBean
Parameters:
role - the role to be renamed.
newName - the new name for the role
Returns:
true if role was renamed.
Since:
0.3.0

findBySerialNumber

public PartBean findBySerialNumber(SerialNumber partSerialNumber)
Description copied from class: BasicPartBean
Returns the part bean corresponding to the specified serial number.

If the part bean contains other part beans, it searches its child beans recursively.

The basic implementation returns this bean if its serial number matches the one passed in or null if not. Subclasses that contain other parts must traverse their children.

Specified by:
findBySerialNumber in interface PartBean
Overrides:
findBySerialNumber in class BasicPartBean
Parameters:
partSerialNumber - the SerialNumber of the part bean to return.
Returns:
the matching PartBean or null if no matching part bean is found.
Since:
0.1.0

checkLocalConsistency

protected boolean checkLocalConsistency(PartProblemReporter reporter)
Description copied from class: BasicPart
Checks if the extended state of this part is consistent.

Overrides:
checkLocalConsistency in class BasicPart
Parameters:
reporter - the problem reporter to use, may be null.
Since:
0.9.0

comparablePart

protected boolean comparablePart(BasicPart part)
Description copied from class: BasicPart
Check if the part specified is comparable to this part.

Specified by:
comparablePart in class BasicPart
Parameters:
part - the part to check.
See Also:
BasicPart
Returns:
true if the part supplied is comparable to this part.
Since:
0.1.0

getSimpleClassName

protected String getSimpleClassName()
Description copied from class: BasicPart
Returns the simple implementation class name of this class.

If your implementation represents an interface implementation return the interface simple class name here. In short: return the instance you are checking against in BasicPart.comparablePart(BasicPart).

Overrides:
getSimpleClassName in class BasicPart
Returns:
the simple implementation class name of this class.
Since:
0.1.0

appendPartDetails

protected void appendPartDetails(StringBuilder sb)
Description copied from class: BasicPart
Appends the details of this extended part for the string representation of this part.

Overrides:
appendPartDetails in class BasicPart
Parameters:
sb - the string builder to add the details to.
See Also:
BasicPart, BasicPart.appendDetails(StringBuilder, String, Object)
Since:
0.1.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:16:59
Copyright (c) 2002-2007 Ergon Informatik AG