jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Rinner <ste...@collettiva.com>
Subject corrupted paths after moving nodes
Date Fri, 29 Jun 2007 14:57:25 GMT

we just found a bug which corrupts the results of Node.getPath() - it  
seems to be related to older Jackrabbit bugs (e.g. JCR-768) but still  
happens in jackrabbit 1.3 and jackrabbit-1.4-SNAPSHOT

Basically we have a node with 3 subnodes (a, b, c), we move all of  
them to index 1 - this works fine, unless we call getPath() of the  
third Node before moving it.

The expected paths after moving would be:
a: /pages[37]/page/element[3]
b: /pages[37]/page/element[2]
c: /pages[37]/page/element

But we get these paths:

a: /pages[37]/page/element[3]
b: /pages[37]/page/element
c: /pages[37]/page/element

This is our testcase:

import org.apache.jackrabbit.core.TransientRepository;

import javax.jcr.*;
import java.io.IOException;

public class JackrabbitPathProb {
     private static final String PATH_TO_REPOSITORY_XML = "testrepo/ 
     private static final String PATH_TO_REPO = "testrepo";
     private Node a;
     private Node b;
     private Node c;
     private Node pages;

     public JackrabbitPathProb() throws IOException,  
RepositoryException {
         TransientRepository repository = new TransientRepository 
         Session session = repository.login(new SimpleCredentials 
("username", "password".toCharArray()), null);

         String pageNT = "nt:unstructured";
         String textElementNT = "nt:unstructured";

         Node rootNode = session.getRootNode();
         pages = rootNode.addNode("pages");
         Node page = pages.addNode("page", pageNT);
         a = page.addNode("element", textElementNT);
         b = page.addNode("element", textElementNT);
         c = page.addNode("element", textElementNT);


     public void moveAndBreak() throws RepositoryException {
         a.getParent().orderBefore("element[" + a.getIndex() + "]",  
         b.getParent().orderBefore("element[" + b.getIndex() + "]",  

         //this call has side effects and breaks the repo
         //when this line is removed the paths are correct

         c.getParent().orderBefore("element[" + c.getIndex() + "]",  

         System.out.println("a: " + a.getPath());
         System.out.println("b: " + b.getPath());
         System.out.println("c: " + c.getPath());


     public static void main(String[] args) throws IOException,  
RepositoryException {
         new JackrabbitPathProb().moveAndBreak();

sincerely yours


Mag. (FH), Stefan Rinner
System One
Gesellschaft f├╝r technologiegest├╝tzte
Kommunikationsprozesse m.b.H.
Stiftgasse 6/2/6
1070 Wien, Austria
t: +43 (0)5 0705 - 0

Find out how System One can work for you, watch our Screencast:

View raw message