jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r718255 - in /jackrabbit/branches/1.5: jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/...
Date Mon, 17 Nov 2008 15:09:21 GMT
Author: angela
Date: Mon Nov 17 07:09:21 2008
New Revision: 718255

URL: http://svn.apache.org/viewvc?rev=718255&view=rev
Log:
1.5: Merged revisions 714034 and 718249 (JCR-1857, JCR-1862)

Added:
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/MandatoryItemTest.java
      - copied unchanged from r718249, jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/MandatoryItemTest.java
Modified:
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/TestAll.java
    jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java
    jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/custom_nodetypes.xml
    jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/repositoryStubImpl.properties

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/state/ItemStateValidator.java
Mon Nov 17 07:09:21 2008
@@ -520,7 +520,7 @@
     }
 
     /**
-     * An item state cannot be removed if it is either protected or mandatory.
+     * An item state cannot be removed if it is protected.
      *
      * @param itemState
      * @throws ConstraintViolationException
@@ -535,9 +535,6 @@
             definition = ((PropertyState)itemState).getDefinition();
         }
         checkProtection(definition);
-        if (definition.isMandatory()) {
-            throw new ConstraintViolationException("Cannot remove mandatory item");
-        }
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/xml/SessionImporter.java
Mon Nov 17 07:09:21 2008
@@ -634,7 +634,10 @@
     private void checkIncludesMixReferenceable(Importer.NodeInfo nodeInfo) throws RepositoryException
{
         List l = new ArrayList();
         l.add(nodeInfo.getNodeTypeName());
-        l.addAll(Arrays.asList(nodeInfo.getMixinNames()));
+        Name[] mixinNames = nodeInfo.getMixinNames();
+        if (mixinNames != null && mixinNames.length > 0) {
+            l.addAll(Arrays.asList(nodeInfo.getMixinNames()));
+        }
         if (l.contains(NameConstants.MIX_REFERENCEABLE)) {
             // shortcut
             return;

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/TestAll.java?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/TestAll.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/nodetype/TestAll.java
Mon Nov 17 07:09:21 2008
@@ -30,6 +30,7 @@
 
         suite.addTestSuite(AddMixinTest.class);
         suite.addTestSuite(RemoveMixinTest.class);
+        suite.addTestSuite(MandatoryItemTest.class);
 
         return suite;
     }

Modified: jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/xml/SessionImportTest.java
Mon Nov 17 07:09:21 2008
@@ -16,21 +16,26 @@
  */
 package org.apache.jackrabbit.jcr2spi.xml;
 
-import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.apache.jackrabbit.uuid.UUID;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.AttributesImpl;
 
-import javax.jcr.RepositoryException;
 import javax.jcr.ImportUUIDBehavior;
-import javax.jcr.PropertyType;
-import javax.jcr.Session;
 import javax.jcr.Item;
 import javax.jcr.Property;
-import java.util.List;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.ConstraintViolationException;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * <code>SessionImportTest</code>...
@@ -108,6 +113,73 @@
         superuser.save();
     }
 
+    /**
+     * Test case for issue <a href="https://issues.apache.org/jira/browse/JCR-1857">JCR-1857</href>
+     *
+     * @throws IOException
+     * @throws RepositoryException
+     */
+    public void testEmptyMixins() throws IOException, RepositoryException {
+        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<sv:node xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" +
+                "         xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"\n" +
+                "         xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\"\n" +
+                "         xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"\n" +
+                "         sv:name=\"testnode1\">\n" +
+                "    <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">\n"
+
+                "        <sv:value>nt:unstructured</sv:value>\n" +
+                "    </sv:property>\n" +
+                "    <sv:property sv:name=\"jcr:title\" sv:type=\"String\">\n" +
+                "        <sv:value>Test Node</sv:value>\n" +
+                "    </sv:property>\n" +
+                "    <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">\n" +
+                "        <sv:value>1234</sv:value>\n" +
+                "    </sv:property>\n" +
+                "</sv:node>";
+
+        InputStream in = new ByteArrayInputStream(xml.getBytes());
+        try {
+            superuser.importXML(testRootNode.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+            fail("jcr:uuid cannot be created if mix:referenceable is not part of the effective
nodetype.");
+        } catch (ConstraintViolationException e) {
+            // ok.
+        }
+    }
+
+    /**
+     * Test case for issue <a href="https://issues.apache.org/jira/browse/JCR-1857">JCR-1857</href>
+     *
+     * @throws IOException
+     * @throws RepositoryException
+     */
+    public void testEmptyMixins2() throws IOException, RepositoryException {
+        /*
+        JSR 170: nt:resource includes mix:referenceable
+        TODO: tests needs to be adjusted for JSR 283 (-> define test-property)
+        */
+        String referenceableNt = "nt:resource";
+        /*
+        TODO: retrieve valid jcr:uuid value from test-properties.
+        */
+        String uuid = UUID.randomUUID().toString();
+        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+                "<sv:node xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\"\n" +
+                "         xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\"\n" +
+                "         xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\"\n" +
+                "         xmlns:jcr=\"http://www.jcp.org/jcr/1.0\"\n" +
+                "         sv:name=\"testnode1\">\n" +
+                "    <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\">\n"
+
+                "        <sv:value>" + referenceableNt + "</sv:value>\n" +
+                "    </sv:property>\n" +
+                "    <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\">\n" +
+                "        <sv:value>" + uuid + "</sv:value>\n" +
+                "    </sv:property>\n" +
+                "</sv:node>";
+
+        InputStream in = new ByteArrayInputStream(xml.getBytes());
+        superuser.importXML(testRootNode.getPath(), in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
+    }
+
     private static String getUnknownURI(Session session, String uriHint) throws RepositoryException
{
         String uri = uriHint;
         int index = 0;
@@ -122,7 +194,7 @@
     /**
      * Returns a prefix that is unique among the already registered prefixes.
      *
-     * @param uriHint namespace uri that serves as hint for the prefix generation
+     * @param session
      * @return a unique prefix
      */
     public static String getUniquePrefix(Session session) throws RepositoryException {

Modified: jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/custom_nodetypes.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/custom_nodetypes.xml?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/custom_nodetypes.xml (original)
+++ jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/custom_nodetypes.xml Mon
Nov 17 07:09:21 2008
@@ -242,6 +242,19 @@
     </childNodeDefinition>
   </nodeType>
 
+  <!-- Defines a test nodetype with mandatory non-protected child definitions -->
+  <nodeType name="test:mandatoryChildDefs" isMixin="false" hasOrderableChildNodes="false"
primaryItemName="">
+    <supertypes>
+      <supertype>nt:base</supertype>
+    </supertypes>
+    <propertyDefinition name="mandatoryProp" requiredType="undefined" autoCreated="false"
mandatory="true" onParentVersion="COPY" protected="false" multiple="false"/>
+    <childNodeDefinition name="mandatoryNode" defaultPrimaryType="nt:unstructured" autoCreated="false"
mandatory="true" onParentVersion="COMPUTE" protected="false" sameNameSiblings="false">
+      <requiredPrimaryTypes>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+      </requiredPrimaryTypes>
+    </childNodeDefinition>
+  </nodeType>
+
 
   <!-- ======================================================== -->
   <!-- Node type definitions only required for jackrabbit core  -->

Modified: jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/repositoryStubImpl.properties
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/repositoryStubImpl.properties?rev=718255&r1=718254&r2=718255&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/repositoryStubImpl.properties
(original)
+++ jackrabbit/branches/1.5/jackrabbit-spi2jcr/src/test/resources/repositoryStubImpl.properties
Mon Nov 17 07:09:21 2008
@@ -485,3 +485,6 @@
 javax.jcr.tck.OnParentVersionAbortTest.nodetype=nt:unstructured
 javax.jcr.tck.OnParentVersionIgnoreTest.nodename4=test:ignoreOnParentVersion
 javax.jcr.tck.OnParentVersionIgnoreTest.nodetype=nt:unstructured
+
+# jcr2spi: special nodetype with mandatory non-protected child items
+javax.jcr.tck.MandatoryItemTest.nodetype=test:mandatoryChildDefs



Mime
View raw message