jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r779051 - in /jackrabbit/branches/1.5/jackrabbit-core/src: main/java/org/apache/jackrabbit/core/nodetype/virtual/ test/java/org/apache/jackrabbit/core/nodetype/ test/java/org/apache/jackrabbit/core/nodetype/xml/ test/resources/org/apache/ja...
Date Wed, 27 May 2009 08:31:54 GMT
Author: jukka
Date: Wed May 27 08:31:53 2009
New Revision: 779051

URL: http://svn.apache.org/viewvc?rev=779051&view=rev
Log:
1.5: Merged revision 741100 (JCR-1964 and JCR-1969)

Added:
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java
      - copied unchanged from r741100, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/NodeTypesInContentTest.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
      - copied unchanged from r741100, jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/TestAll.java
Modified:
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
    jackrabbit/branches/1.5/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java?rev=779051&r1=779050&r2=779051&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/virtual/VirtualNodeTypeStateProvider.java
Wed May 27 08:31:53 2009
@@ -219,7 +219,16 @@
         pState.setPropertyValue(
                 NameConstants.JCR_REQUIREDTYPE,
                 InternalValue.create(PropertyType.nameFromValue(propDef.getRequiredType()).toUpperCase()));
-        pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, PropertyType.STRING, propDef.getDefaultValues());
+        InternalValue[] defVals = propDef.getDefaultValues();
+        // retrieve the property type from the first default value present with
+        // the property definition. in case no default values are defined,
+        // fallback to PropertyType.STRING in order to avoid creating a property
+        // with type UNDEFINED which is illegal.
+        int defValsType = PropertyType.STRING;
+        if (defVals != null && defVals.length > 0) {
+            defValsType = defVals[0].getType();
+        }
+        pState.setPropertyValues(NameConstants.JCR_DEFAULTVALUES, defValsType, defVals);
         ValueConstraint[] vc = propDef.getValueConstraints();
         InternalValue[] vals = new InternalValue[vc.length];
         for (int i = 0; i < vc.length; i++) {

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java?rev=779051&r1=779050&r2=779051&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
Wed May 27 08:31:53 2009
@@ -51,7 +51,7 @@
 public class TestAll extends TestCase {
 
     /** The dummy test namespace. */
-    private static final String TEST_NAMESPACE = "test-namespace";
+    private static final String TEST_NAMESPACE = "http://www.apache.org/jackrabbit/test";
 
     /** Name of the include test node type definition file. */
     private static final String TEST_NODETYPES =
@@ -486,7 +486,7 @@
         assertEquals("referenceProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("referenceProperty valueConstraints[0]",
-                "test:testType",
+                "nt:base",
                 (def.getValueConstraints())[0].getDefinition());
         assertEquals("referenceProperty defaultValues",
                 0, def.getDefaultValues().length);
@@ -544,7 +544,7 @@
     public void testDefaultTypeNode() {
         NodeDef def = getChildNode("childNodeType", "defaultTypeNode");
         assertEquals("defaultTypeNode defaultPrimaryType",
-                FACTORY.create(TEST_NAMESPACE, "testType"),
+                FACTORY.create(Name.NS_NT_URI, "base"),
                 def.getDefaultPrimaryType());
     }
 
@@ -556,9 +556,9 @@
         Name[] types = def.getRequiredPrimaryTypes();
         Arrays.sort(types);
         assertEquals("requiredTypeNode requiredPrimaryTypes[0]",
-                FACTORY.create(TEST_NAMESPACE, "baseType"), types[0]);
+                FACTORY.create(Name.NS_NT_URI, "base"), types[0]);
         assertEquals("requiredTypeNode requiredPrimaryTypes[1]",
-                FACTORY.create(TEST_NAMESPACE, "testType"), types[1]);
+                FACTORY.create(Name.NS_NT_URI, "unstructured"), types[1]);
     }
 
     /**

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml?rev=779051&r1=779050&r2=779051&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml
Wed May 27 08:31:53 2009
@@ -17,7 +17,7 @@
  * limitations under the License.
  */
  -->
-<nodeTypes xmlns:test="test-namespace"
+<nodeTypes xmlns:test="http://www.apache.org/jackrabbit/test"
            xmlns:nt="http://www.jcp.org/jcr/nt/1.0">
 
   <nodeType name="test:emptyNodeType"
@@ -39,8 +39,13 @@
                  requiredType="undefined" autoCreated="false" mandatory="false"
                  onParentVersion="IGNORE" protected="false" multiple="false"/>
     <propertyDefinition name="test:autoCreatedItem"
-                 requiredType="undefined" autoCreated="true" mandatory="false"
-                 onParentVersion="IGNORE" protected="false" multiple="false"/>
+                 requiredType="String" autoCreated="true" mandatory="false"
+                 onParentVersion="IGNORE" protected="false" multiple="false">
+      <defaultValues>
+        <defaultValue>"defvalue"</defaultValue>
+      </defaultValues>
+    </propertyDefinition>
+
     <propertyDefinition name="test:mandatoryItem"
                  requiredType="undefined" autoCreated="false" mandatory="true"
                  onParentVersion="IGNORE" protected="false" multiple="false"/>
@@ -144,7 +149,7 @@
                  requiredType="Reference" autoCreated="false" mandatory="false"
                  onParentVersion="IGNORE" protected="false" multiple="false">
       <valueConstraints>
-        <valueConstraint>test:testType</valueConstraint>
+        <valueConstraint>nt:base</valueConstraint>
       </valueConstraints>
     </propertyDefinition>
     <propertyDefinition name="test:stringProperty"
@@ -174,7 +179,7 @@
                   autoCreated="false" mandatory="false"
                   onParentVersion="IGNORE" protected="false"/>
     <childNodeDefinition name="test:defaultTypeNode"
-                  defaultPrimaryType="test:testType" sameNameSiblings="false"
+                  defaultPrimaryType="nt:base" sameNameSiblings="false"
                   autoCreated="false" mandatory="false"
                   onParentVersion="IGNORE" protected="false"/>
     <childNodeDefinition name="test:requiredTypeNode"
@@ -182,8 +187,8 @@
                   autoCreated="false" mandatory="false"
                   onParentVersion="IGNORE" protected="false">
       <requiredPrimaryTypes>
-        <requiredPrimaryType>test:baseType</requiredPrimaryType>
-        <requiredPrimaryType>test:testType</requiredPrimaryType>
+        <requiredPrimaryType>nt:base</requiredPrimaryType>
+        <requiredPrimaryType>nt:unstructured</requiredPrimaryType>
       </requiredPrimaryTypes>
     </childNodeDefinition>
   </nodeType>



Mime
View raw message