jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1521744 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/
Date Wed, 11 Sep 2013 06:30:58 GMT
Author: mreutegg
Date: Wed Sep 11 06:30:58 2013
New Revision: 1521744

URL: http://svn.apache.org/r1521744
Log:
OAK-999: Version creates frozenNode children with orignial NoteType instead of frozenNode

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java?rev=1521744&r1=1521743&r2=1521744&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/version/VersionableState.java
Wed Sep 11 06:30:58 2013
@@ -154,25 +154,32 @@ class VersionableState {
     }
 
     /**
-     * Creates a frozen node under the version and initializes it with the basic
+     * Creates a frozen node and initializes it with the basic
      * frozen properties (jcr:frozenPrimaryType, jcr:frozenMixinTypes and
-     * jcr:frozenUuid) from the given node. The node must be referenceable.
+     * jcr:frozenUuid) from the given node.
      *
      * @return this versionable state.
      */
     private VersionableState initFrozen(NodeBuilder frozen,
-                                        NodeBuilder referenceable) {
+                                        NodeBuilder node) {
         // initialize jcr:frozenNode
         frozen.setProperty(JCR_UUID, IdentifierManager.generateUUID(), Type.STRING);
         frozen.setProperty(JCR_PRIMARYTYPE, NT_FROZENNODE, Type.NAME);
         List<String> mixinTypes;
-        if (referenceable.hasProperty(JCR_MIXINTYPES)) {
-            mixinTypes = Lists.newArrayList(referenceable.getNames(JCR_MIXINTYPES));
+        if (node.hasProperty(JCR_MIXINTYPES)) {
+            mixinTypes = Lists.newArrayList(node.getNames(JCR_MIXINTYPES));
         } else {
             mixinTypes = Collections.emptyList();
         }
-        frozen.setProperty(JCR_FROZENUUID, uuidFromNode(referenceable), Type.STRING);
-        frozen.setProperty(JCR_FROZENPRIMARYTYPE, primaryTypeOf(referenceable), Type.NAME);
+        String id;
+        if (node.hasProperty(JCR_UUID)) {
+            id = uuidFromNode(node);
+        } else {
+            // TODO: use identifier
+            id = "";
+        }
+        frozen.setProperty(JCR_FROZENUUID, id, Type.STRING);
+        frozen.setProperty(JCR_FROZENPRIMARYTYPE, primaryTypeOf(node), Type.NAME);
         if (mixinTypes.isEmpty()) {
             frozen.removeProperty(JCR_FROZENMIXINTYPES);
         } else {
@@ -311,9 +318,10 @@ class VersionableState {
                                           @Nonnull NodeBuilder dest) {
         dest.setProperty(JCR_PRIMARYTYPE,
                 frozen.getName(JCR_FROZENPRIMARYTYPE), Type.NAME);
-        dest.setProperty(JCR_UUID,
-                frozen.getProperty(JCR_FROZENUUID).getValue(Type.STRING),
-                Type.STRING);
+        String id = frozen.getProperty(JCR_FROZENUUID).getValue(Type.STRING);
+        if (id.length() > 0) {
+            dest.setProperty(JCR_UUID, id, Type.STRING);
+        }
         if (frozen.hasProperty(JCR_FROZENMIXINTYPES)) {
             dest.setProperty(JCR_MIXINTYPES,
                     frozen.getNames(JCR_FROZENMIXINTYPES), Type.NAMES);
@@ -483,12 +491,8 @@ class VersionableState {
     private void copy(NodeBuilder src,
                       NodeBuilder dest)
             throws RepositoryException, CommitFailedException {
-        if (isReferenceable(src)) {
-            initFrozen(dest, src);
-            copyProperties(src, dest, OPVForceCopy.INSTANCE, true);
-        } else {
-            copyProperties(src, dest, OPVForceCopy.INSTANCE, false);
-        }
+        initFrozen(dest, src);
+        copyProperties(src, dest, OPVForceCopy.INSTANCE, true);
         for (String name : src.getChildNodeNames()) {
             NodeBuilder child = src.getChildNode(name);
             copy(child, dest.child(name));

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java?rev=1521744&r1=1521743&r2=1521744&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/VersionManagerImpl.java
Wed Sep 11 06:30:58 2013
@@ -422,7 +422,10 @@ public class VersionManagerImpl implemen
             protected void entering(Node node, int level)
                     throws RepositoryException {
                 if (node.isNodeType(NodeType.NT_FROZEN_NODE)) {
-                    uuids.add(node.getProperty(Property.JCR_FROZEN_UUID).getString());
+                    String id = node.getProperty(Property.JCR_FROZEN_UUID).getString();
+                    if (id.length() > 0) {
+                        uuids.add(id);
+                    }
                 } else if (node.isNodeType(NodeType.NT_VERSIONED_CHILD)) {
                     Node history = node.getProperty(
                             Property.JCR_CHILD_VERSION_HISTORY).getNode();

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionTest.java?rev=1521744&r1=1521743&r2=1521744&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/VersionTest.java
Wed Sep 11 06:30:58 2013
@@ -72,4 +72,16 @@ public class VersionTest extends Abstrac
         assertTrue(rows.hasNext());
         assertTrue(rows.nextRow().getNode() instanceof Version);
     }
+
+    public void testFrozenNode() throws RepositoryException {
+        Node n = testRootNode.addNode(nodeName1, testNodeType);
+        n.addMixin(mixVersionable);
+        Node child = n.addNode(nodeName2, ntUnstructured);
+        superuser.save();
+        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
+        vMgr.checkpoint(n.getPath());
+        Version v = vMgr.getBaseVersion(n.getPath());
+        Node frozenChild = v.getFrozenNode().getNode(child.getName());
+        assertEquals(ntFrozenNode, frozenChild.getPrimaryNodeType().getName());
+    }
 }



Mime
View raw message