Hi, On 2/28/07, Marcel Reutegger <[EMAIL PROTECTED]> wrote:
please note that getParent() may also throw an access denied exception, in case the session does not have sufficient access rights for an ancestor. however getDepth() should still succeed in that case.
Hmm, good point. I think it's a valid option to let getDepth() throw a RepositoryException (by just passing through the AccessDeniedException) to indicate that the depth of the item can not be calculcated in such cases.
iirc the same also applies to getAncestor(int depth).
And Item.getPath(). In fact, I'd argue that if getPath() is allowed to return the path of an item, then there is no good reason to prevent getParent() since the getPath() call already discloses more information about the parent node than what getParent() without any other method calls (which would of course be access controlled) does.
> + public int getDepth() throws RepositoryException { > + try { > + return getParent().getDepth() + 1; > + } catch (ItemNotFoundException e) { > + return 0; > + } > + }
BR, Jukka Zitting