You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ch...@apache.org on 2017/06/01 05:09:24 UTC
svn commit: r1797138 - in /jackrabbit/oak/branches/1.6: ./
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/
oak-core/src/test/java/org/apache/jackrabbit/oak/pl...
Author: chetanm
Date: Thu Jun 1 05:09:23 2017
New Revision: 1797138
URL: http://svn.apache.org/viewvc?rev=1797138&view=rev
Log:
OAK-6267 - Version restore fails if restore would not change bundling root but changes bundled nodes
Merging 1796230,1796239,1796278
Modified:
jackrabbit/oak/branches/1.6/ (props changed)
jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java
jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java
jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java
Propchange: jackrabbit/oak/branches/1.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 1 05:09:23 2017
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782966,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783110,1783619,1783720,1783731,1783733,1783738,1783742,1783773,1783855,1783891,1784023,1784034,1784130,1784162,1784251,1784401,1784551,1784574,1784689,1785095,1785108,1785283,1785838,1785919,1785946,1787074,1787145,1787217,1787425,1788378,1788387-1788389,1788850,1789056,1790382,1792463,1792742,1792746,1793088,1793618,1793627,1793644,1795138,1795314,1795330,1795475,1795488,1795491,1795502,1795594,1795613,1795618,1796144,1796274,1796988
+/jackrabbit/oak/trunk:1781068,1781075,1781248,1781386,1781846,1781907,1782000,1782029,1782196,1782447,1782476,1782770,1782945,1782966,1782973,1782990,1783061,1783066,1783089,1783104-1783105,1783110,1783619,1783720,1783731,1783733,1783738,1783742,1783773,1783855,1783891,1784023,1784034,1784130,1784162,1784251,1784401,1784551,1784574,1784689,1785095,1785108,1785283,1785838,1785919,1785946,1787074,1787145,1787217,1787425,1788378,1788387-1788389,1788850,1789056,1790382,1792463,1792742,1792746,1793088,1793618,1793627,1793644,1795138,1795314,1795330,1795475,1795488,1795491,1795502,1795594,1795613,1795618,1796144,1796230,1796239,1796274,1796278,1796988
/jackrabbit/trunk:1345480
Modified: jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java?rev=1797138&r1=1797137&r2=1797138&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java (original)
+++ jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/CommitDiff.java Thu Jun 1 05:09:23 2017
@@ -102,7 +102,7 @@ class CommitDiff implements NodeStateDif
//TODO [bundling] Handle change of primaryType. Current approach would work
//but if bundling was enabled for previous nodetype its "side effect"
//would still impact even though new nodetype does not have bundling enabled
- BundlingHandler child = bundlingHandler.childChanged(name, after);
+ BundlingHandler child = bundlingHandler.childChanged(name, before, after);
return after.compareAgainstBaseState(before,
new CommitDiff(store, commit, child, builder, blobs));
}
Modified: jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java?rev=1797138&r1=1797137&r2=1797138&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java (original)
+++ jackrabbit/oak/branches/1.6/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/bundlor/BundlingHandler.java Thu Jun 1 05:09:23 2017
@@ -126,17 +126,20 @@ public class BundlingHandler {
return new BundlingHandler(registry, childContext, childPath, state);
}
- public BundlingHandler childChanged(String name, NodeState state){
+ public BundlingHandler childChanged(String name, NodeState before, NodeState after){
String childPath = childPath(name);
BundlingContext childContext;
Matcher childMatcher = ctx.matcher.next(name);
if (childMatcher.isMatch()) {
childContext = createChildContext(childMatcher);
} else {
- childContext = getBundlorContext(childPath, state);
+ //Use the before state for looking up bundlor config
+ //as after state may have been recreated all together
+ //and bundlor config might have got lost
+ childContext = getBundlorContext(childPath, before);
}
- return new BundlingHandler(registry, childContext, childPath, state);
+ return new BundlingHandler(registry, childContext, childPath, after);
}
public boolean isBundlingRoot() {
Modified: jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java?rev=1797138&r1=1797137&r2=1797138&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java (original)
+++ jackrabbit/oak/branches/1.6/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/bundlor/DocumentBundlingTest.java Thu Jun 1 05:09:23 2017
@@ -46,6 +46,10 @@ import org.apache.jackrabbit.oak.plugins
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
import org.apache.jackrabbit.oak.spi.commit.CommitInfo;
+import org.apache.jackrabbit.oak.spi.commit.DefaultEditor;
+import org.apache.jackrabbit.oak.spi.commit.Editor;
+import org.apache.jackrabbit.oak.spi.commit.EditorHook;
+import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
import org.apache.jackrabbit.oak.spi.commit.EmptyHook;
import org.apache.jackrabbit.oak.spi.state.AbstractNodeState;
import org.apache.jackrabbit.oak.spi.state.DefaultNodeStateDiff;
@@ -55,6 +59,7 @@ import org.apache.jackrabbit.oak.spi.sta
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -669,6 +674,43 @@ public class DocumentBundlingTest {
}
@Test
+ public void recreatedBundledNode2() throws Exception{
+ NodeBuilder builder = store.getRoot().builder();
+ NodeBuilder fileNode = newNode("nt:file");
+ fileNode.child("jcr:content").setProperty("jcr:data", "foo");
+ builder.child("test").setChildNode("book.jpg", fileNode.getNodeState());
+ merge(builder);
+
+ builder = store.getRoot().builder();
+ builder.child("a");
+ //In this case we recreate the node in CommitHook
+ store.merge(builder, new EditorHook(new EditorProvider() {
+ @Override
+ public Editor getRootEditor(NodeState before, NodeState after,
+ NodeBuilder builder, CommitInfo info) throws CommitFailedException {
+ return new BookRecreatingEditor(builder);
+ }
+ }), CommitInfo.EMPTY);
+ }
+
+ private static class BookRecreatingEditor extends DefaultEditor {
+ final NodeBuilder builder;
+
+ private BookRecreatingEditor(NodeBuilder builder) {
+ this.builder = builder;
+ }
+
+ @Override
+ public void enter(NodeState before, NodeState after) throws CommitFailedException {
+ builder.child("test").remove();
+
+ NodeBuilder book = builder.child("test").child("book.jpg");
+ book.setProperty(JCR_PRIMARYTYPE, "nt:file");
+ book.child("jcr:content");
+ }
+ }
+
+ @Test
public void deleteAndRecreatedBundledNode() throws Exception{
NodeBuilder builder = store.getRoot().builder();
NodeBuilder fileNode = newNode("nt:file");
Modified: jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java?rev=1797138&r1=1797137&r2=1797138&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java (original)
+++ jackrabbit/oak/branches/1.6/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/document/VersionedDocumentBundlingTest.java Thu Jun 1 05:09:23 2017
@@ -27,6 +27,7 @@ import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
+import javax.jcr.version.Version;
import javax.jcr.version.VersionManager;
import org.apache.jackrabbit.JcrConstants;
@@ -49,6 +50,7 @@ import org.apache.jackrabbit.oak.spi.sta
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import static org.apache.jackrabbit.oak.commons.PathUtils.concat;
@@ -115,6 +117,25 @@ public class VersionedDocumentBundlingTe
assertNull(getNodeDocument(concat(versionedPath, "jcr:content")));
}
+ @Test
+ public void restoreVersionedNode() throws Exception{
+ String assetParentPath = "/bundlingtest/par";
+ Node asset = JcrUtils.getOrCreateByPath(assetParentPath + "/foo.png", "oak:Unstructured", "oak:Asset", s, false);
+ Node assetParent = s.getNode(assetParentPath);
+ assetParent.addMixin(JcrConstants.MIX_VERSIONABLE);
+ asset.addNode("jcr:content", "oak:Unstructured");
+ s.save();
+
+ VersionManager vm = s.getWorkspace().getVersionManager();
+ Version version = vm.checkin(assetParentPath);
+ vm.checkout(assetParentPath);
+
+ asset.getNode("jcr:content").setProperty("foo1", "bar1");
+ s.save();
+
+ vm.restore(version, true);
+ }
+
private void configureBundling() throws ParseException, RepositoryException, IOException {
CndImporter.registerNodeTypes(new StringReader(TEST_NODE_TYPE), s);
Node bundlor = JcrUtils.getOrCreateByPath(BundlingConfigHandler.CONFIG_PATH, "oak:Unstructured", s);