You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Michael Dürig (JIRA)" <ji...@apache.org> on 2012/11/27 17:09:58 UTC
[jira] [Created] (JCR-3465) JcrUtils.getOrCreateByPath() creates a
whole subtree instead of a single branch
Michael Dürig created JCR-3465:
----------------------------------
Summary: JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
Key: JCR-3465
URL: https://issues.apache.org/jira/browse/JCR-3465
Project: Jackrabbit Content Repository
Issue Type: Bug
Reporter: Michael Dürig
Priority: Minor
Given a leaf node n,
JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Bart van der Schans (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506033#comment-13506033 ]
Bart van der Schans commented on JCR-3465:
------------------------------------------
>From the linux/unix perspective:
- if /tmp/b and /tmp/c don't exist and from within /tmp
- mkdir b/../c fails with "No such file or directory"
- mkdir -p b/../c succeeds and created directory b as well as c
So for the getOrCreateByPath() method which resembles the mkdir -p call we could stick to the current behaviour.
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Bart van der Schans (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505404#comment-13505404 ]
Bart van der Schans commented on JCR-3465:
------------------------------------------
Shouldn't it just fail if a/b or c/d doesn't exist?
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505428#comment-13505428 ]
Michael Dürig commented on JCR-3465:
------------------------------------
The current Javadoc for the path parameter says: "relative path to create". So, no it shouldn't fail according to the current contract. Also AFAIU the intention of the function was to have a method to get a node at a certain path without having to worry about non existing nodes on that path since these would just be created.
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506318#comment-13506318 ]
Felix Meschberger commented on JCR-3465:
----------------------------------------
+1 to fixing.
AFAICT from reading the JavaDoc support for "a/b/../../c/d../../e/f" is not implied. In fact I even consider this an unexpected side effect.
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Michael Dürig (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506331#comment-13506331 ]
Michael Dürig commented on JCR-3465:
------------------------------------
+0 for changing this s.t. "a/b/../../c/d../../e/f" has the same effect as "a/b" (this is what Felix means with fixing I guess). However if backward compatibility turns out to be the bigger concern here, we should be more explicit about this case in the Javadoc.
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505811#comment-13505811 ]
Jukka Zitting commented on JCR-3465:
------------------------------------
The current implementation works just as documented: "all non-existent intermediate path elements will be created".
If a/b doesn't exist, then it is questionable whether "a/b/../../c/d/../../e/f" is a valid, resolvable path. From that perspective the getOrCreate contract clearly suggests that also a/b and c/d will get created if they don't already exist.
If we want to change the implementation, we should explicitly also change the contract to include something like: "The given path is syntactically normalized before it gets resolved."
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (JCR-3465) JcrUtils.getOrCreateByPath() creates
a whole subtree instead of a single branch
Posted by "angela (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/JCR-3465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506306#comment-13506306 ]
angela commented on JCR-3465:
-----------------------------
-1 for changing the contract and the implementation as i consider this public API.
apart from that i agree with bart. so, if someone really has a problem with the behavior described
above (which i am not aware of) then i would suggest that we add a second method.
> JcrUtils.getOrCreateByPath() creates a whole subtree instead of a single branch
> -------------------------------------------------------------------------------
>
> Key: JCR-3465
> URL: https://issues.apache.org/jira/browse/JCR-3465
> Project: Jackrabbit Content Repository
> Issue Type: Bug
> Reporter: Michael Dürig
> Priority: Minor
>
> Given a leaf node n,
> JcrUtils.getOrCreateByPath(n, "a/b/../../c/d/../../e/f", false, null, null, true);
> will result in paths a/b, c/d and e/f being added to n where I'd only expect the path e/f.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira