Hi,<div><br></div><div>I have detected the following (at least for me) unexpected behaviour and it should get corrected, the fix is very easy, so I don't send a patch for this.</div><div><br></div><div><b>Use Case:</b></div>
<div>You have prepared a Yarep path (e.g. "/vouchers/thisisanidstring.xml"), and you want to add this node now to a repository.</div><div><br></div><div><b>Solution:</b></div><div>there are two ways in Yanel how to do that:</div>
<div>1) <span class="Apple-style-span" style="color: rgb(77, 144, 114); font-family: Monaco; font-size: 11px; ">repo.getRootNode().addNode(yarepPath, NodeType.RESOURCE);</span></div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4d9072}
</style>


<div><br></div><div>2) <span class="Apple-style-span" style="color: rgb(77, 144, 114); font-family: Monaco; font-size: 11px; ">YarepUtil.addNodes(repo, yarepPath, NodeType.<span class="s1">RESOURCE</span>);</span></div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
span.s1 {color: #0027cc}
</style>


<div><br></div><div>of course, yarepPath = "/vouchers/thisisanidstring.xml" in both scenarios.</div><meta charset="utf-8"><div><br></div><div>Unexpected result:</div><div>1) Does store the new node under "//vouchers/thisisanidstring.xml", starting with a double slash!! --> Index also contains then that path</div>
<div>2) Correct, stores node under "/vouchers/thisisanidstring.xml"</div><div><br></div><div><br></div><div><b>How to fix it:</b></div><div><br></div><div>Class VirtualFileSystemNode:</div><div><br></div><div>Currently this code looks like this:</div>
<div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4f76cb}
span.s1 {color: #4f76cb}
span.s2 {color: #90afcb}
span.s3 {color: #931a68}
span.s4 {color: #3834ff}
</style>


<p class="p1">    <span class="s1">/**</span></p>
<p class="p2">     * <span class="s2">@see</span> org.wyona.yarep.core.Node#addNode(java.lang.String, int)</p>
<p class="p2">     */</p>
<p class="p1">    <span class="s3">public</span> Node addNode(String name, <span class="s3">int</span> type) <span class="s3">throws</span> RepositoryException {</p>
<p class="p1">        String newPath = getPath() + <span class="s4">"/"</span> + name;</p>
<p class="p1">        <span class="s3">if</span> (getPath().endsWith(<span class="s4">"/"</span>)) {</p>
<p class="p1">            newPath = getPath() + name;</p>
<p class="p1">        }</p></div><div><br></div><div>Corrected code would be:</div><div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px}
span.s1 {color: #931a68}
span.s2 {color: #3834ff}
</style>


<p class="p1">        String newPath = <span class="s1">null</span>;</p>
<p class="p1">        <span class="s1">if</span> (name.startsWith(<span class="s2">"/"</span>)) {</p>
<p class="p1">            name = name.substring(1);</p>
<p class="p1">        }</p>
<p class="p1">        <span class="s1">if</span> (getPath().endsWith(<span class="s2">"/"</span>)) {</p>
<p class="p1">            newPath = getPath() + name;</p>
<p class="p1">        } <span class="s1">else</span> {</p>
<p class="p1">            newPath = getPath() + <span class="s2">"/"</span> + name;</p>
<p class="p1">        }</p>
<p class="p2">        </p></div><div><br></div><div>Alternative:</div><div>If you think that this should not get fixed, I would add a clear Javadoc saying that the "String name" parameter MUST BE RELATIVE.</div>
<div><br></div><div>What do you think?</div><div>Cheers</div><div>Balz</div><meta charset="utf-8"><meta charset="utf-8">