public ResourceNode locate(String sessionID,String path,ResourceNode startNode) throws DirectoryNotFoundException {
  if (path == null) {
    return getCurrentNode(sessionID);
  }
 else   if (path.startsWith(PROTOCOL)) {
    path=path.substring(PROTOCOL.length());
  }
 else   if (path.startsWith(ROOT_ELEMENT) && path.length() > ROOT_ELEMENT.length()) {
    startNode=getRootNode();
    path=path.substring(ROOT_ELEMENT.length());
  }
  if (path.equals(CURRENT_ELEMENT))   return getCurrentNode(sessionID);
 else   if (path.equals(ROOT_ELEMENT))   return getRootNode();
  ResourceNode foundNode=null;
  ResourceNode nodeToSearch=startNode;
  String pathElements[]=path.split(PATH_SEPARATOR);
  if (pathElements.length == 0) {
    return getRootNode();
  }
  for (  String element : pathElements) {
    if (element.length() == 0)     continue;
    if (element.equals(PARENT_ELEMENT)) {
      if ((foundNode=nodeToSearch.getParent()) != null) {
        nodeToSearch=nodeToSearch.getParent();
      }
 else {
        throw new DirectoryNotFoundException(String.format("element '%s' not found",path));
      }
    }
 else {
      Map<String,ResourceNode> children=nodeToSearch.getChildren();
      if (element.equals(ANY_ELEMENT)) {
        if (nodeToSearch.getType() == ResourceType.CLUSTER) {
          foundNode=children.get(memberName);
        }
 else         if (children.size() > 0) {
          foundNode=getFirst(children);
        }
 else {
          throw new DirectoryNotFoundException(String.format("the element '%s' of path '%s' resolves to more than one element",element,path));
        }
      }
 else {
        foundNode=children.get(element);
      }
      if (foundNode == null) {
        throw new DirectoryNotFoundException(String.format("element '%s' not found in path '%s' while searching for entry '%s'",element,formatPath(getAbsolutePath(getRootNode(),nodeToSearch,true),true),path));
      }
      nodeToSearch=foundNode;
    }
  }
  return foundNode;
}

public ResourceNode locate ( String sessionID , String path , ResourceNode startNode ) throws DirectoryNotFoundException { if ( path == null ) { return getCurrentNode ( sessionID ) ; } else if ( path . startsWith ( PROTOCOL ) ) { path = path . substring ( PROTOCOL . length ( ) ) ; } else if ( path . startsWith ( ROOT_ELEMENT ) && path . length ( ) > ROOT_ELEMENT . length ( ) ) { startNode = getRootNode ( ) ; path = path . substring ( ROOT_ELEMENT . length ( ) ) ; } if ( path . equals ( CURRENT_ELEMENT ) ) return getCurrentNode ( sessionID ) ; else if ( path . equals ( ROOT_ELEMENT ) ) return getRootNode ( ) ; ResourceNode foundNode = null ; ResourceNode nodeToSearch = startNode ; String pathElements [ ] = path . split ( PATH_SEPARATOR ) ; if ( pathElements . length == 0 ) { return getRootNode ( ) ; } for ( String element : pathElements ) { if ( element . length ( ) == 0 ) continue ; if ( element . equals ( PARENT_ELEMENT ) ) { if ( ( foundNode = nodeToSearch . getParent ( ) ) != null ) { nodeToSearch = nodeToSearch . getParent ( ) ; } else { throw new DirectoryNotFoundException ( String . format ( "element '%s' not found" , path ) ) ; } } else { Map < String , ResourceNode > children = nodeToSearch . getChildren ( ) ; if ( element . equals ( ANY_ELEMENT ) ) { if ( nodeToSearch . getType ( ) == ResourceType . CLUSTER ) { foundNode = children . get ( memberName ) ; } else if ( children . size ( ) > 0 ) { foundNode = getFirst ( children ) ; } else { throw new DirectoryNotFoundException ( String . format ( "the element '%s' of path '%s' resolves to more than one element" , element , path ) ) ; } } else { foundNode = children . get ( element ) ; } if ( foundNode == null ) { throw new DirectoryNotFoundException ( String . format ( "element '%s' not found in path '%s' while searching for entry '%s'" , element , formatPath ( getAbsolutePath ( getRootNode ( ) , nodeToSearch , true ) , true ) , path ) ) ; } nodeToSearch = foundNode ; } } return foundNode ; }
locates a given resource give a path and a starting node .
