jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: svn commit: r512695 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons: AbstractItem.java AbstractNode.java AbstractProperty.java
Date Wed, 28 Feb 2007 13:37:38 GMT
Hi Jukka,

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.

iirc the same also applies to getAncestor(int depth).

regards
  marcel

jukka@apache.org wrote:
> Author: jukka
> Date: Wed Feb 28 02:42:13 2007
> New Revision: 512695
> 
> +
> +    /**
> +     * Returns the depth of this item.
> +     * <p>
> +     * Recursively calls the method on the parent node and increments
> +     * the return value to get the depth of this item. Returns zero if
> +     * the parent node is not available (i.e. this is the root node).
> +     *
> +     * @return depth of this item
> +     * @throws RepositoryException if an error occurs
> +     */
> +    public int getDepth() throws RepositoryException {
> +        try {
> +            return getParent().getDepth() + 1;
> +        } catch (ItemNotFoundException e) {
> +            return 0;
> +        }
> +    }
> +
> +}

Mime
View raw message