jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r785777 [2/4] - in /jackrabbit/trunk: jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/nodetype/com...
Date Wed, 17 Jun 2009 20:22:09 GMT
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/nodetype/xml/TestAll.java Wed Jun 17 20:21:54 2009
@@ -17,7 +17,6 @@
 package org.apache.jackrabbit.core.nodetype.xml;
 
 import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.core.TestRepository;
@@ -34,6 +33,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
+import org.apache.jackrabbit.test.AbstractJCRTest;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
@@ -50,7 +50,7 @@
 /**
  * Test cases for reading and writing node type definition files.
  */
-public class TestAll extends TestCase {
+public class TestAll extends AbstractJCRTest {
 
     /** The dummy test namespace. */
     private static final String TEST_NAMESPACE = "http://www.apache.org/jackrabbit/test";
@@ -81,6 +81,7 @@
      * @throws Exception on initialization errors
      */
     protected void setUp() throws Exception {
+        super.setUp();
         InputStream xml =
             getClass().getClassLoader().getResourceAsStream(TEST_NODETYPES);
 
@@ -119,7 +120,7 @@
      * @param propertyName property name, or <code>null</code>
      * @return property definition
      */
-    private PropDef getProperty(String typeName, String propertyName) {
+    private PropDef getPropDef(String typeName, String propertyName) {
         Name name;
         if (propertyName != null) {
             name = FACTORY.create(TEST_NAMESPACE, propertyName);
@@ -229,7 +230,7 @@
                 def.getPrimaryItemName());
         assertEquals("itemNodeType propertyDefs",
                 10, def.getPropertyDefs().length);
-        PropDef pdef = getProperty("itemNodeType", null);
+        PropDef pdef = getPropDef("itemNodeType", null);
         assertTrue("itemNodeType wildcard property", pdef.definesResidual());
     }
 
@@ -280,7 +281,7 @@
 
     /** Test for the empty item definition. */
     public void testEmptyItem() {
-        PropDef def = getProperty("itemNodeType", "emptyItem");
+        PropDef def = getPropDef("itemNodeType", "emptyItem");
         assertEquals("emptyItem autoCreate",
                 false, def.isAutoCreated());
         assertEquals("emptyItem mandatory",
@@ -293,56 +294,56 @@
 
     /** Test for the <code>autoCreated</code> item definition attribute. */
     public void testAutoCreateItem() {
-        PropDef def = getProperty("itemNodeType", "autoCreatedItem");
+        PropDef def = getPropDef("itemNodeType", "autoCreatedItem");
         assertEquals("autoCreatedItem autoCreated",
                 true, def.isAutoCreated());
     }
 
     /** Test for the <code>mandatory</code> item definition attribute. */
     public void testMandatoryItem() {
-        PropDef def = getProperty("itemNodeType", "mandatoryItem");
+        PropDef def = getPropDef("itemNodeType", "mandatoryItem");
         assertEquals("mandatoryItem mandatory",
                 true, def.isMandatory());
     }
 
     /** Test for the <code>copy</code> parent version action. */
     public void testCopyItem() {
-        PropDef def = getProperty("itemNodeType", "copyItem");
+        PropDef def = getPropDef("itemNodeType", "copyItem");
         assertEquals("copyItem onParentVersion",
                 OnParentVersionAction.COPY, def.getOnParentVersion());
     }
 
     /** Test for the <code>version</code> parent version action. */
     public void testVersionItem() {
-        PropDef def = getProperty("itemNodeType", "versionItem");
+        PropDef def = getPropDef("itemNodeType", "versionItem");
         assertEquals("versionItem onParentVersion",
                 OnParentVersionAction.VERSION, def.getOnParentVersion());
     }
 
     /** Test for the <code>initialize</code> parent version action. */
     public void testInitializeItem() {
-        PropDef def = getProperty("itemNodeType", "initializeItem");
+        PropDef def = getPropDef("itemNodeType", "initializeItem");
         assertEquals("initializeItem onParentVersion",
                 OnParentVersionAction.INITIALIZE, def.getOnParentVersion());
     }
 
     /** Test for the <code>compute</code> parent version action. */
     public void testComputeItem() {
-        PropDef def = getProperty("itemNodeType", "computeItem");
+        PropDef def = getPropDef("itemNodeType", "computeItem");
         assertEquals("computeItem onParentVersion",
                 OnParentVersionAction.COMPUTE, def.getOnParentVersion());
     }
 
     /** Test for the <code>abort</code> parent version action. */
     public void testAbortItem() {
-        PropDef def = getProperty("itemNodeType", "abortItem");
+        PropDef def = getPropDef("itemNodeType", "abortItem");
         assertEquals("abortItem onParentVersion",
                 OnParentVersionAction.ABORT, def.getOnParentVersion());
     }
 
     /** Test for the <code>protected</code> item definition attribute. */
     public void testProtectedItem() {
-        PropDef def = getProperty("itemNodeType", "protectedItem");
+        PropDef def = getPropDef("itemNodeType", "protectedItem");
         assertEquals("protectedItem protected",
                 true, def.isProtected());
     }
@@ -351,12 +352,12 @@
     public void testPropertyNodeType() {
         NodeTypeDef def = getNodeType("propertyNodeType");
         assertEquals("propertyNodeType propertyDefs",
-                11, def.getPropertyDefs().length);
+                13, def.getPropertyDefs().length);
     }
 
     /** Test for the empty property definition. */
     public void testEmptyProperty() {
-        PropDef def = getProperty("propertyNodeType", "emptyProperty");
+        PropDef def = getPropDef("propertyNodeType", "emptyProperty");
         assertEquals("emptyProperty requiredType",
                 PropertyType.UNDEFINED, def.getRequiredType());
         assertEquals("emptyProperty multiple",
@@ -369,28 +370,28 @@
 
     /** Test for the <code>binary</code> property definition type. */
     public void testBinaryProperty() {
-        PropDef def = getProperty("propertyNodeType", "binaryProperty");
+        PropDef def = getPropDef("propertyNodeType", "binaryProperty");
         assertEquals("binaryProperty requiredType",
                 PropertyType.BINARY, def.getRequiredType());
         assertEquals("binaryProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("binaryProperty valueConstraints[0]",
-                "[0,)", (def.getValueConstraints())[0].getDefinition());
+                "[0,)", (def.getValueConstraints())[0].getString());
         assertEquals("binaryProperty defaultValues",
                 0, def.getDefaultValues().length);
     }
 
     /** Test for the <code>boolean</code> property definition type. */
     public void testBooleanProperty() {
-        PropDef def = getProperty("propertyNodeType", "booleanProperty");
+        PropDef def = getPropDef("propertyNodeType", "booleanProperty");
         assertEquals("booleanProperty requiredType",
                 PropertyType.BOOLEAN, def.getRequiredType());
         assertEquals("booleanProperty valueConstraints",
                 2, def.getValueConstraints().length);
         assertEquals("booleanProperty valueConstraints[0]",
-                "true", (def.getValueConstraints())[0].getDefinition());
+                "true", (def.getValueConstraints())[0].getString());
         assertEquals("booleanProperty valueConstraints[1]",
-                "false", (def.getValueConstraints())[1].getDefinition());
+                "false", (def.getValueConstraints())[1].getString());
         assertEquals("booleanProperty defaultValues",
                 1, def.getDefaultValues().length);
         assertEquals("booleanProperty defaultValues[0]",
@@ -399,14 +400,14 @@
 
     /** Test for the <code>date</code> property definition type. */
     public void testDateProperty() {
-        PropDef def = getProperty("propertyNodeType", "dateProperty");
+        PropDef def = getPropDef("propertyNodeType", "dateProperty");
         assertEquals("dateProperty requiredType",
                 PropertyType.DATE, def.getRequiredType());
         assertEquals("dateProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("dateProperty valueConstraints[0]",
                 "[2005-01-01T00:00:00.000Z,2006-01-01T00:00:00.000Z)",
-                (def.getValueConstraints())[0].getDefinition());
+                (def.getValueConstraints())[0].getString());
         assertEquals("dateProperty defaultValues",
                 1, def.getDefaultValues().length);
         assertEquals("dateProperty defaultValues[0]",
@@ -415,17 +416,17 @@
 
     /** Test for the <code>double</code> property definition type. */
     public void testDoubleProperty() {
-        PropDef def = getProperty("propertyNodeType", "doubleProperty");
+        PropDef def = getPropDef("propertyNodeType", "doubleProperty");
         assertEquals("doubleProperty requiredType",
                 PropertyType.DOUBLE, def.getRequiredType());
         assertEquals("doubleProperty valueConstraints",
                 3, def.getValueConstraints().length);
         assertEquals("doubleProperty valueConstraints[0]",
-                "[,0.0)", (def.getValueConstraints())[0].getDefinition());
+                "[,0.0)", (def.getValueConstraints())[0].getString());
         assertEquals("doubleProperty valueConstraints[1]",
-                "(1.0,2.0)", (def.getValueConstraints())[1].getDefinition());
+                "(1.0,2.0)", (def.getValueConstraints())[1].getString());
         assertEquals("doubleProperty valueConstraints[2]",
-                "(3.0,]", (def.getValueConstraints())[2].getDefinition());
+                "(3.0,]", (def.getValueConstraints())[2].getString());
         assertEquals("doubleProperty defaultValues",
                 1, def.getDefaultValues().length);
         assertEquals("doubleProperty defaultValues[0]",
@@ -434,17 +435,17 @@
 
     /** Test for the <code>long</code> property definition type. */
     public void testLongProperty() {
-        PropDef def = getProperty("propertyNodeType", "longProperty");
+        PropDef def = getPropDef("propertyNodeType", "longProperty");
         assertEquals("longProperty requiredType",
                 PropertyType.LONG, def.getRequiredType());
         assertEquals("longProperty valueConstraints",
                 3, def.getValueConstraints().length);
         assertEquals("longProperty valueConstraints[0]",
-                "(-10,0]", (def.getValueConstraints())[0].getDefinition());
+                "(-10,0]", (def.getValueConstraints())[0].getString());
         assertEquals("longProperty valueConstraints[1]",
-                "[1,2]", (def.getValueConstraints())[1].getDefinition());
+                "[1,2]", (def.getValueConstraints())[1].getString());
         assertEquals("longProperty valueConstraints[2]",
-                "[10,100)", (def.getValueConstraints())[2].getDefinition());
+                "[10,100)", (def.getValueConstraints())[2].getString());
         assertEquals("longProperty defaultValues",
                 1, def.getDefaultValues().length);
         assertEquals("longProperty defaultValues[0]",
@@ -453,14 +454,14 @@
 
     /** Test for the <code>name</code> property definition type. */
     public void testNameProperty() {
-        PropDef def = getProperty("propertyNodeType", "nameProperty");
+        PropDef def = getPropDef("propertyNodeType", "nameProperty");
         assertEquals("nameProperty requiredType",
                 PropertyType.NAME, def.getRequiredType());
         assertEquals("nameProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("nameProperty valueConstraints[0]",
-                "test:testName",
-                (def.getValueConstraints())[0].getDefinition());
+                "{http://www.apache.org/jackrabbit/test}testName",
+                (def.getValueConstraints())[0].getString());
         assertEquals("nameProperty defaultValues",
                 1, def.getDefaultValues().length);
         assertEquals("nameProperty defaultValues[0]",
@@ -469,42 +470,70 @@
 
     /** Test for the <code>path</code> property definition type. */
     public void testPathProperty() {
-        PropDef def = getProperty("propertyNodeType", "pathProperty");
+        PropDef def = getPropDef("propertyNodeType", "pathProperty");
         assertEquals("pathProperty requiredType",
                 PropertyType.PATH, def.getRequiredType());
         assertEquals("pathProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("pathProperty valueConstraints[0]",
-                "/test:testPath",
-                (def.getValueConstraints())[0].getDefinition());
+                "{}\t{http://www.apache.org/jackrabbit/test}testPath",
+                (def.getValueConstraints())[0].getString());
+        assertEquals("pathProperty defaultValues",
+                0, def.getDefaultValues().length);
+    }
+
+    /** Test for the <code>path</code> property definition type. */
+    public void testPathProperty1() {
+        PropDef def = getPropDef("propertyNodeType", "pathProperty1");
+        assertEquals("pathProperty requiredType",
+                PropertyType.PATH, def.getRequiredType());
+        assertEquals("pathProperty valueConstraints",
+                1, def.getValueConstraints().length);
+        assertEquals("pathProperty valueConstraints[0]",
+                "{}\t{http://www.apache.org/jackrabbit/test}testPath\t{}*",
+                (def.getValueConstraints())[0].getString());
+        assertEquals("pathProperty defaultValues",
+                0, def.getDefaultValues().length);
+    }
+
+    /** Test for the <code>path</code> property definition type. */
+    public void testPathProperty2() {
+        PropDef def = getPropDef("propertyNodeType", "pathProperty2");
+        assertEquals("pathProperty requiredType",
+                PropertyType.PATH, def.getRequiredType());
+        assertEquals("pathProperty valueConstraints",
+                1, def.getValueConstraints().length);
+        assertEquals("pathProperty valueConstraints[0]",
+                "{http://www.apache.org/jackrabbit/test}testPath\t{}*",
+                (def.getValueConstraints())[0].getString());
         assertEquals("pathProperty defaultValues",
                 0, def.getDefaultValues().length);
     }
 
     /** Test for the <code>reference</code> property definition type. */
     public void testReferenceProperty() {
-        PropDef def = getProperty("propertyNodeType", "referenceProperty");
+        PropDef def = getPropDef("propertyNodeType", "referenceProperty");
         assertEquals("referenceProperty requiredType",
                 PropertyType.REFERENCE, def.getRequiredType());
         assertEquals("referenceProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("referenceProperty valueConstraints[0]",
-                "nt:base",
-                (def.getValueConstraints())[0].getDefinition());
+                "{http://www.jcp.org/jcr/nt/1.0}base",
+                (def.getValueConstraints())[0].getString());
         assertEquals("referenceProperty defaultValues",
                 0, def.getDefaultValues().length);
     }
 
     /** Test for the <code>string</code> property definition type. */
     public void testStringProperty() {
-        PropDef def = getProperty("propertyNodeType", "stringProperty");
+        PropDef def = getPropDef("propertyNodeType", "stringProperty");
         assertEquals("stringProperty requiredType",
                 PropertyType.STRING, def.getRequiredType());
         assertEquals("stringProperty valueConstraints",
                 1, def.getValueConstraints().length);
         assertEquals("stringProperty valueConstraints[0]",
                 "bananas?",
-                (def.getValueConstraints())[0].getDefinition());
+                (def.getValueConstraints())[0].getString());
         assertEquals("stringProperty defaultValues",
                 2, def.getDefaultValues().length);
         assertEquals("stringProperty defaultValues[0]",
@@ -515,7 +544,7 @@
 
     /** Test for the <code>multiple</code> property definition attribute. */
     public void testMultipleProperty() {
-        PropDef def = getProperty("propertyNodeType", "multipleProperty");
+        PropDef def = getPropDef("propertyNodeType", "multipleProperty");
         assertEquals("multipleProperty multiple",
                 true, def.isMultiple());
     }

Modified: jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/nodetype/xml/test_nodetypes.xml Wed Jun 17 20:21:54 2009
@@ -172,6 +172,22 @@
         <valueConstraint>/test:testPath</valueConstraint>
       </valueConstraints>
     </propertyDefinition>
+    <propertyDefinition name="test:pathProperty1"
+                 requiredType="Path" autoCreated="false" mandatory="false"
+                 isFullTextSearchable="false" isQueryOrderable="true"
+                 onParentVersion="IGNORE" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>/test:testPath/*</valueConstraint>
+      </valueConstraints>
+    </propertyDefinition>
+    <propertyDefinition name="test:pathProperty2"
+                 requiredType="Path" autoCreated="false" mandatory="false"
+                 isFullTextSearchable="false" isQueryOrderable="true"
+                 onParentVersion="IGNORE" protected="false" multiple="false">
+      <valueConstraints>
+        <valueConstraint>test:testPath/*</valueConstraint>
+      </valueConstraints>
+    </propertyDefinition>
     <propertyDefinition name="test:referenceProperty"
                  requiredType="Reference" autoCreated="false" mandatory="false"
                  isFullTextSearchable="false" isQueryOrderable="true"

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/NodeTypeIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/NodeTypeIteratorAdapter.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/NodeTypeIteratorAdapter.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/NodeTypeIteratorAdapter.java Wed Jun 17 20:21:54 2009
@@ -60,7 +60,7 @@
      *
      * @param collection collection of {@link NodeType}s
      */
-    public NodeTypeIteratorAdapter(Collection collection) {
+    public NodeTypeIteratorAdapter(Collection<NodeType> collection) {
         super(new RangeIteratorAdapter(collection));
     }
 

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/DefinitionValidator.java Wed Jun 17 20:21:54 2009
@@ -21,6 +21,7 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
@@ -263,13 +264,13 @@
              * the specified node type must be registered, with one notable
              * exception: the node type just being registered
              */
-            String[] constraints = pd.getValueConstraints();
+            QValueConstraint[] constraints = pd.getValueConstraints();
             if (constraints != null && constraints.length > 0) {
 
                 if (pd.getRequiredType() == PropertyType.REFERENCE) {
-                    for (int j = 0; j < constraints.length; j++) {
+                    for (QValueConstraint constraint : constraints) {
                         // TODO improve. don't rely on a specific factory impl
-                        Name ntName = NameFactoryImpl.getInstance().create(constraints[j]);
+                        Name ntName = NameFactoryImpl.getInstance().create(constraint.getString());
                         /* compare to given ntd map and not registered nts only */
                         if (!name.equals(ntName) && !validatedDefs.containsKey(ntName)) {
                             String msg = "[" + name + "#" + pd.getName()

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/nodetype/NodeTypeRegistryImpl.java Wed Jun 17 20:21:54 2009
@@ -25,6 +25,7 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QItemDefinition;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -806,7 +807,7 @@
                     ps.println("\t\tName\t\t" + (pd[i].definesResidual() ? "*" : pd[i].getName().toString()));
                     String type = pd[i].getRequiredType() == 0 ? "null" : PropertyType.nameFromValue(pd[i].getRequiredType());
                     ps.println("\t\tRequiredType\t" + type);
-                    String[] vca = pd[i].getValueConstraints();
+                    QValueConstraint[] vca = pd[i].getValueConstraints();
                     StringBuffer constraints = new StringBuffer();
                     if (vca == null) {
                         constraints.append("<null>");
@@ -815,7 +816,7 @@
                             if (constraints.length() > 0) {
                                 constraints.append(", ");
                             }
-                            constraints.append(vca[n]);
+                            constraints.append(vca[n].getString());
                         }
                     }
                     ps.println("\t\tValueConstraints\t" + constraints.toString());
@@ -824,14 +825,14 @@
                     if (defVals == null) {
                         defaultValues.append("<null>");
                     } else {
-                        for (int n = 0; n < defVals.length; n++) {
+                        for (QValue defVal : defVals) {
                             if (defaultValues.length() > 0) {
                                 defaultValues.append(", ");
                             }
                             try {
-                                defaultValues.append(defVals[n].getString());
+                                defaultValues.append(defVal.getString());
                             } catch (RepositoryException e) {
-                                defaultValues.append(defVals[n].toString());
+                                defaultValues.append(defVal.toString());
                             }
                         }
                     }
@@ -843,25 +844,25 @@
                     ps.println("\t\tMultiple\t" + pd[i].isMultiple());
                 }
                 QNodeDefinition[] nd = ntd.getChildNodeDefs();
-                for (int i = 0; i < nd.length; i++) {
+                for (QNodeDefinition aNd : nd) {
                     ps.print("\tNodeDefinition");
-                    ps.println(" (declared in " + nd[i].getDeclaringNodeType() + ") ");
-                    ps.println("\t\tName\t\t" + (nd[i].definesResidual() ? "*" : nd[i].getName().toString()));
-                    Name[] reqPrimaryTypes = nd[i].getRequiredPrimaryTypes();
+                    ps.println(" (declared in " + aNd.getDeclaringNodeType() + ") ");
+                    ps.println("\t\tName\t\t" + (aNd.definesResidual() ? "*" : aNd.getName().toString()));
+                    Name[] reqPrimaryTypes = aNd.getRequiredPrimaryTypes();
                     if (reqPrimaryTypes != null && reqPrimaryTypes.length > 0) {
                         for (int n = 0; n < reqPrimaryTypes.length; n++) {
                             ps.print("\t\tRequiredPrimaryType\t" + reqPrimaryTypes[n]);
                         }
                     }
-                    Name defPrimaryType = nd[i].getDefaultPrimaryType();
+                    Name defPrimaryType = aNd.getDefaultPrimaryType();
                     if (defPrimaryType != null) {
                         ps.print("\n\t\tDefaultPrimaryType\t" + defPrimaryType);
                     }
-                    ps.println("\n\t\tAutoCreated\t" + nd[i].isAutoCreated());
-                    ps.println("\t\tMandatory\t" + nd[i].isMandatory());
-                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(nd[i].getOnParentVersion()));
-                    ps.println("\t\tProtected\t" + nd[i].isProtected());
-                    ps.println("\t\tAllowsSameNameSiblings\t" + nd[i].allowsSameNameSiblings());
+                    ps.println("\n\t\tAutoCreated\t" + aNd.isAutoCreated());
+                    ps.println("\t\tMandatory\t" + aNd.isMandatory());
+                    ps.println("\t\tOnVersion\t" + OnParentVersionAction.nameFromValue(aNd.getOnParentVersion()));
+                    ps.println("\t\tProtected\t" + aNd.isProtected());
+                    ps.println("\t\tAllowsSameNameSiblings\t" + aNd.allowsSameNameSiblings());
                 }
             }
         }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/AbstractReadableRepositoryService.java Wed Jun 17 20:21:54 2009
@@ -131,10 +131,8 @@
             this.namespaces.setMapping((String) entry.getKey(),
                     (String) entry.getValue());
         }
-        CompactNodeTypeDefReader reader = new CompactNodeTypeDefReader(
-                cnd, "", this.namespaces, new QNodeTypeDefinitionsBuilderImpl());
-        for (Iterator it = reader.getNodeTypeDefs().iterator(); it.hasNext(); ) {
-            QNodeTypeDefinition def = (QNodeTypeDefinition) it.next();
+        CompactNodeTypeDefReader reader = new CompactNodeTypeDefReader(cnd, "", this.namespaces);
+        for (QNodeTypeDefinition def : reader.getNodeTypeDefinitions()) {
             nodeTypeDefs.put(def.getName(), def);
         }
         this.wspNames = Collections.unmodifiableList(new ArrayList(wspNames));

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QItemDefinitionImpl.java Wed Jun 17 20:21:54 2009
@@ -175,7 +175,7 @@
     /**
      * See {@link QNodeDefinition#hashCode()} and {@link QPropertyDefinition#hashCode()}.
      *
-     * @return
+     * @return the hashcode
      */
     public abstract int hashCode();
 }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeDefinitionImpl.java Wed Jun 17 20:21:54 2009
@@ -65,6 +65,9 @@
      * @param isMandatory       if this is a mandatory item.
      * @param onParentVersion   the on parent version behaviour.
      * @param isProtected       if this item is protected.
+     * @param defaultPrimaryType the default primary type name
+     * @param requiredPrimaryTypes the required primary type name
+     * @param allowsSameNameSiblings if this node allows SNS
      */
     public QNodeDefinitionImpl(Name name, Name declaringNodeType,
                                boolean isAutoCreated, boolean isMandatory,
@@ -139,7 +142,7 @@
     /**
      * Overwrites {@link QItemDefinitionImpl#hashCode()}.
      *
-     * @return
+     * @return the hash code
      */
     public int hashCode() {
         if (hashCode == 0) {
@@ -157,11 +160,9 @@
             }
             sb.append('/');
             // set of required node type names, sorted in ascending order
-            TreeSet set = new TreeSet();
+            TreeSet<Name> set = new TreeSet<Name>();
             Name[] names = getRequiredPrimaryTypes();
-            for (int i = 0; i < names.length; i++) {
-                set.add(names[i]);
-            }
+            set.addAll(Arrays.asList(names));
             sb.append(set.toString());
 
             hashCode = sb.toString().hashCode();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QNodeTypeDefinitionImpl.java Wed Jun 17 20:21:54 2009
@@ -23,10 +23,12 @@
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 
 import javax.jcr.PropertyType;
 import javax.jcr.NamespaceException;
@@ -37,6 +39,7 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Collections;
+import java.util.Arrays;
 import java.io.Serializable;
 
 /**
@@ -99,7 +102,7 @@
      * Unmodifiable collection of dependent node type <code>Name</code>s.
      * @see #getDependencies()
      */
-    private transient Collection dependencies;
+    private transient Collection<Name> dependencies;
 
     /**
      * Copy constructor.
@@ -118,64 +121,6 @@
      *
      * @param name                   the name of the node type
      * @param supertypes             the names of the supertypes
-     * @param isMixin                if this is a mixin node type
-     * @param hasOrderableChildNodes if this node type has orderable child
-     *                               nodes.
-     * @param primaryItemName        the name of the primary item, or
-     *                               <code>null</code>.
-     * @param declaredPropDefs       the declared property definitions.
-     * @param declaredNodeDefs       the declared child node definitions.
-     * @deprecated use {@link #QNodeTypeDefinitionImpl(Name, Name[], Name[], boolean, boolean, Name, QPropertyDefinition[], QNodeDefinition[])}
-     */
-    public QNodeTypeDefinitionImpl(Name name,
-                                   Name[] supertypes,
-                                   boolean isMixin,
-                                   boolean hasOrderableChildNodes,
-                                   Name primaryItemName,
-                                   QPropertyDefinition[] declaredPropDefs,
-                                   QNodeDefinition[] declaredNodeDefs) {
-        this(name, supertypes, null, isMixin, false, false,
-                hasOrderableChildNodes, primaryItemName,
-                getSerializablePropertyDefs(declaredPropDefs),
-                getSerializableNodeDefs(declaredNodeDefs));
-    }
-
-    /**
-     * Creates a new serializable SPI node type definition. Same as
-     * {@link #QNodeTypeDefinitionImpl(Name, Name[], Name[], boolean, boolean, boolean, boolean, Name, QPropertyDefinition[], QNodeDefinition[])}
-     * but using <code>false</code> for both {@link #isAbstract()} and {@link #isQueryable)}.
-     *
-     * @param name                   the name of the node type
-     * @param supertypes             the names of the supertypes
-     * @param supportedMixins        the names of supported mixins (or <code>null</code>)
-     * @param isMixin                if this is a mixin node type
-     * @param hasOrderableChildNodes if this node type has orderable child
-     *                               nodes.
-     * @param primaryItemName        the name of the primary item, or
-     *                               <code>null</code>.
-     * @param declaredPropDefs       the declared property definitions.
-     * @param declaredNodeDefs       the declared child node definitions.
-     *
-     */
-    public QNodeTypeDefinitionImpl(Name name,
-                                   Name[] supertypes,
-                                   Name[] supportedMixins,
-                                   boolean isMixin,
-                                   boolean hasOrderableChildNodes,
-                                   Name primaryItemName,
-                                   QPropertyDefinition[] declaredPropDefs,
-                                   QNodeDefinition[] declaredNodeDefs) {
-        this(name, supertypes, supportedMixins, isMixin, false, false,
-                hasOrderableChildNodes, primaryItemName,
-                getSerializablePropertyDefs(declaredPropDefs),
-                getSerializableNodeDefs(declaredNodeDefs));
-    }
-
-    /**
-     * Creates a new serializable SPI node type definition.
-     *
-     * @param name                   the name of the node type
-     * @param supertypes             the names of the supertypes
      * @param supportedMixins        the names of supported mixins (or <code>null</code>)
      * @param isMixin                if this is a mixin node type
      * @param isAbstract             if this is an abstract node type definition.
@@ -213,14 +158,15 @@
      * Createa a new <code>QNodeTypeDefinitionImpl</code> from a JCR
      * NodeType definition.
      *
-     * @param def
-     * @param resolver
-     * @param qValueFactory
-     * @throws RepositoryException
+     * @param def node type definition
+     * @param resolver resolver
+     * @param qValueFactory value factory
+     * @throws RepositoryException if an error occurs
      */
     public QNodeTypeDefinitionImpl(NodeTypeDefinition def,
                                    NamePathResolver resolver,
-                                   QValueFactory qValueFactory) throws RepositoryException {
+                                   QValueFactory qValueFactory)
+            throws RepositoryException {
         this(resolver.getQName(def.getName()),
                 getNames(def.getDeclaredSupertypeNames(), resolver), null, def.isMixin(),
                 def.isAbstract(), def.isQueryable(), def.hasOrderableChildNodes(),
@@ -304,36 +250,34 @@
      */
     public Collection getDependencies() {
         if (dependencies == null) {
-            Collection deps = new HashSet();
+            Collection<Name> deps = new HashSet<Name>();
             // supertypes
-            for (int i = 0; i < supertypes.length; i++) {
-                deps.add(supertypes[i]);
-            }
+            deps.addAll(Arrays.asList(supertypes));
             // child node definitions
-            for (int i = 0; i < childNodeDefs.length; i++) {
+            for (QNodeDefinition childNodeDef : childNodeDefs) {
                 // default primary type
-                Name ntName = childNodeDefs[i].getDefaultPrimaryType();
+                Name ntName = childNodeDef.getDefaultPrimaryType();
                 if (ntName != null && !name.equals(ntName)) {
                     deps.add(ntName);
                 }
                 // required primary type
-                Name[] ntNames = childNodeDefs[i].getRequiredPrimaryTypes();
-                for (int j = 0; j < ntNames.length; j++) {
-                    if (ntNames[j] != null && !name.equals(ntNames[j])) {
-                        deps.add(ntNames[j]);
+                Name[] ntNames = childNodeDef.getRequiredPrimaryTypes();
+                for (Name ntName1 : ntNames) {
+                    if (ntName1 != null && !name.equals(ntName1)) {
+                        deps.add(ntName1);
                     }
                 }
             }
             // property definitions
-            for (int i = 0; i < propertyDefs.length; i++) {
+            for (QPropertyDefinition propertyDef : propertyDefs) {
                 // [WEAK]REFERENCE value constraints
-                if (propertyDefs[i].getRequiredType() == PropertyType.REFERENCE
-                        || propertyDefs[i].getRequiredType() == PropertyType.WEAKREFERENCE) {
-                    String[] ca = propertyDefs[i].getValueConstraints();
+                if (propertyDef.getRequiredType() == PropertyType.REFERENCE
+                        || propertyDef.getRequiredType() == PropertyType.WEAKREFERENCE) {
+                    QValueConstraint[] ca = propertyDef.getValueConstraints();
                     if (ca != null) {
-                        for (int j = 0; j < ca.length; j++) {
+                        for (QValueConstraint aCa : ca) {
                             NameFactory factory = NameFactoryImpl.getInstance();
-                            Name ntName = factory.create(ca[j]);
+                            Name ntName = factory.create(aCa.getString());
                             if (!name.equals(ntName)) {
                                 deps.add(ntName);
                             }
@@ -409,20 +353,30 @@
 
     private static QPropertyDefinition[] createQPropertyDefinitions(PropertyDefinition[] pds,
                                                                     NamePathResolver resolver,
-                                                                    QValueFactory qValueFactory) throws RepositoryException {
+                                                                    QValueFactory qValueFactory)
+            throws RepositoryException {
         QPropertyDefinition[] declaredPropDefs = new QPropertyDefinition[pds.length];
         for (int i = 0; i < pds.length; i++) {
             PropertyDefinition propDef = pds[i];
             Name name = resolver.getQName(propDef.getName());
             Name declName = resolver.getQName(propDef.getDeclaringNodeType().getName());
             QValue[] defVls = ValueFormat.getQValues(propDef.getDefaultValues(), resolver, qValueFactory);
-
+            String[] jcrConstraints = propDef.getValueConstraints();
+            QValueConstraint[] constraints = new QValueConstraint[jcrConstraints.length];
+            for (int j=0; j<constraints.length; j++) {
+                constraints[j] = ValueConstraint.create(propDef.getRequiredType(), jcrConstraints[j], resolver);
+            }
             declaredPropDefs[i] = new QPropertyDefinitionImpl(
-                    name, declName, propDef.isAutoCreated(), propDef.isMandatory(),
-                    propDef.getOnParentVersion(), propDef.isProtected(),
-                    defVls, propDef.isMultiple(),
-                    propDef.getRequiredType(), propDef.getValueConstraints(),
-                    getNames(propDef.getAvailableQueryOperators(), resolver),
+                    name, declName,
+                    propDef.isAutoCreated(),
+                    propDef.isMandatory(),
+                    propDef.getOnParentVersion(),
+                    propDef.isProtected(),
+                    defVls,
+                    propDef.isMultiple(),
+                    propDef.getRequiredType(),
+                    constraints,
+                    propDef.getAvailableQueryOperators(),
                     propDef.isFullTextSearchable(),
                     propDef.isQueryOrderable());
         }
@@ -439,9 +393,14 @@
             Name[] requiredPrimaryTypes = getNames(nodeDef.getRequiredPrimaryTypeNames(), resolver);
 
             declaredNodeDefs[i] = new QNodeDefinitionImpl(
-                    name, declName, nodeDef.isAutoCreated(), nodeDef.isMandatory(),
-                    nodeDef.getOnParentVersion(), nodeDef.isProtected(),
-                    defaultPrimaryType, requiredPrimaryTypes,
+                    name,
+                    declName,
+                    nodeDef.isAutoCreated(),
+                    nodeDef.isMandatory(),
+                    nodeDef.getOnParentVersion(),
+                    nodeDef.isProtected(),
+                    defaultPrimaryType,
+                    requiredPrimaryTypes,
                     nodeDef.allowsSameNameSiblings());
         }
         return declaredNodeDefs;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/QPropertyDefinitionImpl.java Wed Jun 17 20:21:54 2009
@@ -19,6 +19,7 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
 
 import java.util.Arrays;
 import java.util.HashSet;
@@ -28,8 +29,7 @@
  * <code>QPropertyDefinitionImpl</code> implements SPI property
  * definition interface.
  */
-public class QPropertyDefinitionImpl
-        extends QItemDefinitionImpl
+public class QPropertyDefinitionImpl extends QItemDefinitionImpl
         implements QPropertyDefinition {
 
     /**
@@ -40,7 +40,7 @@
     /**
      * The value constraints.
      */
-    private final String[] valueConstraints;
+    private final QValueConstraint[] valueConstraints;
 
     /**
      * The default values.
@@ -53,9 +53,9 @@
     private final boolean multiple;
 
     /**
-     * The 'multiple' flag
+     * The available query operators
      */
-    private final Name[] availableQueryOperators;
+    private final String[] availableQueryOperators;
 
     /**
      * The 'fullTextSearcheable' flag
@@ -98,40 +98,9 @@
      * @param requiredType      the required type for this property.
      * @param valueConstraints  the value constraints for this property. If none
      *                          exist an empty array must be passed.
-     * @throws NullPointerException if <code>valueConstraints</code> is
-     *                              <code>null</code>.
-     * @deprecated Use {@link #QPropertyDefinitionImpl(Name, Name,
-                                   boolean, boolean, int, boolean, QValue[], boolean,
-                                   int, String[], Name[], boolean, boolean)} instead.
-     */
-    public QPropertyDefinitionImpl(Name name, Name declaringNodeType,
-                                   boolean isAutoCreated, boolean isMandatory,
-                                   int onParentVersion, boolean isProtected,
-                                   QValue[] defaultValues, boolean isMultiple,
-                                   int requiredType, String[] valueConstraints) {
-        this(name, declaringNodeType, isAutoCreated, isMandatory,
-                onParentVersion, isProtected, defaultValues, isMultiple,
-                requiredType, valueConstraints, null, false, false);
-    }
-
-    /**
-     * Creates a new serializable property definition.
-     *
-     * @param name              the name of the child item.
-     * @param declaringNodeType the delaring node type
-     * @param isAutoCreated     if this item is auto created.
-     * @param isMandatory       if this is a mandatory item.
-     * @param onParentVersion   the on parent version behaviour.
-     * @param isProtected       if this item is protected.
-     * @param defaultValues     the default values or <code>null</code> if there
-     *                          are none.
-     * @param isMultiple        if this property is multi-valued.
-     * @param requiredType      the required type for this property.
-     * @param valueConstraints  the value constraints for this property. If none
-     *                          exist an empty array must be passed.
-     * @param availableQueryOperators
-     * @param isFullTextSearchable
-     * @param isQueryOrderable
+     * @param availableQueryOperators the available query operators
+     * @param isFullTextSearchable if this is fulltext searchable
+     * @param isQueryOrderable   if this is queryable
      * @throws NullPointerException if <code>valueConstraints</code> is
      *                              <code>null</code>.
      * @since JCR 2.0
@@ -140,8 +109,9 @@
                                    boolean isAutoCreated, boolean isMandatory,
                                    int onParentVersion, boolean isProtected,
                                    QValue[] defaultValues, boolean isMultiple,
-                                   int requiredType, String[] valueConstraints,
-                                   Name[] availableQueryOperators,
+                                   int requiredType,
+                                   QValueConstraint[] valueConstraints,
+                                   String[] availableQueryOperators,
                                    boolean isFullTextSearchable,
                                    boolean isQueryOrderable) {
         super(name, declaringNodeType, isAutoCreated, isMandatory,
@@ -169,7 +139,7 @@
     /**
      * {@inheritDoc}
      */
-    public String[] getValueConstraints() {
+    public QValueConstraint[] getValueConstraints() {
         return valueConstraints;
     }
 
@@ -190,7 +160,7 @@
     /**
      * {@inheritDoc}
      */
-    public Name[] getAvailableQueryOperators() {
+    public String[] getAvailableQueryOperators() {
         return availableQueryOperators;
     }
 
@@ -249,7 +219,7 @@
     /**
      * Overwrites {@link QItemDefinitionImpl#hashCode()}.
      *
-     * @return
+     * @return the hashcode
      */
     public int hashCode() {
         if (hashCode == 0) {
@@ -272,11 +242,9 @@
             sb.append('/');
             sb.append(queryOrderable ? 1 : 0);
             sb.append('/');
-            Set<Name> s = new HashSet<Name>();
-            Name[] names = getAvailableQueryOperators();
-            for (int i = 0; i < names.length; i++) {
-                s.add(names[i]);
-            }
+            Set<String> s = new HashSet<String>();
+            String[] names = getAvailableQueryOperators();
+            s.addAll(Arrays.asList(names));
             sb.append(s.toString());
 
             hashCode = sb.toString().hashCode();

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceMapping.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceMapping.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceMapping.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/namespace/NamespaceMapping.java Wed Jun 17 20:21:54 2009
@@ -16,12 +16,10 @@
  */
 package org.apache.jackrabbit.spi.commons.namespace;
 
-import javax.jcr.NamespaceException;
-import java.util.Properties;
-import java.util.Map;
 import java.util.HashMap;
-import java.util.Set;
-import java.util.Iterator;
+import java.util.Map;
+
+import javax.jcr.NamespaceException;
 
 /**
  * A Simple Namespace Mapping table. Mappings can be added
@@ -31,10 +29,10 @@
 public class NamespaceMapping implements NamespaceResolver {
 
     /** local uris */
-    private final Properties prefixToURI = new Properties();
+    private final Map<String, String> prefixToURI = new HashMap<String, String>();
 
     /** local prefix */
-    private final Properties URIToPrefix = new Properties();
+    private final Map<String, String> URIToPrefix = new HashMap<String, String>();
 
     /** base */
     private final NamespaceResolver base;
@@ -45,6 +43,7 @@
 
     /**
      * Constructor
+     * @param base fallback resolver
      */
     public NamespaceMapping(NamespaceResolver base) {
         this.base = base;
@@ -56,7 +55,7 @@
      */
     public String getPrefix(String uri) throws NamespaceException {
         if (URIToPrefix.containsKey(uri)) {
-            return URIToPrefix.getProperty(uri);
+            return URIToPrefix.get(uri);
         } else if (base == null) {
             throw new NamespaceException("No prefix for URI '" + uri + "' declared.");
         } else {
@@ -69,7 +68,7 @@
      */
     public String getURI(String prefix) throws NamespaceException {
         if (prefixToURI.containsKey(prefix)) {
-            return prefixToURI.getProperty(prefix);
+            return prefixToURI.get(prefix);
         } else if (base == null) {
             throw new NamespaceException("No URI for prefix '" + prefix + "' declared.");
         } else {
@@ -79,6 +78,8 @@
 
     /**
      * Returns true if prefix is already mapped to some URI. Returns false otherwise.
+     * @param prefix prefix to check
+     * @return <code>true</code> if prefix is mapped
      */
     public boolean hasPrefix(String prefix) {
         return prefixToURI.containsKey(prefix);
@@ -87,9 +88,9 @@
     /**
      * Set a prefix == URI one-to-one mapping
      *
-     * @param prefix
-     * @param uri
-     * @throws NamespaceException
+     * @param prefix prefix to map
+     * @param uri uri to map
+     * @throws NamespaceException if an error occurs
      */
     public void setMapping(String prefix, String uri) throws NamespaceException {
         if (prefix == null) {
@@ -115,8 +116,8 @@
      * The returned Map is a copy of the internal Map.
      * @return Map
      */
-    public Map getPrefixToURIMapping() {
-        return new HashMap(prefixToURI);
+    public Map<String, String> getPrefixToURIMapping() {
+        return new HashMap<String, String>(prefixToURI);
     }
 
     /**
@@ -124,15 +125,12 @@
      * The returned Map is a copy of the internal Map.
      * @return Map
      */
-    public Map getURIToPrefixMapping() {
-        return new HashMap(URIToPrefix);
+    public Map<String, String> getURIToPrefixMapping() {
+        return new HashMap<String, String>(URIToPrefix);
     }
 
-     /**
-     * Override equals()
-      *
-     * @param obj
-     * @return boolean
+    /**
+     * {@inheritDoc}
      */
     public boolean equals(Object obj) {
         if (this == obj) {
@@ -153,11 +151,9 @@
      */
     public String toString() {
         String s = "";
-        Set mapping = prefixToURI.entrySet();
-        for (Iterator i = mapping.iterator(); i.hasNext();) {
-            Map.Entry entry = (Map.Entry) i.next();
-            String prefix = (String) entry.getKey();
-            String uri = (String) entry.getValue();
+        for (Map.Entry<String, String> entry: prefixToURI.entrySet()) {
+            String prefix = entry.getKey();
+            String uri = entry.getValue();
             s += "'" + prefix + "' == '" + uri + "'\n";
         }
         return s;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefDiff.java Wed Jun 17 20:21:54 2009
@@ -22,6 +22,8 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
+import java.util.Map;
 
 import javax.jcr.PropertyType;
 
@@ -30,6 +32,7 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValueConstraint;
 
 /**
  * A <code>NodeTypeDefDiff</code> represents the result of the comparison of
@@ -100,11 +103,13 @@
     private final QNodeTypeDefinition newDef;
     private int type;
 
-    private final List propDefDiffs = new ArrayList();
-    private final List childNodeDefDiffs = new ArrayList();
+    private final List<PropDefDiff> propDefDiffs = new ArrayList<PropDefDiff>();
+    private final List<ChildNodeDefDiff> childNodeDefDiffs = new ArrayList<ChildNodeDefDiff>();
 
     /**
      * Constructor
+     * @param oldDef old definition
+     * @param newDef new definition
      */
     private NodeTypeDefDiff(QNodeTypeDefinition oldDef, QNodeTypeDefinition newDef) {
         this.oldDef = oldDef;
@@ -154,9 +159,9 @@
     }
 
     /**
-     * @param oldDef
-     * @param newDef
-     * @return
+     * @param oldDef old definition
+     * @param newDef new definition
+     * @return the diff
      */
     public static NodeTypeDefDiff create(QNodeTypeDefinition oldDef, QNodeTypeDefinition newDef) {
         if (oldDef == null || newDef == null) {
@@ -169,28 +174,28 @@
     }
 
     /**
-     * @return
+     * @return <code>true</code> if modified
      */
     public boolean isModified() {
         return type != NONE;
     }
 
     /**
-     * @return
+     * @return <code>true</code> if trivial
      */
     public boolean isTrivial() {
         return type == TRIVIAL;
     }
 
     /**
-     * @return
+     * @return <code>true</code> if minor
      */
     public boolean isMinor() {
         return type == MINOR;
     }
 
     /**
-     * @return
+     * @return <code>true</code> if major
      */
     public boolean isMajor() {
         return type == MAJOR;
@@ -215,21 +220,21 @@
     }
 
     /**
-     * @return
+     * @return <code>true</code> if mixin diff
      */
     public int mixinFlagDiff() {
         return oldDef.isMixin() != newDef.isMixin() ? MAJOR : NONE;
     }
 
     /**
-     * @return
+     * @return <code>true</code> if supertypes diff
      */
     public int supertypesDiff() {
         return !Arrays.equals(oldDef.getSupertypes(), newDef.getSupertypes()) ? MAJOR : NONE;
     }
 
     /**
-     * @return
+     * @return diff type
      */
     private int buildPropDefDiffs() {
         /**
@@ -239,15 +244,15 @@
 
         int maxType = NONE;
         QPropertyDefinition[] pda1 = oldDef.getPropertyDefs();
-        HashMap defs1 = new HashMap();
-        for (int i = 0; i < pda1.length; i++) {
-            defs1.put(pda1[i].getName(), pda1[i]);
+        Map<Name, QPropertyDefinition> defs1 = new HashMap<Name, QPropertyDefinition>();
+        for (QPropertyDefinition aPda1 : pda1) {
+            defs1.put(aPda1.getName(), aPda1);
         }
 
         QPropertyDefinition[] pda2 = newDef.getPropertyDefs();
-        HashMap defs2 = new HashMap();
-        for (int i = 0; i < pda2.length; i++) {
-            defs2.put(pda2[i].getName(), pda2[i]);
+        Map<Name, QPropertyDefinition> defs2 = new HashMap<Name, QPropertyDefinition>();
+        for (QPropertyDefinition aPda2 : pda2) {
+            defs2.put(aPda2.getName(), aPda2);
         }
 
         /**
@@ -257,8 +262,8 @@
         Iterator iter = defs1.keySet().iterator();
         while (iter.hasNext()) {
             Name name = (Name) iter.next();
-            QPropertyDefinition def1 = (QPropertyDefinition) defs1.get(name);
-            QPropertyDefinition def2 = (QPropertyDefinition) defs2.get(name);
+            QPropertyDefinition def1 = defs1.get(name);
+            QPropertyDefinition def2 = defs2.get(name);
             PropDefDiff diff = new PropDefDiff(def1, def2);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -274,7 +279,7 @@
         iter = defs2.keySet().iterator();
         while (iter.hasNext()) {
             Name name = (Name) iter.next();
-            QPropertyDefinition def = (QPropertyDefinition) defs2.get(name);
+            QPropertyDefinition def = defs2.get(name);
             PropDefDiff diff = new PropDefDiff(null, def);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -286,7 +291,7 @@
     }
 
     /**
-     * @return
+     * @return diff type
      */
     private int buildChildNodeDefDiffs() {
         /**
@@ -296,15 +301,15 @@
 
         int maxType = NONE;
         QNodeDefinition[] cnda1 = oldDef.getChildNodeDefs();
-        HashMap defs1 = new HashMap();
-        for (int i = 0; i < cnda1.length; i++) {
-            defs1.put(cnda1[i].getName(), cnda1[i]);
+        Map<Name, QNodeDefinition> defs1 = new HashMap<Name, QNodeDefinition>();
+        for (QNodeDefinition aCnda1 : cnda1) {
+            defs1.put(aCnda1.getName(), aCnda1);
         }
 
         QNodeDefinition[] cnda2 = newDef.getChildNodeDefs();
-        HashMap defs2 = new HashMap();
-        for (int i = 0; i < cnda2.length; i++) {
-            defs2.put(cnda2[i].getName(), cnda2[i]);
+        Map<Name, QNodeDefinition> defs2 = new HashMap<Name, QNodeDefinition>();
+        for (QNodeDefinition aCnda2 : cnda2) {
+            defs2.put(aCnda2.getName(), aCnda2);
         }
 
         /**
@@ -314,8 +319,8 @@
         Iterator iter = defs1.keySet().iterator();
         while (iter.hasNext()) {
             Name name = (Name) iter.next();
-            QNodeDefinition def1 = (QNodeDefinition) defs1.get(name);
-            QNodeDefinition def2 = (QNodeDefinition) defs2.get(name);
+            QNodeDefinition def1 = defs1.get(name);
+            QNodeDefinition def2 = defs2.get(name);
             ChildNodeDefDiff diff = new ChildNodeDefDiff(def1, def2);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -331,7 +336,7 @@
         iter = defs2.keySet().iterator();
         while (iter.hasNext()) {
             Name name = (Name) iter.next();
-            QNodeDefinition def = (QNodeDefinition) defs2.get(name);
+            QNodeDefinition def = defs2.get(name);
             ChildNodeDefDiff diff = new ChildNodeDefDiff(null, def);
             if (diff.getType() > maxType) {
                 maxType = diff.getType();
@@ -361,7 +366,7 @@
         return result;
     }
 
-    private String toString(List childItemDefDiffs) {
+    private String toString(List<? extends ChildItemDefDiff> childItemDefDiffs) {
         String result = "";
         for (Iterator iter = childItemDefDiffs.iterator(); iter.hasNext();) {
             ChildItemDefDiff propDefDiff = (ChildItemDefDiff) iter.next();
@@ -520,15 +525,15 @@
                  * check if valueConstraints were made more restrictive
                  * (constraints are ORed)
                  */
-                String[] vca1 = getOldDef().getValueConstraints();
-                HashSet set1 = new HashSet();
-                for (int i = 0; i < vca1.length; i++) {
-                    set1.add(vca1[i]);
+                QValueConstraint[] vca1 = getOldDef().getValueConstraints();
+                Set<String> set1 = new HashSet<String>();
+                for (QValueConstraint aVca1 : vca1) {
+                    set1.add(aVca1.getString());
                 }
-                String[] vca2 = getNewDef().getValueConstraints();
-                HashSet set2 = new HashSet();
-                for (int i = 0; i < vca2.length; i++) {
-                    set2.add(vca2[i]);
+                QValueConstraint[] vca2 = getNewDef().getValueConstraints();
+                Set<String> set2 = new HashSet<String>();
+                for (QValueConstraint aVca2 : vca2) {
+                    set2.add(aVca2.getString());
                 }
 
                 if (set1.isEmpty() && !set2.isEmpty()) {
@@ -603,8 +608,8 @@
                 // no need to check defaultPrimaryType (TRIVIAL change)
 
                 if (type == TRIVIAL) {
-                    List l1 = Arrays.asList(getOldDef().getRequiredPrimaryTypes());
-                    List l2 = Arrays.asList(getNewDef().getRequiredPrimaryTypes());
+                    List<Name> l1 = Arrays.asList(getOldDef().getRequiredPrimaryTypes());
+                    List<Name> l2 = Arrays.asList(getNewDef().getRequiredPrimaryTypes());
                     if (!l1.equals(l2)) {
                         if (l1.containsAll(l2)) {
                             // removed requiredPrimaryType (MINOR change)

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java?rev=785777&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java Wed Jun 17 20:21:54 2009
@@ -0,0 +1,187 @@
+/*
+ * 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.spi.commons.nodetype;
+
+import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
+
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.NamespaceException;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.value.QValueValue;
+
+/**
+ * <code>NodeTypeDefinitionFactory</code> can be used to convert the qualified
+ * node type definitions to JCR {@link NodeTypeDefinition}s.
+ */
+public class NodeTypeDefinitionFactory {
+
+    private final NodeTypeManager ntMgr;
+
+    private final NamePathResolver resolver;
+
+    /**
+     * Creates a new node type definition factory that operates on the given
+     * sesion to create the templates.
+     *
+     * @param session repository session
+     * @throws RepositoryException if an error occurs
+     */
+    public NodeTypeDefinitionFactory(Session session)
+            throws RepositoryException {
+        this.ntMgr = session.getWorkspace().getNodeTypeManager();
+        this.resolver = new DefaultNamePathResolver(session);
+    }
+
+    /**
+     * Create a new node type definitions from a qualified ones.
+     *
+     * @param defs the qualified node type definitions
+     * @return the JCR node type definitions
+     * @throws RepositoryException if an error occurs
+     */
+    public List<NodeTypeDefinition> create(Collection<QNodeTypeDefinition> defs)
+            throws RepositoryException {
+        List<NodeTypeDefinition> list = new ArrayList<NodeTypeDefinition>(defs.size());
+        for (QNodeTypeDefinition qNtd: defs) {
+            list.add(create(qNtd));
+        }
+        return list;
+    }
+
+    /**
+     * Create a new node type definition from a qualified one.
+     *
+     * @param qNtd the qualified node type definition
+     * @return the JCR node type definition
+     * @throws RepositoryException if an error occurs
+     */
+    @SuppressWarnings("unchecked")
+    public NodeTypeDefinition create(QNodeTypeDefinition qNtd)
+            throws RepositoryException {
+        NodeTypeTemplate nt = ntMgr.createNodeTypeTemplate();
+        nt.setName(resolver.getJCRName(qNtd.getName()));
+        nt.setDeclaredSuperTypeNames(getJCRNames(qNtd.getSupertypes()));
+        nt.setAbstract(qNtd.isAbstract());
+        nt.setMixin(qNtd.isMixin());
+        nt.setOrderableChildNodes(qNtd.hasOrderableChildNodes());
+        nt.setPrimaryItemName(resolver.getJCRName(qNtd.getPrimaryItemName()));
+        nt.setQueryable(qNtd.isQueryable());
+        List nodeDefs = nt.getNodeDefinitionTemplates();
+        for (QNodeDefinition qNd: qNtd.getChildNodeDefs()) {
+            nodeDefs.add(create(qNd));
+        }
+        List propDefs = nt.getPropertyDefinitionTemplates();
+        for (QPropertyDefinition qPd: qNtd.getPropertyDefs()) {
+            propDefs.add(create(qPd));
+        }
+        return nt;
+    }
+
+    /**
+     * Create a new node definition from a qualified one.
+     *
+     * @param qNd the qualified node definition
+     * @return the JCR node definition
+     * @throws RepositoryException if an error occurs
+     */
+    public NodeDefinition create(QNodeDefinition qNd)
+            throws RepositoryException {
+        NodeDefinitionTemplate nt = ntMgr.createNodeDefinitionTemplate();
+        nt.setName(resolver.getJCRName(qNd.getName()));
+        nt.setAutoCreated(qNd.isAutoCreated());
+        nt.setMandatory(qNd.isMandatory());
+        nt.setOnParentVersion(qNd.getOnParentVersion());
+        nt.setProtected(qNd.isProtected());
+        nt.setSameNameSiblings(qNd.allowsSameNameSiblings());
+        nt.setDefaultPrimaryTypeName(resolver.getJCRName(qNd.getDefaultPrimaryType()));
+        nt.setRequiredPrimaryTypeNames(getJCRNames(qNd.getRequiredPrimaryTypes()));
+        return nt;
+    }
+
+    /**
+     * Create a new property definition from a qualified one.
+     *
+     * @param qPd the qualified propert definition
+     * @return the JCR property definition
+     * @throws RepositoryException if an error occurs
+     */
+    public PropertyDefinition create(QPropertyDefinition qPd) throws RepositoryException {
+        PropertyDefinitionTemplate pt = ntMgr.createPropertyDefinitionTemplate();
+        pt.setName(resolver.getJCRName(qPd.getName()));
+        pt.setAutoCreated(qPd.isAutoCreated());
+        pt.setMandatory(qPd.isMandatory());
+        pt.setOnParentVersion(qPd.getOnParentVersion());
+        pt.setProtected(qPd.isProtected());
+        pt.setMultiple(qPd.isMultiple());
+        pt.setFullTextSearchable(qPd.isFullTextSearchable());
+        pt.setValueConstraints(createValueConstraints(qPd.getRequiredType(), qPd.getValueConstraints()));
+        pt.setAvailableQueryOperators(qPd.getAvailableQueryOperators());
+        pt.setDefaultValues(createValues(qPd.getDefaultValues()));
+        return pt;
+    }
+
+    private String[] getJCRNames(Name[] names) throws NamespaceException {
+        String[] ret = new String[names.length];
+        for (int i=0; i<names.length; i++) {
+            ret[i] = resolver.getJCRName(names[i]);
+        }
+        return ret;
+    }
+
+    private String[] createValueConstraints(int type, QValueConstraint[] qv)
+            throws RepositoryException {
+        String[] ret = new String[qv.length];
+        for (int i=0; i<ret.length; i++) {
+            try {
+                ValueConstraint c = ValueConstraint.create(type, qv[i].getString());
+                ret[i] = c.getDefinition(resolver);
+            } catch (InvalidConstraintException e) {
+                throw new RepositoryException("Internal error while converting value constraints.", e);
+            }
+        }
+        return ret;
+    }
+
+    private Value[] createValues(QValue[] qv) {
+        Value[] ret = new Value[qv.length];
+        for (int i=0; i<ret.length; i++) {
+            ret[i] = new QValueValue(qv[i], resolver);
+        }
+        return ret;
+    }
+
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeDefinitionFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/NodeTypeTemplateImpl.java Wed Jun 17 20:21:54 2009
@@ -16,17 +16,15 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype;
 
-import org.apache.commons.collections.list.TypedList;
-
-import javax.jcr.nodetype.NodeTypeTemplate;
-import javax.jcr.nodetype.NodeTypeDefinition;
-import javax.jcr.nodetype.NodeDefinitionTemplate;
-import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import java.util.LinkedList;
+import java.util.List;
 
 import javax.jcr.nodetype.NodeDefinition;
+import javax.jcr.nodetype.NodeDefinitionTemplate;
+import javax.jcr.nodetype.NodeTypeDefinition;
+import javax.jcr.nodetype.NodeTypeTemplate;
 import javax.jcr.nodetype.PropertyDefinition;
-import java.util.ArrayList;
-import java.util.List;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
 
 /**
  * A <code>NodeTypeTemplateImpl</code> ...
@@ -40,8 +38,8 @@
     private boolean queryable;
     private boolean mixin;
     private boolean orderableChildNodes;
-    private List nodeDefinitionTemplates;
-    private List propertyDefinitionTemplates;
+    private List<NodeDefinitionTemplate> nodeDefinitionTemplates;
+    private List<PropertyDefinitionTemplate> propertyDefinitionTemplates;
 
     /**
      * Package private constructor
@@ -66,15 +64,15 @@
         NodeDefinition[] nodeDefs = def.getDeclaredChildNodeDefinitions();
         if (nodeDefs != null) {
             List list = getNodeDefinitionTemplates();
-            for (int i = 0; i < nodeDefs.length; i++) {
-                list.add(new NodeDefinitionTemplateImpl(nodeDefs[i]));
+            for (NodeDefinition nodeDef : nodeDefs) {
+                list.add(new NodeDefinitionTemplateImpl(nodeDef));
             }
         }
         PropertyDefinition[] propDefs = def.getDeclaredPropertyDefinitions();
         if (propDefs != null) {
             List list = getPropertyDefinitionTemplates();
-            for (int i = 0; i < propDefs.length; i++) {
-                list.add(new PropertyDefinitionTemplateImpl(propDefs[i]));
+            for (PropertyDefinition propDef : propDefs) {
+                list.add(new PropertyDefinitionTemplateImpl(propDef));
             }
         }
     }
@@ -127,8 +125,7 @@
      */
     public List getPropertyDefinitionTemplates() {
         if (propertyDefinitionTemplates == null) {
-            propertyDefinitionTemplates = TypedList.decorate(
-                    new ArrayList(), PropertyDefinitionTemplate.class);
+            propertyDefinitionTemplates = new LinkedList<PropertyDefinitionTemplate>();
         }
         return propertyDefinitionTemplates;
     }
@@ -138,8 +135,7 @@
      */
     public List getNodeDefinitionTemplates() {
         if (nodeDefinitionTemplates == null) {
-            nodeDefinitionTemplates = TypedList.decorate(
-                    new ArrayList(), NodeDefinitionTemplate.class);
+            nodeDefinitionTemplates = new LinkedList<NodeDefinitionTemplate>();
         }
         return nodeDefinitionTemplates;
     }
@@ -205,7 +201,7 @@
         if (propertyDefinitionTemplates == null) {
             return null;
         } else {
-            return (PropertyDefinition[]) propertyDefinitionTemplates.toArray(
+            return propertyDefinitionTemplates.toArray(
                     new PropertyDefinition[propertyDefinitionTemplates.size()]);
         }
     }
@@ -217,7 +213,7 @@
         if (nodeDefinitionTemplates == null) {
             return null;
         } else {
-            return (NodeDefinition[]) nodeDefinitionTemplates.toArray(
+            return nodeDefinitionTemplates.toArray(
                     new NodeDefinition[nodeDefinitionTemplates.size()]);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java Wed Jun 17 20:21:54 2009
@@ -16,20 +16,19 @@
  */
 package org.apache.jackrabbit.spi.commons.nodetype;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.nodetype.PropertyDefinition;
+
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
-
-import javax.jcr.nodetype.PropertyDefinition;
-import javax.jcr.Value;
-import javax.jcr.RepositoryException;
-import javax.jcr.NamespaceException;
-import javax.jcr.ValueFactory;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * This class implements the <code>PropertyDefinition</code> interface.
@@ -50,8 +49,8 @@
      * Package private constructor
      *
      * @param propDef    property definition
-     * @param resolver
-     * @param valueFactory
+     * @param resolver the name-path resolver
+     * @param valueFactory a value factory
      */
     public PropertyDefinitionImpl(QPropertyDefinition propDef, NamePathResolver resolver,
                                   ValueFactory valueFactory) {
@@ -60,10 +59,10 @@
 
     /**
      *
-     * @param propDef
-     * @param ntMgr
-     * @param resolver
-     * @param valueFactory
+     * @param propDef underlying propdef
+     * @param ntMgr nodetype manager
+     * @param resolver name-path resolver
+     * @param valueFactory value factory (for default values)
      */
     public PropertyDefinitionImpl(QPropertyDefinition propDef,
                                   AbstractNodeTypeManager ntMgr,
@@ -110,21 +109,21 @@
      */
     public String[] getValueConstraints() {
         QPropertyDefinition pd = (QPropertyDefinition) itemDef;
-        String[] constraints = pd.getValueConstraints();
+        QValueConstraint[] constraints = pd.getValueConstraints();
         if (constraints == null || constraints.length == 0) {
             return new String[0];
         }
-        try {
-            String[] vca = new String[constraints.length];
-            for (int i = 0; i < constraints.length; i++) {
-                ValueConstraint constr = ValueConstraint.create(pd.getRequiredType(), constraints[i]);
-                vca[i] = constr.getDefinition(resolver);
+        String[] vca = new String[constraints.length];
+        for (int i = 0; i < constraints.length; i++) {
+            try {
+                ValueConstraint vc = ValueConstraint.create(pd.getRequiredType(), constraints[i].getString());
+                vca[i] = vc.getDefinition(resolver);
+            } catch (InvalidConstraintException e) {
+                log.warn("Internal error during conversion of constraint.", e);
+                vca[i] = constraints[i].getString();
             }
-            return vca;
-        } catch (InvalidConstraintException e) {
-            log.error("Invalid value constraint: " + e.getMessage());
-            return null;
         }
+        return vca;
     }
 
     /**
@@ -138,18 +137,7 @@
      * @see javax.jcr.nodetype.PropertyDefinition#getAvailableQueryOperators()
      */
     public String[] getAvailableQueryOperators() {
-        Name[] names = ((QPropertyDefinition) itemDef).getAvailableQueryOperators();
-        String[] aqos = new String[names.length];
-        for (int i = 0; i < names.length; i++) {
-            try {
-                aqos[i] = resolver.getJCRName(names[i]);
-            } catch (NamespaceException e) {
-                // should not occure. fallback
-                log.warn(e.getMessage());
-                aqos[i] = names[i].toString();
-            }
-        }
-        return aqos;
+        return ((QPropertyDefinition) itemDef).getAvailableQueryOperators();
     }
 
     /**



Mime
View raw message