Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-2626

Transaction ChangeLog merge prevent to have modified and deleted reference between 2 nodes


    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.1, 2.2.1
    • Fix Version/s: None
    • Labels:
    • Environment:
      Windows XP


      I've created a test case to reproduce the issue.

      In short, I have 2 artifacts where one has a reference on the second one. I want to copy/delete the second one and update the reference, save my operation and do a copy/delete of the first artefact afterward.

      Here is the test case

      package com.testjcr;

      import java.io.IOException;
      import java.rmi.NotBoundException;
      import java.rmi.RemoteException;
      import java.rmi.registry.LocateRegistry;
      import java.rmi.registry.Registry;
      import javax.jcr.ItemExistsException;
      import javax.jcr.LoginException;
      import javax.jcr.Node;
      import javax.jcr.NodeIterator;
      import javax.jcr.Property;
      import javax.jcr.PropertyIterator;
      import javax.jcr.Repository;
      import javax.jcr.RepositoryException;
      import javax.jcr.Session;
      import javax.jcr.SimpleCredentials;
      import javax.transaction.xa.XAException;
      import javax.transaction.xa.XAResource;
      import javax.transaction.xa.Xid;
      import org.apache.jackrabbit.api.XASession;
      import org.apache.jackrabbit.core.TransientRepository;
      import org.apache.jackrabbit.rmi.remote.RemoteRepository;
      import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
      import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;


      • Hello world!
        public class App {

      public static final String userNodeName = "User";
      public static final String sharedNodeName = "Shared";

      public static final String node1Name = "Node1";
      public static final String node2Name = "Node2";

      public static void main(String[] args) throws IOException, LoginException, RepositoryException, RemoteException, NotBoundException, XAException, Exception {

      TransientRepository repository = new TransientRepository();

      RemoteAdapterFactory factory = null;

      factory = new ServerAdapterFactory();

      RemoteRepository remote = factory.getRemoteRepository(repository);

      Registry reg;

      { reg = LocateRegistry.createRegistry(2100); }

      catch (RemoteException ex)

      { reg = LocateRegistry.getRegistry(2100); }

      reg.rebind("alban", remote);

      Session session = repository.login(new SimpleCredentials("", "".toCharArray()));

      Node rootNode = session.getRootNode();

      Node userNode = rootNode.addNode(userNodeName);
      Node sharedNode = rootNode.addNode(sharedNodeName);

      Node node1 = userNode.addNode(node1Name);

      Node node2 = userNode.addNode(node2Name);

      node1.setProperty("reference", node2);




      private static void moveNode(Session xaSession, Node sharedNode, Node node) throws Exception {

      Node copyNode = sharedNode.addNode(node.getName());

      PropertyIterator it = node.getReferences();
      while (it.hasNext())

      { it.nextProperty().setValue(copyNode); }




      private static void doOperation(TransientRepository repository) throws Exception {
      XASession xaSession = (XASession) repository.login(new SimpleCredentials("", "".toCharArray()));
      Xid xid = new Xid() {

      public byte[] getBranchQualifier()

      { return new byte[0]; }

      public int getFormatId() { return 0; }

      public byte[] getGlobalTransactionId() { return new byte[0]; }


      XAResource xaResource = xaSession.getXAResource();
      xaResource.start(xid, XAResource.TMNOFLAGS);


      Node rootNode = xaSession.getRootNode();
      Node sharedNode = rootNode.getNode(sharedNodeName);
      Node userNode = rootNode.getNode(userNodeName);

      moveNode(xaSession, sharedNode, userNode.getNode(node2Name));

      moveNode(xaSession, sharedNode, userNode.getNode(node1Name));



      // Finally commit this transaction to persist the changes made to xaSession.
      xaResource.end(xid, XAResource.TMSUCCESS);
      xaResource.commit(xid, false);



        Alban Seurat created issue -
        Alban Seurat made changes -
        Field Original Value New Value
        Attachment merge.patch [ 12444194 ]
        Alban Seurat made changes -
        Summary Merge with transaction prevent to have modified and deleted reference between 2 nodes Transaction ChangeLog merge prevent to have modified and deleted reference between 2 nodes
        Alban Seurat made changes -
        Comment [ A tempory proposed patch which doesn't delete modifiedState when we merge deletedStates of ChangeLog.

        Alban Seurat made changes -
        Attachment merge.patch [ 12444194 ]
        Stefan Guggisberg made changes -
        Priority Critical [ 2 ] Major [ 3 ]
        Component/s transactions [ 11616 ]
        Alban Seurat made changes -
        Attachment transaction.patch [ 12444280 ]
        Alban Seurat made changes -
        Affects Version/s 2.2.1 [ 12315965 ]


          • Assignee:
            Alban Seurat
          • Votes:
            2 Vote for this issue
            2 Start watching this issue


            • Created: