jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "alban seurat (JIRA)" <j...@apache.org>
Subject [jira] Updated: (JCR-2626) Transaction ChangeLog merge prevent to have modified and deleted reference between 2 nodes
Date Tue, 11 May 2010 09:26:42 GMT

     [ https://issues.apache.org/jira/browse/JCR-2626?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

alban seurat updated JCR-2626:
------------------------------

    Summary: Transaction ChangeLog merge prevent to have modified and deleted reference between
2 nodes  (was: 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
> ------------------------------------------------------------------------------------------
>
>                 Key: JCR-2626
>                 URL: https://issues.apache.org/jira/browse/JCR-2626
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>    Affects Versions: 1.6.1
>         Environment: Windows XP 
>            Reporter: alban seurat
>            Priority: Critical
>         Attachments: merge.patch
>
>
> 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;
>         try {
>             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);
>         node1.addMixin("mix:referenceable");
>         Node node2 = userNode.addNode(node2Name);
>         node2.addMixin("mix:referenceable");
>         node1.setProperty("reference", node2);
>         session.save();
>         session.logout();
>         doOperation(repository);
>     }
>     private static void moveNode(Session xaSession, Node sharedNode, Node node) throws
Exception {
>         Node copyNode = sharedNode.addNode(node.getName());
>         copyNode.addMixin("mix:referenceable");
>         PropertyIterator it = node.getReferences();
>         while (it.hasNext()) {
>             it.nextProperty().setValue(copyNode);
>         }
>         
>         node.remove();
>         xaSession.save();
>         //copyNode.checkin();
>     }
>     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));
>         //xaSession.save();
>         
>         ////////////////////////////////////////////////////////////////
>         // Finally commit this transaction to persist the changes made to xaSession.
>         xaResource.end(xid, XAResource.TMSUCCESS);
>         xaResource.prepare(xid);
>         xaResource.commit(xid, false);
>         xaSession.logout();
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message