jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r785777 [4/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-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java
Wed Jun 17 20:21:54 2009
@@ -27,6 +27,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
 import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameConstants;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
 
 /**
@@ -39,11 +40,11 @@
 
     static PathConstraint create(String qualifiedDefinition) throws InvalidConstraintException
{
         // constraint format: qualified absolute or relative path with optional trailing
wildcard
-        boolean deep = qualifiedDefinition.endsWith("*");
+        boolean deep = qualifiedDefinition.endsWith("\t{}*");
         Path path;
         // TODO improve. don't rely on a specific factory impl
         if (deep) {
-            path = PathFactoryImpl.getInstance().create(qualifiedDefinition.substring(0,
qualifiedDefinition.length() - 1));
+            path = PathFactoryImpl.getInstance().create(qualifiedDefinition.substring(0,
qualifiedDefinition.length() - 4));
         } else {
             path = PathFactoryImpl.getInstance().create(qualifiedDefinition);
         }
@@ -53,7 +54,6 @@
     static PathConstraint create(String definition, PathResolver resolver)
             throws InvalidConstraintException {
         try {
-            StringBuffer qualifiedDefinition = new StringBuffer();
             // constraint format: absolute or relative path with optional
             // trailing wildcard
             boolean deep = definition.endsWith("/*");
@@ -61,15 +61,16 @@
                 // trim trailing wildcard before building path
                 if (definition.equals("/*")) {
                     definition = "/";
-                    qualifiedDefinition.append('*');
                 } else {
                     definition = definition.substring(0, definition.length() - 2);
-                    qualifiedDefinition.append("/*");
                 }
             }
             Path path = resolver.getQPath(definition);
-            qualifiedDefinition.insert(0, path.getString());
-
+            StringBuffer qualifiedDefinition = new StringBuffer(path.getString());
+            if (deep) {
+                qualifiedDefinition.append(Path.DELIMITER);
+                qualifiedDefinition.append(NameConstants.ANY_NAME);
+            }
             return new PathConstraint(qualifiedDefinition.toString(), path, deep);
         } catch (NameException e) {
             String msg = "Invalid path expression specified as value constraint: " + definition;
@@ -93,7 +94,7 @@
      * qualified <code>Path</code> into a JCR path.
      *
      * @see ValueConstraint#getDefinition(NamePathResolver)
-     * @param resolver
+     * @param resolver name-path resolver
      */
     public String getDefinition(NamePathResolver resolver) {
         try {
@@ -107,16 +108,16 @@
             }
         } catch (NamespaceException e) {
             // should never get here, return raw definition as fallback
-            return getQualifiedDefinition();
+            return getString();
         }
     }
 
     /**
      * @see ValueConstraint#check(QValue)
      */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+    public void check(QValue value) throws ConstraintViolationException, RepositoryException
{
         if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint
'" + getQualifiedDefinition() + "'");
+            throw new ConstraintViolationException("null value does not satisfy the constraint
'" + getString() + "'");
         }
         switch (value.getType()) {
             case PropertyType.PATH:
@@ -134,20 +135,20 @@
                         if (!p0.isAncestorOf(p1)) {
                             throw new ConstraintViolationException(p
                                 + " does not satisfy the constraint '"
-                                + getQualifiedDefinition() + "'");
+                                + getString() + "'");
                         }
                     } catch (RepositoryException e) {
                         // can't compare relative with absolute path
                         throw new ConstraintViolationException(p
                             + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
+                            + getString() + "'");
                     }
                 } else {
                     // exact match required
                     if (!p0.equals(p1)) {
                         throw new ConstraintViolationException(p
                             + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
+                            + getString() + "'");
                     }
                 }
                 return;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java
Wed Jun 17 20:21:54 2009
@@ -67,23 +67,23 @@
      * qualified <code>Name</code> into a JCR name.
      *
      * @see ValueConstraint#getDefinition(NamePathResolver)
-     * @param resolver
+     * @param resolver name-path resolver
      */
     public String getDefinition(NamePathResolver resolver) {
         try {
             return resolver.getJCRName(ntName);
         } catch (NamespaceException e) {
             // should never get here, return raw definition as fallback
-            return getQualifiedDefinition();
+            return getString();
         }
     }
 
     /**
      * @see ValueConstraint#check(QValue)
      */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+    public void check(QValue value) throws ConstraintViolationException, RepositoryException
{
         if (value == null) {
-            throw new ConstraintViolationException("Null value does not satisfy the constraint
'" + getQualifiedDefinition() + "'");
+            throw new ConstraintViolationException("Null value does not satisfy the constraint
'" + getString() + "'");
         }
         switch (value.getType()) {
             case PropertyType.REFERENCE:

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java
Wed Jun 17 20:21:54 2009
@@ -50,9 +50,9 @@
     /**
      * @see ValueConstraint#check(QValue)
      */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+    public void check(QValue value) throws ConstraintViolationException, RepositoryException
{
         if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint
'" + getQualifiedDefinition() + "'");
+            throw new ConstraintViolationException("null value does not satisfy the constraint
'" + getString() + "'");
         }
         switch (value.getType()) {
             case PropertyType.STRING:
@@ -60,7 +60,7 @@
                 String text = value.getString();
                 Matcher matcher = pattern.matcher(text);
                 if (!matcher.matches()) {
-                    throw new ConstraintViolationException("'" + text  + "' does not satisfy
the constraint '" + getQualifiedDefinition() + "'");
+                    throw new ConstraintViolationException("'" + text  + "' does not satisfy
the constraint '" + getString() + "'");
                 }
                 return;
 

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
Wed Jun 17 20:21:54 2009
@@ -24,6 +24,7 @@
 import org.apache.jackrabbit.spi.NameFactory;
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
@@ -35,7 +36,7 @@
  * syntax of a value constraint and to test if a specific value satisfies
  * it.
  */
-public abstract class ValueConstraint {
+public abstract class ValueConstraint implements QValueConstraint {
 
     protected static Logger log = LoggerFactory.getLogger(ValueConstraint.class);
 
@@ -52,7 +53,7 @@
 
     /**
      * For constraints that are not namespace prefix mapping sensitive this
-     * method returns the same result as <code>{@link #getQualifiedDefinition()}</code>.
+     * method returns the same result as <code>{@link #getString()}</code>.
      * <p/>
      * Those that are namespace prefix mapping sensitive (e.g.
      * <code>NameConstraint</code>, <code>PathConstraint</code> and
@@ -63,8 +64,8 @@
      * and path elements resolved.
      *
      * @return the definition of this constraint.
-     * @see #getQualifiedDefinition()
-     * @param resolver
+     * @see #getString ()
+     * @param resolver name-path resolver
      */
     public String getDefinition(NamePathResolver resolver) {
         return qualifiedDefinition;
@@ -73,14 +74,21 @@
     /**
      * By default the qualified definition is the same as the JCR definition.
      *
-     * @return the qualified definition String
-     * @see #getDefinition(NamePathResolver)
+     * @return the internal definition String
      */
-    public String getQualifiedDefinition() {
+    public String getString() {
         return qualifiedDefinition;
     }
 
     /**
+     * Same as {@link #getString()}
+     * @return the internal definition String
+     */
+    public String toString() {
+        return getString();
+    }
+
+    /**
      * Check if the specified value matches the this constraint.
      *
      * @param value The value to be tested.
@@ -88,17 +96,13 @@
      * <code>null</code> or does not matches the constraint.
      * @throws RepositoryException If another error occurs.
      */
-    abstract void check(QValue value) throws ConstraintViolationException, RepositoryException;
+    public abstract void check(QValue value) throws ConstraintViolationException, RepositoryException;
 
     //---------------------------------------------------< java.lang.Object >---
     public boolean equals(Object other) {
-        if (other == this) {
-            return true;
-        } else if (other instanceof ValueConstraint) {
-            return qualifiedDefinition.equals(((ValueConstraint) other).qualifiedDefinition);
-        } else {
-            return false;
-        }
+        return other == this
+                || other instanceof ValueConstraint
+                && qualifiedDefinition.equals(((ValueConstraint) other).qualifiedDefinition);
     }
 
     /**
@@ -117,10 +121,10 @@
      * Note, that the definition must be in the qualified format in case the type
      * indicates {@link PropertyType#NAME}, {@link PropertyType#PATH} or {@link PropertyType#REFERENCE}
      *
-     * @param type
-     * @param qualifiedDefinition
-     * @return
-     * @throws InvalidConstraintException
+     * @param type required type
+     * @param qualifiedDefinition internal definition string
+     * @return a new value constraint
+     * @throws InvalidConstraintException if the constraint is not valid
      */
     public static ValueConstraint create(int type, String qualifiedDefinition)
         throws InvalidConstraintException {
@@ -128,7 +132,7 @@
             throw new IllegalArgumentException("illegal definition (null)");
         }
         switch (type) {
-            // constraints which are not qName senstive
+            // constraints which are not qName sensitive
             case PropertyType.STRING:
             case PropertyType.URI:
                 return new StringConstraint(qualifiedDefinition);
@@ -165,12 +169,55 @@
     }
 
     /**
+     * Create a new <code>ValueConstraint</code> array from the String representation.
+     * Note, that the definition must be in the qualified format in case the type
+     * indicates {@link PropertyType#NAME}, {@link PropertyType#PATH} or {@link PropertyType#REFERENCE}
+     *
+     * @param type the required type
+     * @param qualifiedDefinition internal definition strings
+     * @return the array of constraints
+     * @throws InvalidConstraintException if one of the constraints is invalid
+     */
+    public static ValueConstraint[] create(int type, String[] qualifiedDefinition)
+            throws InvalidConstraintException {
+        if (qualifiedDefinition == null || qualifiedDefinition.length == 0) {
+            return ValueConstraint.EMPTY_ARRAY;
+        }
+        ValueConstraint[] ret = new ValueConstraint[qualifiedDefinition.length];
+        for (int i=0; i<ret.length; i++) {
+            ret[i] = ValueConstraint.create(type, qualifiedDefinition[i]);
+        }
+        return ret;
+    }
+
+    /**
+     * Create a new <code>ValueConstraint</code> array from the JCR representation.
+     *
+     * @param type the required type
+     * @param definition definition strings
+     * @param resolver name-path resolver
+     * @return the array of constraints
+     * @throws InvalidConstraintException if one of the constraints is invalid
+     */
+    public static ValueConstraint[] create(int type, String definition[], NamePathResolver
resolver)
+            throws InvalidConstraintException {
+        if (definition == null || definition.length == 0) {
+            return ValueConstraint.EMPTY_ARRAY;
+        }
+        ValueConstraint[] ret = new ValueConstraint[definition.length];
+        for (int i=0; i<ret.length; i++) {
+            ret[i] = ValueConstraint.create(type, definition[i], resolver);
+        }
+        return ret;
+    }
+
+    /**
      *
-     * @param type
-     * @param definition
-     * @param resolver
-     * @return
-     * @throws InvalidConstraintException
+     * @param type required type
+     * @param definition JCR definition
+     * @param resolver name-path resolver
+     * @return a new value constraint
+     * @throws InvalidConstraintException if the constraint is invalid
      */
     public static ValueConstraint create(int type, String definition,
                                          NamePathResolver resolver)
@@ -220,9 +267,9 @@
      * type conversions are attempted if the type of the given values does not
      * match the required type as specified in the given definition.
      *
-     * @param pd
-     * @param values
-     * @throws ConstraintViolationException
+     * @param pd propert definition
+     * @param values values to check
+     * @throws ConstraintViolationException if the constraints are violated
      */
     public static void checkValueConstraints(QPropertyDefinition pd, QValue[] values)
             throws ConstraintViolationException, RepositoryException {
@@ -231,21 +278,20 @@
             throw new ConstraintViolationException("the property is not multi-valued");
         }
 
-        String[] constraints = pd.getValueConstraints();
+        QValueConstraint[] constraints = pd.getValueConstraints();
         if (constraints == null || constraints.length == 0) {
             // no constraints to check
             return;
         }
         if (values != null && values.length > 0) {
             // check value constraints on every value
-            for (int i = 0; i < values.length; i++) {
+            for (QValue value : values) {
                 // constraints are OR-ed together
                 boolean satisfied = false;
                 ConstraintViolationException cve = null;
                 for (int j = 0; j < constraints.length && !satisfied; j++) {
                     try {
-                        ValueConstraint cnstr = ValueConstraint.create(pd.getRequiredType(),
constraints[j]);
-                        cnstr.check(values[i]);
+                        constraints[j].check(value);
                         satisfied = true;
                     } catch (ConstraintViolationException e) {
                         cve = e;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/compact/CompactNodeTypeDefTest.java
Wed Jun 17 20:21:54 2009
@@ -23,17 +23,13 @@
 import java.io.StringWriter;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.jackrabbit.spi.QNodeTypeDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.namespace.NamespaceMapping;
 import org.apache.jackrabbit.spi.commons.nodetype.NodeTypeDefDiff;
-import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
-import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 
-import javax.jcr.ValueFactory;
+import junit.framework.TestCase;
 
 public class CompactNodeTypeDefTest extends TestCase {
 
@@ -43,30 +39,27 @@
 
         // Read in node type def from test file
         Reader reader = new InputStreamReader(getClass().getClassLoader().getResourceAsStream(TEST_FILE));
-        CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(reader, TEST_FILE,
-                new QNodeTypeDefinitionsBuilderImpl());
+        CompactNodeTypeDefReader cndReader = new CompactNodeTypeDefReader(reader, TEST_FILE);
 
-        List ntdList1 = cndReader.getNodeTypeDefs();
+        List<QNodeTypeDefinition> ntdList1 = cndReader.getNodeTypeDefinitions();
         NamespaceMapping nsm = cndReader.getNamespaceMapping();
         NamePathResolver resolver = new DefaultNamePathResolver(nsm);
 
         // Put imported node type def back into CND form with CND writer
         StringWriter sw = new StringWriter();
-        ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
-        CompactNodeTypeDefWriter.write(ntdList1, nsm, resolver, vf, sw);
+        CompactNodeTypeDefWriter.write(ntdList1, nsm, resolver, sw);
 
         // Rerun the reader on the product of the writer
-        cndReader = new CompactNodeTypeDefReader(new StringReader(sw.toString()), TEST_FILE,
-                new QNodeTypeDefinitionsBuilderImpl());
+        cndReader = new CompactNodeTypeDefReader(new StringReader(sw.toString()), TEST_FILE);
 
-        List ntdList2 = cndReader.getNodeTypeDefs();
+        List<QNodeTypeDefinition> ntdList2 = cndReader.getNodeTypeDefinitions();
 
         if (ntdList1.size() == 0 || ntdList1.size() != ntdList2.size()) {
             fail("Exported node type definition was not successfully read back in");
         } else {
             for(int k = 0; k < ntdList1.size(); k++) {
-                QNodeTypeDefinition ntd1 = (QNodeTypeDefinition) ntdList1.get(k);
-                QNodeTypeDefinition ntd2 = (QNodeTypeDefinition) ntdList2.get(k);
+                QNodeTypeDefinition ntd1 = ntdList1.get(k);
+                QNodeTypeDefinition ntd2 = ntdList2.get(k);
 
                 NodeTypeDefDiff diff = NodeTypeDefDiff.create(ntd1, ntd2);
                 if (diff.isModified() && !diff.isTrivial()){

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java
Wed Jun 17 20:21:54 2009
@@ -98,7 +98,7 @@
         String[] qDefs = getQualifiedDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
-            assertEquals(qDefs[i], vc.getQualifiedDefinition());
+            assertEquals(qDefs[i], vc.getString());
         }
     }
 
@@ -128,7 +128,7 @@
         String[] qDefs = getQualifiedDefinitions();
         for (int i = 0; i < qDefs.length; i++) {
             ValueConstraint vc = createValueConstraint(qDefs[i]);
-            assertNotNull(vc.getQualifiedDefinition());
+            assertNotNull(vc.getString());
         }
     }
 
@@ -185,7 +185,7 @@
             ValueConstraint vc2 = createValueConstraint(qDefs[i]);
             assertEquals(vc, vc2);
 
-            vc2 = createValueConstraint(vc.getQualifiedDefinition());
+            vc2 = createValueConstraint(vc.getString());
             assertEquals(vc, vc2);
         }
     }

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/resources/cnd-reader-test-input.cnd Wed
Jun 17 20:21:54 2009
@@ -44,6 +44,32 @@
 [ex:Path]
   - ex:path (path) < 'ex:a/ex:b'  
 
+[ex:Full] > ex:NodeType
+  orderable mixin abstract primaryitem ex:p1 noquery
+  - ex:p1 (STRING) mandatory protected autocreated multiple
+  - ex:p2 (BINARY) queryops '=, <>, <, <=, >, >=, LIKE'
+  - ex:p3 (LONG) nofulltext noqueryorder
+  - ex:p4 (DOUBLE)
+  - ex:p5 (BOOLEAN)
+  - ex:p6 (NAME)
+  - ex:p8 (PATH)
+  - ex:p9 (REFERENCE)
+  - ex:pa (WEAKREFERENCE)
+  - ex:pb (DECIMAL)
+  - ex:pc (URI)
+  - ex:pd (UNDEFINED)
+  - ex:pf (*)
+  + ex:n1 (ex:NodeType) COPY
+  + ex:n2 (ex:NodeType) VERSION
+  + ex:n3 (ex:NodeType) INITIALIZE
+  + ex:n4 (ex:NodeType) COMPUTE
+  + ex:n5 (ex:NodeType) IGNORE
+  + ex:n6 (ex:NodeType) ABORT
+
+[ex:Full1] > ex:NodeType
+  orderable mixin abstract primaryitem ex:p1 query
+  - ex:p1
+
 //------------------------------------------------------------------------------
 // B A S E  T Y P E S
 //------------------------------------------------------------------------------

Modified: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QPropertyDefinition.java
Wed Jun 17 20:21:54 2009
@@ -45,7 +45,7 @@
      *
      * @return the array of value constraints.
      */
-    public String[] getValueConstraints();
+    public QValueConstraint[] getValueConstraints();
 
     /**
      * Returns the array of default values or <code>null</code> if no default
@@ -68,7 +68,7 @@
      * @return the availabe query operators.
      * @since JCR 2.0
      */
-    public Name[] getAvailableQueryOperators();
+    public String[] getAvailableQueryOperators();
 
     /**
      * Reports whether this property definition is full text searchable.

Added: jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueConstraint.java?rev=785777&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueConstraint.java
(added)
+++ jackrabbit/trunk/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QValueConstraint.java
Wed Jun 17 20:21:54 2009
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.spi;
+
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.RepositoryException;
+
+/**
+ * <code>QValueConstraint</code> is used to check the syntax of a value
+ * constraint and to test if a specific value satisfies it.
+ *
+ * @see PropertyDefinition#getValueConstraints()
+ */
+public interface QValueConstraint {
+
+    /**
+     * Empty array of <code>QValueConstraint</code>.
+     */
+    public static final QValueConstraint[] EMPTY_ARRAY = new QValueConstraint[0];
+
+    /**
+     * Check if the specified value matches this constraint.
+     *
+     * @param value The value to be tested.
+     * @throws ConstraintViolationException If the specified value is
+     * <code>null</code> or does not matches the constraint.
+     * @throws RepositoryException If another error occurs.
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException;
+
+    /**
+     * For constraints that are not namespace prefix mapping sensitive this
+     * method returns the same defined in
+     * <code>{@link PropertyDefinition#getValueConstraints()}</code>.
+     * <p/>
+     * Those that are namespace prefix mapping sensitive (e.g.
+     * <code>NameConstraint</code>, <code>PathConstraint</code> and
+     * <code>ReferenceConstraint</code>) return an internal string.
+     *
+     * @return the internal definition String
+     */
+    String getString();
+
+}
\ No newline at end of file

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

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

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QNodeTypeDefinitionImpl.java
Wed Jun 17 20:21:54 2009
@@ -29,6 +29,7 @@
 import org.apache.jackrabbit.spi.QNodeDefinition;
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
 
@@ -243,11 +244,11 @@
                 // [WEAK]REFERENCE value constraints
                 if (propDefs[i].getRequiredType() == PropertyType.REFERENCE
                         || propDefs[i].getRequiredType() == PropertyType.WEAKREFERENCE) {
-                    String[] ca = propDefs[i].getValueConstraints();
+                    QValueConstraint[] ca = propDefs[i].getValueConstraints();
                     if (ca != null) {
                         for (int j = 0; j < ca.length; j++) {
                             // TODO: don't rely on a specific factory
-                            Name ntName = NameFactoryImpl.getInstance().create(ca[j]);
+                            Name ntName = NameFactoryImpl.getInstance().create(ca[j].getString());
                             if (!name.equals(ntName)) {
                                 dependencies.add(ntName);
                             }

Modified: jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QPropertyDefinitionImpl.java
Wed Jun 17 20:21:54 2009
@@ -21,8 +21,10 @@
 import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.QValueConstraint;
 import org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.webdav.xml.DomUtil;
 import org.apache.jackrabbit.webdav.xml.ElementIterator;
 import org.w3c.dom.Element;
@@ -50,7 +52,7 @@
     /**
      * The value constraints.
      */
-    private final String[] valueConstraints;
+    private final QValueConstraint[] valueConstraints;
 
     /**
      * The default values.
@@ -62,7 +64,7 @@
      */
     private final boolean multiple;
 
-    private final Name[] availableQueryOperators;
+    private final String[] availableQueryOperators;
     private final boolean fullTextSearcheable;
     private final boolean queryOrderable;
 
@@ -126,37 +128,31 @@
 
         child = DomUtil.getChildElement(pdefElement, VALUECONSTRAINTS_ELEMENT, null);
         if (child == null) {
-            valueConstraints = new String[0];
+            valueConstraints = QValueConstraint.EMPTY_ARRAY;
         } else {
-            List vc = new ArrayList();
+            List<QValueConstraint> vc = new ArrayList<QValueConstraint>();
             ElementIterator it = DomUtil.getChildren(child, VALUECONSTRAINT_ELEMENT, null);
             while (it.hasNext()) {
-                int constType = (requiredType == PropertyType.REFERENCE
-                        || requiredType == PropertyType.WEAKREFERENCE) ?  PropertyType.NAME
: requiredType;
                 String qValue = DomUtil.getText(it.nextElement());
                 // in case of name and path constraint, the value must be
                 // converted to SPI values
                 // TODO: tobefixed. path-constraint may contain trailing *
-                if (constType == PropertyType.NAME || constType == PropertyType.PATH) {
-                   qValue = ValueFormat.getQValue(qValue, constType, resolver, qValueFactory).getString();
-                }
-                vc.add(qValue);
+                vc.add(ValueConstraint.create(requiredType, qValue));
             }
-            valueConstraints = (String[]) vc.toArray(new String[vc.size()]);
+            valueConstraints = vc.toArray(new QValueConstraint[vc.size()]);
         }
 
         child = DomUtil.getChildElement(pdefElement, AVAILABLE_QUERY_OPERATORS_ELEMENT, null);
         if (child == null) {
-            availableQueryOperators = new Name[0];
+            availableQueryOperators = new String[0];
         } else {
-            List names = new ArrayList();
+            List<String> names = new ArrayList<String>();
             ElementIterator it = DomUtil.getChildren(child, AVAILABLE_QUERY_OPERATOR_ELEMENT,
null);
             while (it.hasNext()) {
                 String str = DomUtil.getText(it.nextElement());
-                Name n = resolver.getQName(str);
-                names.add(n);
+                names.add(str);
             }
-            availableQueryOperators = (Name[]) names.toArray(new Name[names.size()]);
+            availableQueryOperators = names.toArray(new String[names.size()]);
         }
     }
     
@@ -171,7 +167,7 @@
     /**
      * {@inheritDoc}
      */
-    public String[] getValueConstraints() {
+    public QValueConstraint[] getValueConstraints() {
         return valueConstraints;
     }
 
@@ -192,7 +188,7 @@
     /**
      * {@inheritDoc}
      */
-    public Name[] getAvailableQueryOperators() {
+    public String[] getAvailableQueryOperators() {
         return availableQueryOperators;
     }
 

Modified: jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java?rev=785777&r1=785776&r2=785777&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QPropertyDefinitionImpl.java
Wed Jun 17 20:21:54 2009
@@ -19,10 +19,12 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.QValueFactory;
 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.conversion.NameException;
 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.nodetype.PropertyDefinition;
 import javax.jcr.RepositoryException;
@@ -53,13 +55,17 @@
             throws RepositoryException, NameException {
         super(propDef.getName().equals(ANY_NAME.getLocalName()) ? ANY_NAME : resolver.getQName(propDef.getName()),
                 resolver.getQName(propDef.getDeclaringNodeType().getName()),
-                propDef.isAutoCreated(), propDef.isMandatory(),
-                propDef.getOnParentVersion(), propDef.isProtected(),
+                propDef.isAutoCreated(),
+                propDef.isMandatory(),
+                propDef.getOnParentVersion(),
+                propDef.isProtected(),
                 convertValues(propDef.getDefaultValues(), resolver, qValueFactory),
-                propDef.isMultiple(), propDef.getRequiredType(),
-                convertConstraints(propDef.getValueConstraints(), resolver, qValueFactory,
propDef.getRequiredType()),
-                convertQueryOperators(propDef.getAvailableQueryOperators(), resolver),
-                propDef.isFullTextSearchable(), propDef.isQueryOrderable());
+                propDef.isMultiple(),
+                propDef.getRequiredType(),
+                ValueConstraint.create(propDef.getRequiredType(), propDef.getValueConstraints(),
resolver),
+                propDef.getAvailableQueryOperators(),
+                propDef.isFullTextSearchable(),
+                propDef.isQueryOrderable());
     }
 
     /**
@@ -87,37 +93,6 @@
     }
 
     /**
-     * Makes sure name and path constraints are parsed correctly using the
-     * namespace resolver.
-     *
-     * @param constraints  the constraint strings from the JCR property
-     *                     definition.
-     * @param resolver
-     * @param factory      the QValueFactory.
-     * @param requiredType the required type of the property definition.
-     * @return SPI formatted constraint strings.
-     * @throws RepositoryException if an error occurs while converting the
-     *                             constraint strings.
-     */
-    private static String[] convertConstraints(String[] constraints,
-                                               NamePathResolver resolver,
-                                               QValueFactory factory,
-                                               int requiredType)
-            throws RepositoryException {
-        if (requiredType == PropertyType.REFERENCE
-                || requiredType == PropertyType.WEAKREFERENCE
-                || requiredType == PropertyType.NAME
-                || requiredType == PropertyType.PATH) {
-            int type = ((requiredType == PropertyType.REFERENCE || requiredType == PropertyType.WEAKREFERENCE)
? PropertyType.NAME : requiredType);
-            for (int i = 0; i < constraints.length; i++) {
-                constraints[i] = ValueFormat.getQValue(
-                        constraints[i], type, resolver, factory).getString();
-            }
-        }
-        return constraints;
-    }
-
-    /**
      * Convert String jcr names to Name objects.
      *
      * @param aqos



Mime
View raw message