Hi

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/ repository.xml";
    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 (PATH_TO_REPOSITORY_XML, PATH_TO_REPO); 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");
        rootNode.save();
        Node page = pages.addNode("page", pageNT);
        a = page.addNode("element", textElementNT);
        b = page.addNode("element", textElementNT);
        c = page.addNode("element", textElementNT);
        pages.save();

    }

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

        //this call has side effects and breaks the repo
        //when this line is removed the paths are correct
        pages.getNode("page/element[1]");

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

        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

stefan


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
[EMAIL PROTECTED]
http://www.systemone.at

Find out how System One can work for you, watch our Screencast:
http://www.systemone.at/en/technology/overview


Reply via email to