You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by Michael Dürig <md...@apache.org> on 2012/11/22 10:25:53 UTC
Re: svn commit: r1406225 [1/2] - in /jackrabbit/oak/trunk: oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/
oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/
oak...
On 6.11.12 18:12, angela@apache.org wrote:
> + @Nonnull
> + public NodeUtil getOrAddTree(String relativePath, String primaryTypeName) {
> + if (relativePath.indexOf('/') == -1) {
> + return getOrAddChild(relativePath, primaryTypeName);
> + } else {
> + TreeLocation location = LocationUtil.getTreeLocation(tree.getLocation(), relativePath);
> + if (location.getTree() == null) {
> + NodeUtil target = this;
> + for (String segment : Text.explode(relativePath, '/')) {
> + if (PathUtils.denotesCurrent(segment)) {
> + continue;
> + } else if (PathUtils.denotesParent(segment)) {
> + target = target.getParent();
> + } else if (target.hasChild(segment)) {
> + target = target.getChild(segment);
> + } else {
> + target = target.addChild(segment, primaryTypeName);
> + }
> + }
> + return target;
> + } else {
> + return new NodeUtil(location.getTree());
> + }
> + }
> + }
rootNode.getOrAddTree("a/b/../../c/d/../../e/f", "");
adds the three sub trees /a/b, /c/d and /e/f. Is this really the
intended behaviour?
Michael
Re: svn commit: r1406225 [1/2] - in /jackrabbit/oak/trunk: oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/
oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/...
Posted by Michael Dürig <md...@apache.org>.
On 27.11.12 15:12, Angela Schreiber wrote:
> hi michael
>
>> rootNode.getOrAddTree("a/b/../../c/d/../../e/f", "");
>>
>> adds the three sub trees /a/b, /c/d and /e/f. Is this really the
>> intended behaviour?
>
> yes... see als JcrUtil in jackrabbit-commons.
Ok, I created JCR-3465. If this is intended the Javadoc should at least
clearly state so.
However, AFAICT Node.getNode("a/b/../../c/d/../../e/f") is equal to
Node.getNode("e/f"). So I don't see why the methods in JCRUtil should
interpret path parameters any different.
Michael
>
> kind regards
> angela
Re: svn commit: r1406225 [1/2] - in /jackrabbit/oak/trunk: oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/
oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/...
Posted by Angela Schreiber <an...@adobe.com>.
hi michael
> rootNode.getOrAddTree("a/b/../../c/d/../../e/f", "");
>
> adds the three sub trees /a/b, /c/d and /e/f. Is this really the
> intended behaviour?
yes... see als JcrUtil in jackrabbit-commons.
kind regards
angela