jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1591723 - in /jackrabbit/oak/trunk/oak-upgrade/src: main/java/org/apache/jackrabbit/oak/upgrade/ test/java/org/apache/jackrabbit/oak/upgrade/
Date Thu, 01 May 2014 18:23:23 GMT
Author: jukka
Date: Thu May  1 18:23:22 2014
New Revision: 1591723

URL: http://svn.apache.org/r1591723
Log:
OAK-1789: Upgraded version history has UUIDs as jcr:frozenUuid of non-referenceable nodes

Correct handling of cases where referenceability is inherited through a parent node type

Modified:
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
    jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
    jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgradeTest.java

Modified: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java?rev=1591723&r1=1591722&r2=1591723&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
(original)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/JackrabbitNodeState.java
Thu May  1 18:23:22 2014
@@ -332,10 +332,12 @@ class JackrabbitNodeState extends Abstra
             }
 
             if (!isReferenceable.apply(frozenPrimary, frozenMixins)) {
-                frozenUuid = PropertyStates.createProperty(
-                        JCR_FROZENUUID,
-                        parent.getString(JCR_FROZENUUID) + "/" + name);
-                properties.put(JCR_FROZENUUID, frozenUuid);
+                String parentFrozenUuid = parent.getString(JCR_FROZENUUID);
+                if (parentFrozenUuid != null) {
+                    frozenUuid = PropertyStates.createProperty(
+                            JCR_FROZENUUID, parentFrozenUuid + "/" + name);
+                    properties.put(JCR_FROZENUUID, frozenUuid);
+                }
             }
         }
     }

Modified: jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java?rev=1591723&r1=1591722&r2=1591723&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
(original)
+++ jackrabbit/oak/trunk/oak-upgrade/src/main/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgrade.java
Thu May  1 18:23:22 2014
@@ -238,7 +238,8 @@ public class RepositoryUpgrade {
         logger.info(
                 "Copying repository content from {} to Oak", config.getHomeDir());
         try {
-            NodeBuilder builder = target.getRoot().builder();
+            NodeState base = target.getRoot();
+            NodeBuilder builder = base.builder();
 
             String workspace =
                     source.getRepositoryConfig().getDefaultWorkspaceName();
@@ -260,6 +261,11 @@ public class RepositoryUpgrade {
             copyNodeTypes(builder, uriToPrefix.inverse());
             copyPrivileges(builder);
 
+            // Triggers compilation of type information, which we need for
+            // the type predicates used by the bulk  copy operations below.
+            new TypeEditorProvider(false).getRootEditor(
+                    base, builder.getNodeState(), builder, null);
+
             NodeState root = builder.getNodeState();
             copyVersionStore(builder, root, uriToPrefix, idxToPrefix);
             copyWorkspace(builder, root, workspace, uriToPrefix, idxToPrefix);

Modified: jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgradeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgradeTest.java?rev=1591723&r1=1591722&r2=1591723&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgradeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-upgrade/src/test/java/org/apache/jackrabbit/oak/upgrade/RepositoryUpgradeTest.java
Thu May  1 18:23:22 2014
@@ -26,6 +26,8 @@ import static org.apache.jackrabbit.JcrC
 import static org.apache.jackrabbit.JcrConstants.JCR_FROZENPRIMARYTYPE;
 import static org.apache.jackrabbit.JcrConstants.JCR_FROZENUUID;
 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 java.io.ByteArrayInputStream;
 import java.io.InputStream;
@@ -104,15 +106,21 @@ public class RepositoryUpgradeTest exten
 
             nodeTypeManager.registerNodeType(template, false);
 
+            template = nodeTypeManager.createNodeTypeTemplate();
+            template.setName("test:referenceable");
+            template.setDeclaredSuperTypeNames(
+                    new String[] {"nt:unstructured", "mix:referenceable"});
+            nodeTypeManager.registerNodeType(template, false);
+
             Node root = session.getRootNode();
 
             Node referenceable =
                 root.addNode("referenceable", "test:unstructured");
             referenceable.addMixin(NodeType.MIX_REFERENCEABLE);
-            Node versionable =
-                root.addNode("versionable", "test:unstructured");
-            versionable.addMixin(NodeType.MIX_VERSIONABLE);
-            versionable.addNode("child", "test:unstructured");
+            Node versionable = root.addNode("versionable", NT_UNSTRUCTURED);
+            versionable.addMixin(MIX_VERSIONABLE);
+            Node child = versionable.addNode("child", "test:referenceable");
+            child.addNode("child2", NT_UNSTRUCTURED);
             session.save();
 
             session.getWorkspace().getVersionManager().checkin("/versionable");
@@ -379,11 +387,15 @@ public class RepositoryUpgradeTest exten
             Node versionable = session.getNode("/versionable");
             assertTrue(versionable.hasNode("child"));
             Node child = versionable.getNode("child");
+            assertTrue(child.hasNode("child2"));
+            Node child2 = child.getNode("child2");
 
             assertFalse(versionable.isCheckedOut());
             assertTrue(versionable.hasProperty(JCR_UUID));
-            assertFalse(versionable.getNode("child").isCheckedOut());
-            assertFalse(versionable.getNode("child").hasProperty(JCR_UUID));
+            assertFalse(child.isCheckedOut());
+            assertTrue(child.hasProperty(JCR_UUID));
+            assertFalse(child2.isCheckedOut());
+            assertFalse(child2.hasProperty(JCR_UUID));
 
             VersionManager manager = session.getWorkspace().getVersionManager();
             Version version = manager.getBaseVersion("/versionable");
@@ -408,6 +420,16 @@ public class RepositoryUpgradeTest exten
                     "OAK-1789",
                     child.getIdentifier(),
                     frozenChild.getProperty(JCR_FROZENUUID).getString());
+
+            Node frozenChild2 = frozenChild.getNode("child2");
+            assertEquals(
+                    child2.getPrimaryNodeType().getName(),
+                    frozenChild2.getProperty(JCR_FROZENPRIMARYTYPE).getString());
+            assertFalse(frozenChild2.hasProperty(JCR_FROZENMIXINTYPES));
+            assertEquals(
+                    "OAK-1789",
+                    child2.getIdentifier(),
+                    frozenChild2.getProperty(JCR_FROZENUUID).getString());
         } finally {
             session.logout();
         }



Mime
View raw message