Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
The javadocs for "Item javax.jcr.Item.getAncestor(int depth)" describes the depth argument as:
depth = 0 returns the root node of a workspace. depth = 1 returns the child of the root node along the path to this Item. depth = 2 returns the grandchild of the root node along the path to this Item. And so on to depth = n, where n is the depth of this Item, which returns this Item itself.
However, the org.apache.sling.testing.mock.jcr.AbstractItem#getAncestor implementation is using "ResourceUtil.getParent(getPath(), depth)" which interprets the second argument as:
level = 0 returns the path. level = 1 returns the parent of path, if it exists, null otherwise. level = 2 returns the grandparent of path, if it exists, null otherwise.
Expected:
AbstractItem#getAncestor should resolve the ancestor path as the item depth minus the supplied depth argument.
this.session.getItem(ResourceUtil.getParent(getPath(), getDepth() - depth));
Attachments
Issue Links
- links to