Hi Michael,<div>yes I think my suggestion to correct the method implementation was a bad one, because some realms might rely on the behaviour as it is now.</div><div><br></div><div>Regarding the javadoc, it not clear to me what this means:</div>
<div>"<span class="Apple-style-span" style="color: rgb(79, 118, 203); font-family: Monaco; font-size: 11px; ">     * Creates a new node and adds it as a direct child to this node.</span><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: #4f76cb}
span.s1 {color: #90afcb}
</style>
<p class="p1">     * <span class="s1">@param</span> name name of the child node</p>"</div><div><br></div><div>because my node with path "/vouchers/node.xml" is a direct child to the ROOT node, so I would expect that it gets stored as child of root, but it doesn't (--> "//" ).</div>
<div><br></div><div>So I would update the javadoc with something like:</div><div><br></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; color: #4f76cb}
span.s1 {color: #90afcb}
</style>


<p class="p1">     * Creates a new node and adds it as a direct relative child to the current node.</p>
<p class="p1">     * <span class="s1">@param</span> name Relative path of the child node (e.g. if current node has a path like /data/images , the relative path could be "1970/abc.xml" -> The method will create a new node with path /data/images/1970/abc.xml</p>
</div><div><br></div><div>Cheers</div><div>Balz</div><div><br><div class="gmail_quote">On Tue, Apr 12, 2011 at 11:18 AM, Michael Wechner <span dir="ltr"><<a href="mailto:michael.wechner@wyona.com">michael.wechner@wyona.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

  
    
  
  <div text="#000000" bgcolor="#ffffff">
    Hi Balz<br>
    <br>
    It seems to me that the Javadoc of <br>
    <br>
    src/core/java/org/wyona/yarep/core/Node.java#addNode(String, int)<br>
    <br>
    is pretty clear or please feel free to suggest a better wording.<br>
    <br>
    Re the Virtual Filesystem implementation I would suggest that we
    check the name for slashes<br>
    and throw an exception such that it is clear that one should not use
    the method (1) like this.<br>
    <br>
    WDYT?<br>
    <br>
    Thanks<br><font color="#888888">
    <br>
    Michael</font><div><div></div><div class="h5"><br>
    <br>
    On 4/11/11 9:32 AM, Balz Schreier wrote:
    <blockquote type="cite">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 style="color:rgb(77, 144, 114);font-family:Monaco;font-size:11px">repo.getRootNode().addNode(yarepPath,
          NodeType.RESOURCE);</span></div>
      
      
      
      
      
      
      <div><br>
      </div>
      <div>2) <span style="color:rgb(77, 144, 114);font-family:Monaco;font-size:11px">YarepUtil.addNodes(repo,
          yarepPath, NodeType.<span>RESOURCE</span>);</span></div>
      
      
      
      
      
      
      <div><br>
      </div>
      <div>of course, yarepPath = "/vouchers/thisisanidstring.xml" in
        both scenarios.</div>
      
      <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>
        
        
        
        
        
        
        <p>    <span>/**</span></p>
        <p>     * <span>@see</span>
          org.wyona.yarep.core.Node#addNode(java.lang.String, int)</p>
        <p>     */</p>
        <p>    <span>public</span> Node
          addNode(String name, <span>int</span> type) <span>throws</span> RepositoryException {</p>
        <p>        String newPath = getPath() + <span>"/"</span> + name;</p>
        <p>        <span>if</span>
          (getPath().endsWith(<span>"/"</span>)) {</p>
        <p>            newPath = getPath() + name;</p>
        <p>        }</p>
      </div>
      <div><br>
      </div>
      <div>Corrected code would be:</div>
      <div>
        
        
        
        
        
        
        <p>        String newPath = <span>null</span>;</p>
        <p>        <span>if</span>
          (name.startsWith(<span>"/"</span>)) {</p>
        <p>            name = name.substring(1);</p>
        <p>        }</p>
        <p>        <span>if</span>
          (getPath().endsWith(<span>"/"</span>)) {</p>
        <p>            newPath = getPath() + name;</p>
        <p>        } <span>else</span> {</p>
        <p>            newPath = getPath() + <span>"/"</span> + name;</p>
        <p>        }</p>
        <p>        </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>
      
      
    </blockquote>
    <br>
  </div></div></div>

<br>--<br>
Yanel-development mailing list <a href="mailto:Yanel-development@wyona.com">Yanel-development@wyona.com</a><br>
<a href="http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development" target="_blank">http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development</a><br></blockquote></div><br></div>