jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1021757 - in /jackrabbit/trunk: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/
Date Tue, 12 Oct 2010 12:27:22 GMT
Author: angela
Date: Tue Oct 12 12:27:22 2010
New Revision: 1021757

URL: http://svn.apache.org/viewvc?rev=1021757&view=rev
Log:
JCR-2778 : Node.removeMixin fails if the mixin defines a protected child node

Added:
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java
  (with props)
    jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
    jackrabbit/trunk/pom.xml

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java?rev=1021757&r1=1021756&r2=1021757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/RemoveMixinOperation.java
Tue Oct 12 12:27:22 2010
@@ -248,9 +248,8 @@ class RemoveMixinOperation implements Se
             }
 
             for (ChildNodeEntry entry : affectedNodes.keySet()) {
-                NodeState nodeState =
-                    (NodeState) stateMgr.getItemState(entry.getId());
-                NodeImpl node = (NodeImpl) itemMgr.getItem(entry.getId());
+                NodeState nodeState = (NodeState) stateMgr.getItemState(entry.getId());
+                NodeImpl childNode = (NodeImpl) itemMgr.getItem(entry.getId());
                 NodeDefinition oldDef = affectedNodes.get(entry);
 
                 if (oldDef.isProtected()) {
@@ -267,7 +266,7 @@ class RemoveMixinOperation implements Se
                                 entry.getName(),
                                 nodeState.getNodeTypeName());
                     // redefine node
-                    node.onRedefine(newDef.unwrap());
+                    childNode.onRedefine(newDef.unwrap());
                 } catch (ConstraintViolationException cve) {
                     // no suitable definition found for this child node,
                     // remove it

Added: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java?rev=1021757&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java
Tue Oct 12 12:27:22 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.nodetype;
+
+import org.apache.jackrabbit.commons.cnd.CndImporter;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+/**
+ * <code>MixinTest</code>...
+ */
+public class MixinTest extends AbstractJCRTest {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(MixinTest.class);
+
+    /** Name of the cnd nodetype file for import and namespace registration. */
+    private static final String TEST_NODETYPES = "org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd";
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Reader cnd = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES));
+        CndImporter.registerNodeTypes(cnd, superuser);
+        cnd.close();
+    }
+
+    /**
+     * Test for bug JCR-2778
+     *
+     * @throws Exception
+     */
+    public void testMixinRemovedWithProtectedChildNode() throws Exception {
+        testRootNode.addMixin("test:mixinNode_protectedchild");
+        superuser.save();
+
+        // remove the mixin type again
+        testRootNode.removeMixin("test:mixinNode_protectedchild");
+
+        assertFalse(testRootNode.isNodeType("test:mixinNode_protectedchild"));
+        superuser.save();
+        assertFalse(testRootNode.isNodeType("test:mixinNode_protectedchild"));
+    }
+}
\ No newline at end of file

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

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/MixinTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java?rev=1021757&r1=1021756&r2=1021757&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
Tue Oct 12 12:27:22 2010
@@ -36,6 +36,7 @@ public class TestAll extends TestCase {
         TestSuite suite = new TestSuite("org.apache.jackrabbit.core.nodetype tests");
 
         suite.addTestSuite(NodeTypesInContentTest.class);
+        suite.addTestSuite(MixinTest.class);
 
         return suite;
     }

Added: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd?rev=1021757&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
(added)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
Tue Oct 12 12:27:22 2010
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+<test = "http://www.apache.org/jackrabbit/test">
+
+[test:mixinNode_protectedchild] mixin
+  + test:protectedchild (nt:unstructured) = nt:unstructured protected autocreated

Propchange: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_mixin_nodetypes.cnd
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/pom.xml?rev=1021757&r1=1021756&r2=1021757&view=diff
==============================================================================
--- jackrabbit/trunk/pom.xml (original)
+++ jackrabbit/trunk/pom.xml Tue Oct 12 12:27:22 2010
@@ -54,7 +54,7 @@
     <module>jackrabbit-spi2dav</module>
     <module>jackrabbit-jcr2dav</module>
     <module>jackrabbit-jcr-client</module>
-    <module>jackrabbit-standalone</module>
+    <!--module>jackrabbit-standalone</module-->
   </modules>
 
   <scm>



Mime
View raw message