jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1509101 - in /jackrabbit/trunk/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/version/ test/java/org/apache/jackrabbit/core/version/
Date Thu, 01 Aug 2013 07:47:04 GMT
Author: jukka
Date: Thu Aug  1 07:47:03 2013
New Revision: 1509101

URL: http://svn.apache.org/r1509101
Log:
JCR-3635: Manually specified jcr:frozenUuid overwriting the one assigned by the VersionManager
when versioning node

Patch and test case by Florin Iordache.

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java?rev=1509101&r1=1509100&r2=1509101&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/version/InternalFrozenNodeImpl.java
Thu Aug  1 07:47:03 2013
@@ -265,7 +265,11 @@ class InternalFrozenNodeImpl extends Int
                 // ignore frozen properties
                 if (!propName.equals(NameConstants.JCR_PRIMARYTYPE)
                         && !propName.equals(NameConstants.JCR_MIXINTYPES)
-                        && !propName.equals(NameConstants.JCR_UUID)) {
+                        && !propName.equals(NameConstants.JCR_UUID)
+                        // JCR-3635: should never occur in normal content...
+                        && !propName.equals(NameConstants.JCR_FROZENPRIMARYTYPE)
+                        && !propName.equals(NameConstants.JCR_FROZENMIXINTYPES)
+                        && !propName.equals(NameConstants.JCR_FROZENUUID)) {
                     node.copyFrom(prop);
                 }
             }

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java?rev=1509101&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java
Thu Aug  1 07:47:03 2013
@@ -0,0 +1,59 @@
+/*
+ * 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.core.version;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * Tests the case when a node already has a manual set JcrConstants.JCR_FROZENUUID property
and is versioned.
+ * The manual set frozenUuid will overwrite the one that is automatically assigned by the
VersionManager, which should not happen
+ */
+public class CopyFrozenUuidTest extends AbstractJCRTest {
+
+    public void testCopyFrozenUuidProperty() throws Exception {
+        Node firstNode = testRootNode.addNode(nodeName1);
+        firstNode.setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
+        firstNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        firstNode.getSession().save();
+
+        // create version for the node
+        Version firstNodeVersion = firstNode.checkin();
+        firstNode.checkout();
+
+        Node secondNode = testRootNode.addNode(nodeName2);
+        secondNode.setPrimaryType(JcrConstants.NT_UNSTRUCTURED);
+        secondNode.addMixin(JcrConstants.MIX_VERSIONABLE);
+        Property firstNodeVersionFrozenUuid = firstNodeVersion.getFrozenNode().getProperty(JcrConstants.JCR_FROZENUUID);
+        secondNode.setProperty(JcrConstants.JCR_FROZENUUID, firstNodeVersionFrozenUuid.getValue());
+        secondNode.getSession().save();
+
+        // create version of the second node
+        Version secondNodeVersion = secondNode.checkin();
+        secondNode.checkout();
+
+        // frozenUuid from the second node version node should not be the same as the one
from the first node version
+        Property secondBodeVersionFrozenUuid = secondNodeVersion.getFrozenNode().getProperty(JcrConstants.JCR_FROZENUUID);
+        assertFalse(JcrConstants.JCR_FROZENUUID + " should not be the same for two different
versions of different nodes! ", 
+                secondBodeVersionFrozenUuid.getValue().equals(firstNodeVersionFrozenUuid.getValue()));
+    }
+
+}

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/CopyFrozenUuidTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java?rev=1509101&r1=1509100&r2=1509101&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/TestAll.java
Thu Aug  1 07:47:03 2013
@@ -33,6 +33,7 @@ public class TestAll extends TestCase {
     public static Test suite() {
         TestSuite suite = new TestSuite("Version tests");
         suite.addTestSuite(CheckinRemoveVersionTest.class);
+        suite.addTestSuite(CopyFrozenUuidTest.class);
         suite.addTestSuite(InternalVersionHistoryImplTest.class);
         suite.addTestSuite(RemoveVersionLabelTest.class);
         suite.addTestSuite(RestoreTest.class);



Mime
View raw message