com.metamatrix.platform.admin.apiimpl
Class PermissionDataNodeTreeViewImpl

java.lang.Object
  extended by com.metamatrix.platform.admin.apiimpl.PermissionDataNodeTreeViewImpl
All Implemented Interfaces:
PermissionDataNodeTreeView, PermissionTreeView

public class PermissionDataNodeTreeViewImpl
extends java.lang.Object
implements PermissionDataNodeTreeView

Provides a view into the tree of PermissionDataNodes and supports utility methods that perform funcions on the tree as a whole.

A property can be set (or toggled) to determine if clients want methods to return nodes marked hidden. See setShowHidden(boolean).


Constructor Summary
PermissionDataNodeTreeViewImpl(PermissionNode root)
          Construct a PermissionDataNode.
 
Method Summary
 boolean allDescendantsShareActions(PermissionNode startingPoint)
          Determine whether all descendants of the given node share the exact same actions as the given node.
protected  PermissionDataNodeImpl assertPermissionDataNode(PermissionNode node)
          Perform safe runtime casts.
 java.util.Iterator breadthFirstIterator()
          Obtain a breadth-first Iterator over the whole tree starting at the root.
 java.util.Iterator breadthFirstIterator(PermissionNode startingPoint)
          Obtain a breadth-first Iterator starting at the given node.
 java.util.List getChildren(PermissionNode parent)
          Obtain the set of entries that are considered the children of the specified PermissionDataNode.
 java.util.List getDescendants(PermissionNode startingPoint)
          Obtain all the PermissionDataNodes in the tree under the given node.
 java.util.List getDescendantsWithActions(PermissionNode startingPoint, AuthorizationActions actions, boolean strict)
          Obtain all the PermissionDataNodes in the tree under the given node.
 java.util.Set getMarked()
          Obtain all the marked PermissionDataNodes in the tree.
 java.util.Set getMarkedDescendants(PermissionNode startingPoint)
          Obtain all the marked PermissionDataNodes in the tree under the given node.
 java.util.List getModified()
          Obtain all the modified PermissionDataNodes in the tree.

This method will get hidden nodes if showHidden == true.
 java.util.List getModifiedBreadthFirst()
          Obtain the modified PermissionDataNodes closest to the root in the tree.
 java.util.List getModifiedDescendants(PermissionNode startingPoint)
          Obtain all the modified PermissionDataNodes in the tree under the given node.
 PermissionNode getParent(PermissionNode node)
          Determine the parent PermissionDataNode for the specified entry, or null if the specified entry is a root.
 PermissionNode getRoot()
          Obtain the root PermissionDataNode of the tree.
 java.util.List getRoots()
          Obtain a list of PermissionDataNodes which are the children of the root.
 java.util.List getUnModifiedDescendants(PermissionNode startingPoint)
          Obtain all the unmodified PermissionDataNodes in the tree under the given node.
 void hideAllSystemNodes()
          Hide all nodes whose resource name starts with "System".
 boolean isAncestorOf(PermissionNode ancestor, PermissionNode descendant)
          Determine whether the given descendant is a descendant of the given ancestor.

This method will check all ancesters of the descendant, even if they are marked hidden.
 boolean isDescendantOf(PermissionNode ancestor, PermissionNode descendant)
          Determine whether the given descendant is a descendant of the given ancestor.

This method will check all descendants of the ancester, even if they are marked hidden.
 java.util.Iterator iterator()
          Obtain a depth-first Iterator over the whole tree starting at the root.
 java.util.Iterator iterator(PermissionNode startingPoint)
          Obtain a depth-first Iterator starting at the given node.
 void resetTree()
          Reset all tree nodes to their original AuthorizationActions values.
 void setBranchAllowedActions(PermissionNode startingPoint, AuthorizationActions actions)
          Set the allowed AuthorizationActions for the subtree rooted at this node (inclusive).
 void setBranchHidden(PermissionNode startingPoint)
          Set the subtree rooted at this node as hidden (inclusive).
 void setMarked(PermissionNode entry, boolean markedState)
          (Un)Mark this node.
 java.util.Collection setPermissions(java.util.Collection permissions)
          Set the permissions on the node containing each permission's resource.
 void setShowHidden(boolean showHidden)
          Determines whether methods in this class return hidden nodes in results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionDataNodeTreeViewImpl

public PermissionDataNodeTreeViewImpl(PermissionNode root)
Construct a PermissionDataNode.

Method Detail

assertPermissionDataNode

protected PermissionDataNodeImpl assertPermissionDataNode(PermissionNode node)
Perform safe runtime casts.

Parameters:
node - The node to check.
Returns:
The safley cast node.

setShowHidden

public void setShowHidden(boolean showHidden)
Determines whether methods in this class return hidden nodes in results. The state can be toggled on or off as needed. The default is false (don't show hidden nodes).

Specified by:
setShowHidden in interface PermissionTreeView
Parameters:
showHidden - If true, hidden nodes will be returned in results, if false, they will not.

hideAllSystemNodes

public void hideAllSystemNodes()
Hide all nodes whose resource name starts with "System".

Specified by:
hideAllSystemNodes in interface PermissionDataNodeTreeView

setMarked

public void setMarked(PermissionNode entry,
                      boolean markedState)
(Un)Mark this node.

Specified by:
setMarked in interface PermissionTreeView
Parameters:
entry - The node to mark or unmark.
markedState - If true, the node will be marked, if false, the node will be unmarked.

iterator

public java.util.Iterator iterator(PermissionNode startingPoint)
Obtain a depth-first Iterator starting at the given node.

Specified by:
iterator in interface PermissionTreeView
Returns:
The iterator.

iterator

public java.util.Iterator iterator()
Obtain a depth-first Iterator over the whole tree starting at the root.

Specified by:
iterator in interface PermissionTreeView
Returns:
The iterator.

breadthFirstIterator

public java.util.Iterator breadthFirstIterator(PermissionNode startingPoint)
Obtain a breadth-first Iterator starting at the given node.

Specified by:
breadthFirstIterator in interface PermissionTreeView
Returns:
The iterator.

breadthFirstIterator

public java.util.Iterator breadthFirstIterator()
Obtain a breadth-first Iterator over the whole tree starting at the root.

Specified by:
breadthFirstIterator in interface PermissionTreeView
Returns:
The iterator.

getRoot

public PermissionNode getRoot()
Obtain the root PermissionDataNode of the tree. The root of this tree is always hidden but will always be returned even if the state of showHidden is false.

Specified by:
getRoot in interface PermissionTreeView
Returns:
The root of the tree.

getRoots

public java.util.List getRoots()
Obtain a list of PermissionDataNodes which are the children of the root. These nodes are the real roots of the tree, since the root is just a placeholder that holds the real roots.

Specified by:
getRoots in interface PermissionTreeView
Returns:
The list of PermissionDataNodes that are the roots of the forest.

getParent

public PermissionNode getParent(PermissionNode node)
Determine the parent PermissionDataNode for the specified entry, or null if the specified entry is a root.

Specified by:
getParent in interface PermissionTreeView
Parameters:
node - the PermissionDataNode instance for which the parent is to be obtained; may not be null
Returns:
the parent entry, or null if there is no parent

getChildren

public java.util.List getChildren(PermissionNode parent)
Obtain the set of entries that are considered the children of the specified PermissionDataNode.

Specified by:
getChildren in interface PermissionTreeView
Parameters:
parent - the PermissionDataNode instance for which the child entries are to be obtained; may not be null
Returns:
The list of PermissionDataNode instances that are considered the children of the specified entry; never null but possibly empty

isAncestorOf

public boolean isAncestorOf(PermissionNode ancestor,
                            PermissionNode descendant)
Determine whether the given descendant is a descendant of the given ancestor.

This method will check all ancesters of the descendant, even if they are marked hidden.

Parameters:
ancestor - The node to check to see if it is an ancestor of the descendant.
descendant - The node to check to see if it is a descendant ancestor.
Returns:
true if ancestor is the ancestor of descendant.

isDescendantOf

public boolean isDescendantOf(PermissionNode ancestor,
                              PermissionNode descendant)
Determine whether the given descendant is a descendant of the given ancestor.

This method will check all descendants of the ancester, even if they are marked hidden.

Specified by:
isDescendantOf in interface PermissionTreeView
Parameters:
ancestor - The node to check to see if it is an ancestor of the descendant.
descendant - The node to check to see if it is a descendant ancestor.
Returns:
true if ancestor is the ancestor of descendant.

setBranchAllowedActions

public void setBranchAllowedActions(PermissionNode startingPoint,
                                    AuthorizationActions actions)
Set the allowed AuthorizationActions for the subtree rooted at this node (inclusive).

Parameters:
entry - The node to mark or unmark.
actions - The actions to allow on this node and its descendants.

setBranchHidden

public void setBranchHidden(PermissionNode startingPoint)
Set the subtree rooted at this node as hidden (inclusive).

Specified by:
setBranchHidden in interface PermissionTreeView
Parameters:
entry - The node to mark or unmark.
See Also:
setShowHidden

resetTree

public void resetTree()
Reset all tree nodes to their original AuthorizationActions values.

Specified by:
resetTree in interface PermissionTreeView

getMarked

public java.util.Set getMarked()
Obtain all the marked PermissionDataNodes in the tree. Note that the nodes are not nessesarily in tree form. They are just a collection of nodes.

This method will get hidden nodes if showHidden == true.

Specified by:
getMarked in interface PermissionTreeView
Returns:
The Set of all marked nodes in the tree.

getMarkedDescendants

public java.util.Set getMarkedDescendants(PermissionNode startingPoint)
Obtain all the marked PermissionDataNodes in the tree under the given node. Note that the nodes are not nessesarily in tree form. They are just a collection of nodes.

This method will get hidden nodes if showHidden == true.

Specified by:
getMarkedDescendants in interface PermissionTreeView
Returns:
The Set of all marked nodes in the tree below startingPoint.

getDescendants

public java.util.List getDescendants(PermissionNode startingPoint)
Obtain all the PermissionDataNodes in the tree under the given node. Note that the nodes are not nessesarily in tree form. They are just a collection of nodes.

This method will get hidden nodes if showHidden == true.

Specified by:
getDescendants in interface PermissionTreeView
Parameters:
startingPoint - The point in the tree to start the search for descendants.
Returns:
The List of all nodes in the tree below startingPoint.

getDescendantsWithActions

public java.util.List getDescendantsWithActions(PermissionNode startingPoint,
                                                AuthorizationActions actions,
                                                boolean strict)
Obtain all the PermissionDataNodes in the tree under the given node. Note that the nodes are not nessesarily in tree form. They are just a collection of nodes.

This method will get hidden nodes if showHidden == true.

Parameters:
startingPoint - The point in the tree to start the search for descendants.
actions - Get only those descendants that possess the given AuthorizationActions.
strict - If true, get only those descendants with actions equal to the given actions.
Returns:
The List of all nodes in the tree below startingPoint that possess the given actions.

getModified

public java.util.List getModified()
Obtain all the modified PermissionDataNodes in the tree.

This method will get hidden nodes if showHidden == true.

Specified by:
getModified in interface PermissionTreeView
Returns:
The List of all modified nodes in the tree.

getModifiedBreadthFirst

public java.util.List getModifiedBreadthFirst()
Obtain the modified PermissionDataNodes closest to the root in the tree.

This method will get hidden nodes if showHidden == true.

Specified by:
getModifiedBreadthFirst in interface PermissionTreeView
Returns:
The List of all top level modified nodes in the tree.

getModifiedDescendants

public java.util.List getModifiedDescendants(PermissionNode startingPoint)
Obtain all the modified PermissionDataNodes in the tree under the given node. Note that the nodes are not nessesarily in tree form.

This method will get hidden nodes if showHidden == true.

Specified by:
getModifiedDescendants in interface PermissionTreeView
Returns:
The List of all modified nodes in the tree below startingPoint.

getUnModifiedDescendants

public java.util.List getUnModifiedDescendants(PermissionNode startingPoint)
Obtain all the unmodified PermissionDataNodes in the tree under the given node. Note that the nodes are not nessesarily in tree form.

This method will get hidden nodes if showHidden == true.

Specified by:
getUnModifiedDescendants in interface PermissionTreeView
Returns:
The List of all unmodified nodes in the tree below startingPoint.

allDescendantsShareActions

public boolean allDescendantsShareActions(PermissionNode startingPoint)
Determine whether all descendants of the given node share the exact same actions as the given node. This determination is independant of the state of showHidden.

Specified by:
allDescendantsShareActions in interface PermissionDataNodeTreeView
Parameters:
startingPoint - The root of the subtree to check.

setPermissions

public java.util.Collection setPermissions(java.util.Collection permissions)
Set the permissions on the node containing each permission's resource.

Specified by:
setPermissions in interface PermissionDataNodeTreeView
Parameters:
permissions - The Collection of BasicAuthorizationPermissions to set (each contains the the resource and an AuthorizationAction.)
Returns:
The Collection of DataNodeExceptionss each containing a resource name that was not found in the tree.


Copyright © 2009. All Rights Reserved.