/** * The procedure which return the path existed in tree. * * @param node is a Node type which represents current node. * @param path a current path * @return the path existed in tree * @throws RepositoryException when some exceptions occurrence. */ public static String getExistPath(Node node, String path) throws RepositoryException { // The following process is added by lampt. int deep = getDepth(path); // In case of path is root path. if (deep == 0) { path = LinkUtils.getAncestorPath(path, 0); } else { Session session = node.getSession(); for (int i = deep; i > 0; i--) { if (session.itemExists(path)) break; path = getParentPath(path); } } return path; }