You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2020/12/03 08:54:36 UTC

[GitHub] [jackrabbit-oak] mreutegg opened a new pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

mreutegg opened a new pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r542527343



##########
File path: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/migration/version/VersionCopierTest.java
##########
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.migration.version;
+
+import java.util.UUID;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.core.ImmutableRoot;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier;
+import org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager;
+import org.apache.jackrabbit.oak.plugins.version.ReadWriteVersionManager;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static java.util.Collections.singletonList;
+import static org.apache.jackrabbit.JcrConstants.JCR_FROZENNODE;
+import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
+import static org.apache.jackrabbit.JcrConstants.MIX_VERSIONABLE;
+import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
+import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT;
+import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT_FROZEN_NODE_REFERENCEABLE;
+import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.commit;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class VersionCopierTest {
+
+    @Test
+    public void copyVersionSourceFrozenNodeReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(true));
+        NodeStore target = createStore(false);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionNotReferenceable(target.getRoot(), path);
+    }
+
+    @Test
+    public void copyVersionSourceFrozenNodeNotReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(false));
+        NodeStore target = createStore(false);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionNotReferenceable(target.getRoot(), path);
+    }
+
+    @Test
+    public void copyVersionTargetFrozenNodeReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(true));
+        NodeStore target = createStore(true);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionReferenceable(target.getRoot(), path);
+    }
+
+    @Ignore("VersionCopier does not generate referenceable target nt:frozenNode from source frozen nodes that are not referenceable")

Review comment:
       The initial idea was more like test driven design. Ideally, it would be possible to copy frozen nodes that are not referenceable to a target store that has referenceable frozen nodes and the operation would generate a jcr:uuid property for each frozen node on the target store. This is currently not the case and the test is ignored. It something like a TODO, but I don't consider it a priority.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r542531104



##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/NodeStateCopier.java
##########
@@ -308,6 +316,8 @@ private static NodeBuilder getChildNodeBuilder(@NotNull final NodeBuilder root,
 
         private Set<String> mergePaths = emptySet();
 
+        private boolean referenceableFrozenNodes = true;

Review comment:
       That's exactly the reason why I set the default to true. I was worried there may be code out there using this class without us knowing. Setting it to false by default would then change the behaviour.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#issuecomment-744327016


   @mreutegg I had a 2nd look but no further comments, so other than the previous ones it lgtm.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r542527844



##########
File path: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeStateTest.java
##########
@@ -43,6 +46,7 @@
 import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.createNodeStoreWithContent;
 import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.getNodeState;
 import static org.apache.jackrabbit.oak.plugins.tree.TreeConstants.OAK_CHILD_ORDER;
+import static org.apache.jackrabbit.oak.spi.state.AbstractNodeState.getBoolean;

Review comment:
       Thanks, will fix.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#issuecomment-754468062


   Changes have been committed to SVN.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r537563402



##########
File path: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/migration/version/VersionCopierTest.java
##########
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.migration.version;
+
+import java.util.UUID;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.core.ImmutableRoot;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore;
+import org.apache.jackrabbit.oak.plugins.migration.NodeStateCopier;
+import org.apache.jackrabbit.oak.plugins.version.ReadOnlyVersionManager;
+import org.apache.jackrabbit.oak.plugins.version.ReadWriteVersionManager;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static java.util.Collections.singletonList;
+import static org.apache.jackrabbit.JcrConstants.JCR_FROZENNODE;
+import static org.apache.jackrabbit.JcrConstants.JCR_MIXINTYPES;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.JCR_UUID;
+import static org.apache.jackrabbit.JcrConstants.MIX_VERSIONABLE;
+import static org.apache.jackrabbit.JcrConstants.NT_UNSTRUCTURED;
+import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT;
+import static org.apache.jackrabbit.oak.InitialContentHelper.INITIAL_CONTENT_FROZEN_NODE_REFERENCEABLE;
+import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.commit;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class VersionCopierTest {
+
+    @Test
+    public void copyVersionSourceFrozenNodeReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(true));
+        NodeStore target = createStore(false);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionNotReferenceable(target.getRoot(), path);
+    }
+
+    @Test
+    public void copyVersionSourceFrozenNodeNotReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(false));
+        NodeStore target = createStore(false);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionNotReferenceable(target.getRoot(), path);
+    }
+
+    @Test
+    public void copyVersionTargetFrozenNodeReferenceable() throws Exception {
+        String path = "/foo";
+        NodeStore source = createVersionFor(path, createStore(true));
+        NodeStore target = createStore(true);
+
+        copyContent(source, target, path);
+        copyVersionStorage(source, target);
+        assertVersionReferenceable(target.getRoot(), path);
+    }
+
+    @Ignore("VersionCopier does not generate referenceable target nt:frozenNode from source frozen nodes that are not referenceable")

Review comment:
       It seems if the assertion was inverted (to become `assertVersionNotReferenceable`) this test would succeed and could be included. Would that make sense?

##########
File path: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeStateTest.java
##########
@@ -294,12 +301,25 @@ public void shouldDelegateHasProperty() {
 
     @Test
     public void exists() {
-        final NodeState decorated = wrap("/", rootNodeState, null, of("/content/foo"), null, null);
+        final NodeState decorated = wrap("/", rootNodeState, null, of("/content/foo"), null, null, true);
         assertTrue("/content should exist and be visible", getNodeState(decorated, "/content").exists());
         assertFalse("/content/foo should be hidden", getNodeState(decorated, "/content/foo").exists());
         assertFalse("/nonexisting should not exist", getNodeState(decorated, "/nonexisting").exists());
     }
 
+    @Test
+    public void withoutReferenceableFrozenNode() {
+        final NodeState decorated = wrap("/", rootNodeState, null, of("/content/foo"), null, null, false);

Review comment:
       It looks like this is the only test which uses `referenceableFrozenNodes=false` - while I assume `false` is now (with OAK-9134) the default. So I'm wondering if we shouldn't have more test cases that test `false`? (Ok, afterwards noticed that `VersionCopierTest` has more `false` tests - so that might be sufficient I guess)

##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/NodeStateCopier.java
##########
@@ -308,6 +316,8 @@ private static NodeBuilder getChildNodeBuilder(@NotNull final NodeBuilder root,
 
         private Set<String> mergePaths = emptySet();
 
+        private boolean referenceableFrozenNodes = true;

Review comment:
       Was thinking if this should rather be `false` here - as that's the new default. But haven't checked all implications..

##########
File path: oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeStateTest.java
##########
@@ -43,6 +46,7 @@
 import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.createNodeStoreWithContent;
 import static org.apache.jackrabbit.oak.plugins.migration.NodeStateTestUtils.getNodeState;
 import static org.apache.jackrabbit.oak.plugins.tree.TreeConstants.OAK_CHILD_ORDER;
+import static org.apache.jackrabbit.oak.spi.state.AbstractNodeState.getBoolean;

Review comment:
       unused import?

##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeState.java
##########
@@ -60,6 +66,8 @@
 
     public static final Set<String> NONE = ImmutableSet.of();
 
+    private static final Set<String> JCR_SYSTEM_PATH_PREFIX = ImmutableSet.of("/", "/" + JcrConstants.JCR_SYSTEM);

Review comment:
       IIUC "/" makes "/jcr:system" superfluous - why is "/" in this set, for tests only?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r542492381



##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeState.java
##########
@@ -60,6 +66,8 @@
 
     public static final Set<String> NONE = ImmutableSet.of();
 
+    private static final Set<String> JCR_SYSTEM_PATH_PREFIX = ImmutableSet.of("/", "/" + JcrConstants.JCR_SYSTEM);

Review comment:
       This is indeed incorrect. I was trying to use isDescendantOfAnyPath() when in fact, I needed something like isDescendantOrSelf().




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg closed pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg closed pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #261: OAK-9290: Respect nt:frozenNode definition on upgrade and migration

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #261:
URL: https://github.com/apache/jackrabbit-oak/pull/261#discussion_r542539751



##########
File path: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/migration/FilteringNodeState.java
##########
@@ -60,6 +66,8 @@
 
     public static final Set<String> NONE = ImmutableSet.of();
 
+    private static final Set<String> JCR_SYSTEM_PATH_PREFIX = ImmutableSet.of("/", "/" + JcrConstants.JCR_SYSTEM);

Review comment:
       I simplified this and removed any path check logic. NodeState wrapping is now done whenever the jcr:uuid property of frozen nodes must be hidden. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org