do {
nodeID = nodeID.getParentId();
if (nodeID == null) {
SanityCheck.TRACE("Node " + node.getDocument().getDocId() + ":" +
nodeID + " not found.");
throw new BTreeException("Node " + nodeID + " not found.");
}
if (nodeID == NodeId.DOCUMENT_NODE) {
SanityCheck.TRACE("Node " + node.getDocument().getDocId() + ":" +
nodeID + " not found.");
throw new BTreeException("Node " + nodeID + " not found.");
}
final NativeBroker.NodeRef parentRef = new NativeBroker.NodeRef(doc.getDocId(), nodeID);
try {
parentPointer = findValue(parentRef);
} catch (final BTreeException bte) {
LOG.error("report me", bte);
}
} while (parentPointer == KEY_NOT_FOUND);
try {
final NodeProxy parent = new NodeProxy(doc, nodeID, parentPointer);
final EmbeddedXMLStreamReader cursor = broker.getXMLStreamReader(parent, true);
while(cursor.hasNext()) {
final int status = cursor.next();
if (status != XMLStreamReader.END_ELEMENT) {
final NodeId nextId = (NodeId) cursor.getProperty(EmbeddedXMLStreamReader.PROPERTY_NODE_ID);
if (nextId.equals(node.getNodeId())) {
return cursor.getCurrentPosition();
}
}
}
if (LOG.isDebugEnabled())
{LOG.debug("Node " + node.getNodeId() + " could not be found. Giving up. This is usually not an error.");}
return KEY_NOT_FOUND;
} catch (final XMLStreamException e) {
SanityCheck.TRACE("Node " + node.getDocument().getDocId() + ":" + node.getNodeId() + " not found.");
throw new BTreeException("Node " + node.getNodeId() + " not found.");
}
} else {
return pointer;
}
}