jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roman Puchkovskiy <roman.puchkovs...@blandware.com>
Subject Node.restore in transaction
Date Tue, 06 May 2008 18:46:58 GMT

Hi.

I'm experiencing problems with Node.restore inside transactions. In the
application, I have code like

Version bv = node.getBaseVersion();
node.restore(earlierVersion, true);
node.getVersionHistory().removeVersion(bv.getName()); // this fails

So I just try to remove base version first restoring node to one of previous
versions. But version removal fails saying that it's referenced; the only
reference is this node's "jcr:baseVersion" property which (if I undestand
this correctly) should be reset with second line (restore).

I tryed to write a simplified test case, and I came to one using
springmodules and Jencks for XA transactions. But in this test case it
behaves differently: NPE is thrown when Node.restore() is called from inside
a transaction and is not thrown when no transaction exists.

Main code is following:

        Node root = session.getRootNode();
        Node target = root.addNode(nodeName);
        target.addMixin("mix:versionable");
        root.save();
        
        VersionHistory vh = target.getVersionHistory();
        
        Version v1 = target.checkin();
        
        target.checkout();
        Version v2 = target.checkin();
        
        target.restore(v1.getName(), true);
        
        vh.removeVersion(v2.getName());

Here's the link to maven project with tests:
http://rpuch.narod.ru/test-versions-in-tx.zip
Tests may be run using 'mvn clean test'.

There're three tests: testRemoveVersionNoTx (no transaction, passes),
testRemoveVersionInTx (in transaction, fails),
testRemoveVersionInTxTwoTransactions (almost same, but works in two
transactions: first creates node and makes a version, then does the rest).
Two first tests use code shown above.

Repository configuration is default one (or very close to it), but same is
observed when I use Derby DB everywhere for FSs and PMs.

Can someone help: is my test code just incorrect, or maybe XA config is bad?
-- 
View this message in context: http://www.nabble.com/Node.restore-in-transaction-tp17089810p17089810.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message