// if root is common ancestor, corresponding path is same as ours
if (m1.getDepth() == 0) {
// check existence
if (!srcSession.getItemManager().nodeExists(getPrimaryPath())) {
throw new ItemNotFoundException("Node not found: " + this);
} else {
return getPath();
}
}
// get corresponding ancestor
Node m2 = srcSession.getNodeByUUID(m1.getUUID());
// return path of m2, if m1 == n1
if (m1 == this) {
return m2.getPath();
}
String relPath;
try {
Path p = m1.getPrimaryPath().computeRelativePath(getPrimaryPath());
// use prefix mappings of srcSession
relPath = session.getJCRPath(p);
} catch (NameException be) {
// should never get here...
String msg = "internal error: failed to determine relative path";
log.error(msg, be);
throw new RepositoryException(msg, be);
}
if (!m2.hasNode(relPath)) {
throw new ItemNotFoundException();
} else {
return m2.getNode(relPath).getPath();
}
} finally {
if (srcSession != null) {