public AbstractJcrNode getNodeByIdentifier( String id ) throws ItemNotFoundException, RepositoryException {
checkLive();
if (NodeKey.isValidFormat(id)) {
// Try the identifier as a node key ...
try {
NodeKey key = new NodeKey(id);
AbstractJcrNode node = node(key, null);
checkPermission(pathSupplierFor(node), ModeShapePermissions.READ);
return node;
} catch (ItemNotFoundException e) {
// continue ...
}
}
// First, we're given a partial key, so look first in this workspace's content ...
NodeKey key = null;
ItemNotFoundException first = null;
try {
// Try as node key identifier ...
key = this.rootNode.key.withId(id);
AbstractJcrNode node = node(key, null);
checkPermission(pathSupplierFor(node), ModeShapePermissions.READ);
return node;
} catch (ItemNotFoundException e) {
// Not found, so capture the exception (which we might use later) and continue ...
first = e;
}
// Next look for it using the same key except with the system workspace part ...
try {
String systemWorkspaceKey = this.repository().systemWorkspaceKey();
key = key.withWorkspaceKey(systemWorkspaceKey);
AbstractJcrNode systemNode = node(key, null);
if (systemNode instanceof JcrVersionHistoryNode) {
// because the version history node has the same key as the original node, we don't want to expose it to clients
// this means that if we got this far, the original hasn't been found, so neither should the version history
throw first;