com.metamatrix.platform.admin.apiimpl
Class PermissionDataNodeImpl

java.lang.Object
  extended by com.metamatrix.common.tree.basic.BasicTreeNode
      extended by com.metamatrix.platform.admin.apiimpl.PermissionDataNodeImpl
All Implemented Interfaces:
PropertiedObject, TreeNode, PermissionDataNode, PermissionNode, java.io.Serializable, java.lang.Comparable

public class PermissionDataNodeImpl
extends BasicTreeNode
implements PermissionDataNode, java.io.Serializable, java.lang.Comparable

Defines a tree node for displaying entitlements.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.metamatrix.common.tree.basic.BasicTreeNode
DELIMITER, DELIMITER_CHAR
 
Constructor Summary
PermissionDataNodeImpl(BasicTreeNode parent, AuthorizationActions allowedActions, PermissionDataNodeDefinition nodeDefinition, boolean nodeIsPhysical, ObjectID guid)
          Construct a new instance by specifying the parent that owns this entity, the name of the instance, the type of the instance and the global UID for the instance.
 
Method Summary
 boolean actionsAreEqual(AuthorizationActions actions)
          Determine if this node's AuthorizationActions are equal to the given actions.
 boolean actionsAreEqual(PermissionNode node)
          Determine if this node's AuthorizationActions are equal to the given node's actions.
 boolean actionsAreEqual(java.lang.String[] actions)
          Determine if this node's AuthorizationActions are equal to the given actions.
 boolean allChildrenEnabledFor(AuthorizationActions actions)
          Do all children of this node share the given AuthorizationActions?
static int compare(PermissionDataNodeImpl obj1, PermissionDataNodeImpl obj2)
          Utility method to compare two PermissionDataNodeImpl instances.
 int compareTo(java.lang.Object obj)
          Compares this object to another.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
 java.lang.String[] getActionLabels()
          The AuthorizationActions labels currently on this data node.
 AuthorizationActions getActions()
          The AuthorizationActions currently on this data node.
 AuthorizationActions getAllowedActions()
          The AuthorizationActions allowed on this data node.
 int getDataNodeType()
          Get the type of this PermissionDataNode.
 AuthorizationActions getDescendantActions()
          Get the actions allowed by all descendants.
 java.lang.String getDisplayName()
          Display name for node.
 AuthorizationActions getOriginalActions()
          Get the original actions this node was created with.
 java.lang.String getResourceName()
          Resource name for node (the DataNodeID).
 ObjectID getUUID()
          The node's unique ID.
 int hashCode()
          Override hashCode() to be consistant with overriden equals().
 boolean hasPermission()
          Does this node have any permission associated with it?

Note: if hasPermission() returns false, there will be no AuthorizatinPoicyID associated with this node and getPolicyID() will return null.
 boolean isDescendantEnabled()
          Are there any entitled nodes below this point in the tree?
 boolean isDescendantEnabledFor(AuthorizationActions actions)
          Does this node have any descendants enabled for the given AuthorizationActions?
 boolean isGroupNode()
          Is this node a group (has only one level of children)?
 boolean isHidden()
          Check whether or not this node is hidden from the PermissionDataNodeTreeView.
 boolean isLeafNode()
          Is this node a leaf?
 boolean isPhysical()
          Does this node belong to a physical model?
 boolean isRecursive()
          A node is recursive if its actions are shared by its descendants' actions.
 java.lang.String printDebug()
          Return stringafied representation of the object.
 void setActions(AuthorizationActions actions)
          Set the AuthorizationActions on this data node.
 void setActions(int actions)
          Set the allowed AuthorizationActions on this data node.
 void setAllowedActions(AuthorizationActions actions)
          Set the allowed AuthorizationActions on this data node.
 void setHidden(boolean isHidden)
          Set whether or not this node is hidden from the PermissionDataNodeTreeView.
 java.lang.String toString()
          Return stringafied representation of the object.
 
Methods inherited from class com.metamatrix.common.tree.basic.BasicTreeNode
add, add, addChild, addChildIsValid, addFullName, addMarkedNodesToSet, areDuplicateChildNamesAllowed, assertBasicTreeNode, containsChildWithName, convertTypeToString, ensureNameIsValid, exists, find, findLeafNodes, findMarkedAndUnmarkedNodes, findTopLevelMarkedNodes, getChild, getChildCount, getChildren, getChildren, getDecendant, getDecendant, getDefaultName, getDescriptionPropertyDefinition, getEntityForm, getFullName, getFullName, getGlobalUID, getIndexOfChild, getName, getNamePropertyDefinition, getNamespace, getParent, getProperties, getPropertyDefinitions, getPropertyValue, getSeparator, getSeparatorChar, getType, hasChildren, insert, isAncestorOf, isMarked, isModified, isParentOf, isValidNewName, iterator, moveChild, print, printInfo, remove, remove, removeAll, removePropertyValue, resolveTypeFromString, setExists, setGlobalUID, setMarked, setMarked, setModified, setModified, setName, setNameOfNode, setPropertyValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.metamatrix.common.tree.TreeNode
exists, getFullName, getName, getNamespace, getSeparator, getSeparatorChar, getType, isModified
 

Constructor Detail

PermissionDataNodeImpl

public PermissionDataNodeImpl(BasicTreeNode parent,
                              AuthorizationActions allowedActions,
                              PermissionDataNodeDefinition nodeDefinition,
                              boolean nodeIsPhysical,
                              ObjectID guid)
Construct a new instance by specifying the parent that owns this entity, the name of the instance, the type of the instance and the global UID for the instance. Note: this constructor does NOT verify that the name is valid within the parent's namespace.

Parameters:
parent - the parent that is considered the owning namespace for this instance; may be null if the new instance is to be the root
allowedActions - Contain the only actions that will be allowed on this node.
nodeDefinition - The "type" of this treeNode which contains the "subtype" of the PermissionDataNode: PermissionDataNodeDefinition.TYPE
nodeIsPhysical - Is this node physical are virtual.
guid - the globally-unique identifier for this instance; may not be null
Method Detail

getDataNodeType

public int getDataNodeType()
Get the type of this PermissionDataNode.
This method returns the int type of this node which coresponds to PermissionDataNodeDefinition.TYPE .

Specified by:
getDataNodeType in interface PermissionDataNode
Returns:
The type of this PermisionDataNode.

getDisplayName

public java.lang.String getDisplayName()
Display name for node.

Specified by:
getDisplayName in interface PermissionNode
Returns:
The name of the data node for display.

getResourceName

public java.lang.String getResourceName()
Resource name for node (the DataNodeID).

Specified by:
getResourceName in interface PermissionNode
Returns:
The resource name of the data node.

isPhysical

public boolean isPhysical()
Does this node belong to a physical model?

Specified by:
isPhysical in interface PermissionDataNode
Returns:
true if this node is part of a physical model.

hasPermission

public boolean hasPermission()
Does this node have any permission associated with it?

Note: if hasPermission() returns false, there will be no AuthorizatinPoicyID associated with this node and getPolicyID() will return null.

Specified by:
hasPermission in interface PermissionNode
Returns:
True, if this node has an Action other than NONE.

getUUID

public ObjectID getUUID()
The node's unique ID.

Specified by:
getUUID in interface PermissionNode
Returns:
The unique ID for the node.

getActionLabels

public java.lang.String[] getActionLabels()
The AuthorizationActions labels currently on this data node.

Specified by:
getActionLabels in interface PermissionNode
Returns:
The Array of one or more of {"None", "Create", "Read", "Update", "Delete"}.
See Also:
com.metatamatrix.platform.security.api.StandardAuthorizationActions

getActions

public AuthorizationActions getActions()
The AuthorizationActions currently on this data node.

Specified by:
getActions in interface PermissionNode
Returns:
The actions allowed on this data node.
See Also:
com.metatamatrix.platform.security.api.StandardAuthorizationActions

getAllowedActions

public AuthorizationActions getAllowedActions()
The AuthorizationActions allowed on this data node.

Specified by:
getAllowedActions in interface PermissionNode
Returns:
The actions allowed on this data node.
See Also:
com.metatamatrix.platform.security.api.StandardAuthorizationActions

setActions

public void setActions(AuthorizationActions actions)
                throws PermissionNodeNotActionableException
Set the AuthorizationActions on this data node.

Specified by:
setActions in interface PermissionNode
Parameters:
actions - The the actions to set on this data node.
Throws:
PermissionNodeNotActionableException - If attempt is made to set actions on a node that can't accept any actions.

setActions

public void setActions(int actions)
                throws PermissionNodeNotActionableException
Set the allowed AuthorizationActions on this data node.

Specified by:
setActions in interface PermissionNode
Parameters:
actions - The the actions to set on this data node.
Throws:
PermissionNodeNotActionableException - If attempt is made to set actions on a node that can't accept any actions.

getOriginalActions

public AuthorizationActions getOriginalActions()
Get the original actions this node was created with.

Returns:
The actions this node was created with.

setAllowedActions

public void setAllowedActions(AuthorizationActions actions)
Set the allowed AuthorizationActions on this data node.

Parameters:
actions - The the actions that can be applied to this data node.

actionsAreEqual

public boolean actionsAreEqual(AuthorizationActions actions)
Determine if this node's AuthorizationActions are equal to the given actions. The actions are considered equal if number of actions are the same and all corresponding pairs of actions are equal.

Specified by:
actionsAreEqual in interface PermissionNode
Parameters:
actions - The AuthorizationActions to compare with this node's actions.
Returns:
true if the Actions of this node are equal to the given actions.

actionsAreEqual

public boolean actionsAreEqual(java.lang.String[] actions)
Determine if this node's AuthorizationActions are equal to the given actions. The actions are considered equal if number of actions are the same and all corresponding pairs of actions are equal.

Specified by:
actionsAreEqual in interface PermissionNode
Parameters:
actions - The Array of one or more of {"None", "Create", "Read", "Update", "Delete"}.
Returns:
true if the Actions of this node are equal to the given actions.

actionsAreEqual

public boolean actionsAreEqual(PermissionNode node)
Determine if this node's AuthorizationActions are equal to the given node's actions. The actions are considered equal if number of actions are the same and all corresponding pairs of actions are equal.

Specified by:
actionsAreEqual in interface PermissionNode
Parameters:
node - The node whose actions to compare with this node's actions.
Returns:
true if the Actions of this node are equal to the given node's actions.

isDescendantEnabled

public boolean isDescendantEnabled()
Are there any entitled nodes below this point in the tree?

Specified by:
isDescendantEnabled in interface PermissionDataNode
Returns:
True, if a decendant is entitled with any AuthorizationActions, False otherwise.

isDescendantEnabledFor

public boolean isDescendantEnabledFor(AuthorizationActions actions)
Does this node have any descendants enabled for the given AuthorizationActions?

Specified by:
isDescendantEnabledFor in interface PermissionDataNode
Parameters:
actions - The actions of interest.
Returns:
True, if a decendant of this node is entitled with the given actions, False otherwise.

allChildrenEnabledFor

public boolean allChildrenEnabledFor(AuthorizationActions actions)
Do all children of this node share the given AuthorizationActions?

Parameters:
actions - The actions of interest.
Returns:
True, if all children of this node share the given actions, False otherwise.

isRecursive

public boolean isRecursive()
A node is recursive if its actions are shared by its descendants' actions.

Returns:
true if this node is recursive.

isHidden

public boolean isHidden()
Check whether or not this node is hidden from the PermissionDataNodeTreeView. The default is false, the node is not hidden.

Specified by:
isHidden in interface PermissionNode
Returns:
true if this node may be hidden from the view.
See Also:
PermissionTreeView.setShowHidden(boolean)

setHidden

public void setHidden(boolean isHidden)
Set whether or not this node is hidden from the PermissionDataNodeTreeView. The default is false, the node is not hidden.

Specified by:
setHidden in interface PermissionNode
Parameters:
isHidden - If true, this node may be hidden from the view.
See Also:
PermissionTreeView.setShowHidden(boolean)

isLeafNode

public boolean isLeafNode()
Is this node a leaf?

Specified by:
isLeafNode in interface PermissionNode
Returns:
true, if this node has no children.

isGroupNode

public boolean isGroupNode()
Is this node a group (has only one level of children)?

Specified by:
isGroupNode in interface PermissionDataNode
Returns:
true, if this node has only on level of children.

getDescendantActions

public AuthorizationActions getDescendantActions()
Get the actions allowed by all descendants.


equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Specified by:
equals in interface TreeNode
Overrides:
equals in class BasicTreeNode
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object to another. If the specified object is not an instance of the PermissionDataNodeImpl class, then this method throws a ClassCastException (as instances are comparable only to instances of the same class). Note: this method is consistent with equals(), meaning that (compare(x, y)==0) == (x.equals(y)).

Specified by:
compareTo in interface TreeNode
Specified by:
compareTo in interface java.lang.Comparable
Overrides:
compareTo in class BasicTreeNode
Parameters:
obj - the object that this instance is to be compared to; may not be null.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this instance.

compare

public static final int compare(PermissionDataNodeImpl obj1,
                                PermissionDataNodeImpl obj2)
Utility method to compare two PermissionDataNodeImpl instances. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

This method assumes that all type-checking has already been performed.

Parameters:
obj1 - the first node to be compared
obj2 - the second node to be compared
Returns:
-1, 0, +1 based on whether obj1 is less than, equal to, or greater than obj2

hashCode

public int hashCode()
Override hashCode() to be consistant with overriden equals().

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Return stringafied representation of the object.

Specified by:
toString in interface TreeNode
Overrides:
toString in class BasicTreeNode
Returns:
the string representation of this instance.

printDebug

public java.lang.String printDebug()
Return stringafied representation of the object.

Specified by:
printDebug in interface PermissionDataNode


Copyright © 2009. All Rights Reserved.