You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2009/05/27 11:14:54 UTC

svn commit: r779068 [1/2] - in /jackrabbit/trunk/jackrabbit-spi-commons/src: main/java/org/apache/jackrabbit/spi/commons/nodetype/ main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/ main/java/org/apache/jackrabbit/spi/commons/nodetype/constr...

Author: jukka
Date: Wed May 27 09:14:53 2009
New Revision: 779068

URL: http://svn.apache.org/viewvc?rev=779068&view=rev
Log:
JCR-97: Improve Checkstyle conformance

Move the ValueConstraint classes from a single .java file to multiple files, one per class. Use a new package (org.apache.jackrabbit.spi.commons.nodetype.constraint) for this.

Added:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java   (with props)
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/BooleanConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/DateConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NameConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NumericConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/PathConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ReferenceConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/StringConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraintTest.java
      - copied, changed from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraintTest.java
Removed:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraint.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/BooleanConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/DateConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NameConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NumericConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/PathConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ReferenceConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/StringConstraintTest.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraintTest.java
Modified:
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/PropertyDefinitionImpl.java
    jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java

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=779068&r1=779067&r2=779068&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 May 27 09:14:53 2009
@@ -22,6 +22,7 @@
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.Name;
 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;

Modified: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java?rev=779068&r1=779067&r2=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/compact/QNodeTypeDefinitionsBuilderImpl.java Wed May 27 09:14:53 2009
@@ -31,7 +31,7 @@
 import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
 import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
-import org.apache.jackrabbit.spi.commons.nodetype.ValueConstraint;
+import org.apache.jackrabbit.spi.commons.nodetype.constraint.ValueConstraint;
 import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
 import org.apache.jackrabbit.spi.commons.value.ValueFormat;
 

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java?rev=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.constraint;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+
+/**
+ * <code>BooleanConstraint</code> ...
+ */
+class BooleanConstraint extends ValueConstraint {
+
+    private final boolean reqBool;
+
+    public BooleanConstraint(String definition) throws InvalidConstraintException {
+        super(definition);
+
+        // constraint format: 'true' or 'false'
+        if (definition.equals("true")) {
+            reqBool = true;
+        } else if (definition.equals("false")) {
+            reqBool = false;
+        } else {
+            String msg = "'" + definition
+                    + "' is not a valid value constraint format for BOOLEAN values";
+            log.debug(msg);
+            throw new InvalidConstraintException(msg);
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '"  + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.BOOLEAN:
+                boolean b = Boolean.valueOf(value.getString()).booleanValue();
+                if (b != reqBool) {
+                    throw new ConstraintViolationException("'" + b + "' does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+                }
+                return;
+
+            default:
+                String msg = "BOOLEAN constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java?rev=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,163 @@
+/*
+ * 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.constraint;
+
+import java.util.Calendar;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.apache.jackrabbit.value.DateValue;
+
+/**
+ * <code>DateConstraint</code> ...
+ */
+class DateConstraint extends ValueConstraint {
+
+    private final boolean lowerInclusive;
+
+    private final Calendar lowerLimit;
+
+    private final boolean upperInclusive;
+
+    private final Calendar upperLimit;
+
+    public DateConstraint(String definition) throws InvalidConstraintException {
+        super(definition);
+
+        // format: '(<fromDate>, <toDate>)', '[<fromDate>, <toDate>]', '[, <toDate>]' etc.
+        Pattern pattern = Pattern.compile("([\\(\\[]) *([0-9TZ\\.\\+-:]*)? *, *([0-9TZ\\.\\+-:]*)? *([\\)\\]])");
+        Matcher matcher = pattern.matcher(definition);
+        if (matcher.matches()) {
+            try {
+                // group 1 is lower inclusive/exclusive
+                String s = matcher.group(1);
+                lowerInclusive = s.equals("[");
+                // group 2 is lower limit
+                s = matcher.group(2);
+                if (s == null || s.length() == 0) {
+                    lowerLimit = null;
+                } else {
+                    lowerLimit = DateValue.valueOf(matcher.group(2)).getDate();
+                }
+                // group 3 is upper limit
+                s = matcher.group(3);
+                if (s == null || s.length() == 0) {
+                    upperLimit = null;
+                } else {
+                    upperLimit = DateValue.valueOf(matcher.group(3)).getDate();
+                }
+                // group 4 is upepr inclusive/exclusive
+                s = matcher.group(4);
+                upperInclusive = s.equals("]");
+
+                if (lowerLimit == null && upperLimit == null) {
+                    String msg = "'" + definition
+                            + "' is not a valid value constraint format for dates: neither min- nor max-date specified";
+                    log.debug(msg);
+                    throw new InvalidConstraintException(msg);
+                }
+                if (lowerLimit != null && upperLimit != null) {
+                    if (lowerLimit.after(upperLimit)) {
+                        String msg = "'" + definition
+                                + "' is not a valid value constraint format for dates: min-date > max-date";
+                        log.debug(msg);
+                        throw new InvalidConstraintException(msg);
+                    }
+                }
+            } catch (ValueFormatException vfe) {
+                String msg = "'" + definition
+                        + "' is not a valid value constraint format for dates";
+                log.debug(msg);
+                throw new InvalidConstraintException(msg, vfe);
+            } catch (RepositoryException re) {
+                String msg = "'" + definition
+                        + "' is not a valid value constraint format for dates";
+                log.debug(msg);
+                throw new InvalidConstraintException(msg, re);
+            }
+        } else {
+            String msg = "'" + definition
+                    + "' is not a valid value constraint format for dates";
+            log.debug(msg);
+            throw new InvalidConstraintException(msg);
+        }
+    }
+
+    private void check(Calendar cal) throws ConstraintViolationException {
+        if (cal == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        if (lowerLimit != null) {
+            if (lowerInclusive) {
+                if (cal.getTimeInMillis() < lowerLimit.getTimeInMillis()) {
+                    throw new ConstraintViolationException(cal
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            } else {
+                if (cal.getTimeInMillis() <= lowerLimit.getTimeInMillis()) {
+                    throw new ConstraintViolationException(cal
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            }
+        }
+        if (upperLimit != null) {
+            if (upperInclusive) {
+                if (cal.getTimeInMillis() > upperLimit.getTimeInMillis()) {
+                    throw new ConstraintViolationException(cal
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            } else {
+                if (cal.getTimeInMillis() >= upperLimit.getTimeInMillis()) {
+                    throw new ConstraintViolationException(cal
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            }
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.DATE:
+                check(value.getCalendar());
+                return;
+
+            default:
+                String msg = "DATE constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java?rev=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,106 @@
+/*
+ * 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.constraint;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+
+/**
+ * <code>NameConstraint</code> ...
+ */
+class NameConstraint extends ValueConstraint {
+
+    private final Name name;
+
+    static NameConstraint create(String qualifiedDefinition) {
+        // constraint format: String representation of qualified name
+        return new NameConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
+    }
+
+    static NameConstraint create(String definition, NameResolver resolver)
+            throws InvalidConstraintException {
+        // constraint format: JCR name in prefix form
+        try {
+            Name name = resolver.getQName(definition);
+            return new NameConstraint(name.toString(), name);
+        } catch (NameException e) {
+            String msg = "Invalid name constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        } catch (NamespaceException e) {
+            String msg = "Invalid name constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        }
+    }
+
+    private NameConstraint(String qualifiedDefinition, Name name) {
+        super(qualifiedDefinition);
+        this.name = name;
+    }
+
+    /**
+     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
+     * qualified <code>Name</code> into a JCR name.
+     *
+     * @see ValueConstraint#getDefinition(NamePathResolver)
+     * @param resolver
+     */
+    public String getDefinition(NamePathResolver resolver) {
+        try {
+            return resolver.getJCRName(name);
+        } catch (NamespaceException e) {
+            // should never get here, return raw definition as fallback
+            return getQualifiedDefinition();
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.NAME:
+                Name n = value.getName();
+                if (!name.equals(n)) {
+                    throw new ConstraintViolationException(n
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+                return;
+
+            default:
+                String msg = "NAME constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java?rev=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,165 @@
+/*
+ * 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.constraint;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+
+/**
+ * <code>NumericConstraint</code> ...
+ */
+class NumericConstraint extends ValueConstraint {
+
+    private final boolean lowerInclusive;
+
+    private final Double lowerLimit;
+
+    private final boolean upperInclusive;
+
+    private final Double upperLimit;
+
+    public NumericConstraint(String definition) throws InvalidConstraintException {
+        super(definition);
+
+        // format: '(<min>, <max>)',  '[<min>, <max>]', '(, <max>)' etc.
+        Pattern pattern = Pattern.compile("([\\(\\[]) *(\\-?\\d+\\.?\\d*)? *, *(\\-?\\d+\\.?\\d*)? *([\\)\\]])");
+        Matcher matcher = pattern.matcher(definition);
+        if (matcher.matches()) {
+            try {
+                // group 1 is lower inclusive/exclusive
+                String s = matcher.group(1);
+                lowerInclusive = s.equals("[");
+                // group 2 is lower limit
+                s = matcher.group(2);
+                if (s == null || s.length() == 0) {
+                    lowerLimit = null;
+                } else {
+                    lowerLimit = Double.valueOf(matcher.group(2));
+                }
+                // group 3 is upper limit
+                s = matcher.group(3);
+                if (s == null || s.length() == 0) {
+                    upperLimit = null;
+                } else {
+                    upperLimit = Double.valueOf(matcher.group(3));
+                }
+                // group 4 is lower inclusive/exclusive
+                s = matcher.group(4);
+                upperInclusive = s.equals("]");
+                if (lowerLimit == null && upperLimit == null) {
+                    String msg = "'" + definition + "' is not a valid value constraint"
+                            + " format for numeric types: neither lower- nor upper-limit specified";
+                    log.debug(msg);
+                    throw new InvalidConstraintException(msg);
+                }
+                if (lowerLimit != null && upperLimit != null) {
+                    if (lowerLimit.doubleValue() > upperLimit.doubleValue()) {
+                        String msg = "'" + definition
+                                + "' is not a valid value constraint format for numeric types: lower-limit exceeds upper-limit";
+                        log.debug(msg);
+                        throw new InvalidConstraintException(msg);
+                    }
+                }
+            } catch (NumberFormatException nfe) {
+                String msg = "'" + definition
+                        + "' is not a valid value constraint format for numeric types";
+                log.debug(msg);
+                throw new InvalidConstraintException(msg, nfe);
+            }
+        } else {
+            String msg = "'" + definition
+                    + "' is not a valid value constraint format for numeric values";
+            log.debug(msg);
+            throw new InvalidConstraintException(msg);
+        }
+    }
+
+    private void check(double number) throws ConstraintViolationException {
+        if (lowerLimit != null) {
+            if (lowerInclusive) {
+                if (number < lowerLimit.doubleValue()) {
+                    throw new ConstraintViolationException(number
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            } else {
+                if (number <= lowerLimit.doubleValue()) {
+                    throw new ConstraintViolationException(number
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            }
+        }
+        if (upperLimit != null) {
+            if (upperInclusive) {
+                if (number > upperLimit.doubleValue()) {
+                    throw new ConstraintViolationException(number
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            } else {
+                if (number >= upperLimit.doubleValue()) {
+                    throw new ConstraintViolationException(number
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                }
+            }
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '"
+                    + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.LONG:
+                check(value.getLong());
+                return;
+
+            case PropertyType.DOUBLE:
+                check(value.getDouble());
+                return;
+
+            case PropertyType.BINARY:
+                long length = value.getLength();
+                if (length != -1) {
+                    check(length);
+                } else {
+                    log.warn("failed to determine length of binary value");
+                }
+                return;
+
+            default:
+                String msg = "numeric constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: 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=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,163 @@
+/*
+ * 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.constraint;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+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.nodetype.InvalidConstraintException;
+
+/**
+ * <code>PathConstraint</code> ...
+ */
+class PathConstraint extends ValueConstraint {
+
+    private final Path path;
+    private final boolean deep;
+
+    static PathConstraint create(String qualifiedDefinition) throws InvalidConstraintException {
+        // constraint format: qualified absolute or relative path with optional trailing wildcard
+        boolean deep = qualifiedDefinition.endsWith("*");
+        Path path;
+        // TODO improve. don't rely on a specific factory impl
+        if (deep) {
+            path = PathFactoryImpl.getInstance().create(qualifiedDefinition.substring(0, qualifiedDefinition.length() - 1));
+        } else {
+            path = PathFactoryImpl.getInstance().create(qualifiedDefinition);
+        }
+        return new PathConstraint(qualifiedDefinition, path, deep);
+    }
+
+    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("/*");
+            if (deep) {
+                // 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());
+
+            return new PathConstraint(qualifiedDefinition.toString(), path, deep);
+        } catch (NameException e) {
+            String msg = "Invalid path expression specified as value constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        } catch (NamespaceException e) {
+            String msg = "Invalid path expression specified as value constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        }
+    }
+
+    private PathConstraint(String qualifiedDefinition, Path path, boolean deep) throws InvalidConstraintException {
+        super(qualifiedDefinition);
+        this.path = path;
+        this.deep = deep;
+    }
+
+    /**
+     * Uses {@link NamePathResolver#getJCRPath(Path)} to convert the
+     * qualified <code>Path</code> into a JCR path.
+     *
+     * @see ValueConstraint#getDefinition(NamePathResolver)
+     * @param resolver
+     */
+    public String getDefinition(NamePathResolver resolver) {
+        try {
+            String p = resolver.getJCRPath(path);
+            if (!deep) {
+                return p;
+            } else if (path.denotesRoot()) {
+                return p + "*";
+            } else {
+                return p + "/*";
+            }
+        } catch (NamespaceException e) {
+            // should never get here, return raw definition as fallback
+            return getQualifiedDefinition();
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.PATH:
+                Path p = value.getPath();
+                // normalize paths before comparing them
+                Path p0, p1;
+                try {
+                    p0 = path.getNormalizedPath();
+                    p1 = p.getNormalizedPath();
+                } catch (RepositoryException e) {
+                    throw new ConstraintViolationException("path not valid: " + e);
+                }
+                if (deep) {
+                    try {
+                        if (!p0.isAncestorOf(p1)) {
+                            throw new ConstraintViolationException(p
+                                + " does not satisfy the constraint '"
+                                + getQualifiedDefinition() + "'");
+                        }
+                    } catch (RepositoryException e) {
+                        // can't compare relative with absolute path
+                        throw new ConstraintViolationException(p
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                    }
+                } else {
+                    // exact match required
+                    if (!p0.equals(p1)) {
+                        throw new ConstraintViolationException(p
+                            + " does not satisfy the constraint '"
+                            + getQualifiedDefinition() + "'");
+                    }
+                }
+                return;
+
+            default:
+                String msg = "PATH constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: 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=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,102 @@
+/*
+ * 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.constraint;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NameException;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+
+/**
+ * <code>ReferenceConstraint</code> ...
+ */
+class ReferenceConstraint extends ValueConstraint {
+
+    private final Name ntName;
+
+    static ReferenceConstraint create(String qualifiedDefinition) {
+        // constraint format: String representation of qualified name
+        return new ReferenceConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
+    }
+
+    static ReferenceConstraint create(String definition, NameResolver resolver)
+            throws InvalidConstraintException {
+        // constraint format: JCR name in prefix form
+        try {
+            Name name = resolver.getQName(definition);
+            return new ReferenceConstraint(name.toString(), name);
+        } catch (NameException e) {
+            String msg = "Invalid name constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        } catch (NamespaceException e) {
+            String msg = "Invalid name constraint: " + definition;
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, e);
+        }
+    }
+
+    private ReferenceConstraint(String qualifiedDefinition, Name ntName) {
+        super(qualifiedDefinition);
+        this.ntName = ntName;
+    }
+
+    /**
+     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
+     * qualified <code>Name</code> into a JCR name.
+     *
+     * @see ValueConstraint#getDefinition(NamePathResolver)
+     * @param 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();
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("Null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.REFERENCE:
+                // TODO check REFERENCE value constraint (requires a session)
+                log.warn("validation of REFERENCE constraint is not yet implemented");
+                return;
+
+            default:
+                String msg = "REFERENCE constraint can not be applied to value of type: "
+                        + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Added: 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=779068&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java (added)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraint.java Wed May 27 09:14:53 2009
@@ -0,0 +1,73 @@
+/*
+ * 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.constraint;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.ConstraintViolationException;
+
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+
+/**
+ * <code>StringConstraint</code> ...
+ */
+class StringConstraint extends ValueConstraint {
+
+    private final Pattern pattern;
+
+    public StringConstraint(String definition) throws InvalidConstraintException {
+        super(definition);
+
+        // constraint format: regexp
+        try {
+            pattern = Pattern.compile(definition);
+        } catch (PatternSyntaxException pse) {
+            String msg = "'" + definition + "' is not valid regular expression syntax";
+            log.debug(msg);
+            throw new InvalidConstraintException(msg, pse);
+        }
+    }
+
+    /**
+     * @see ValueConstraint#check(QValue)
+     */
+    void check(QValue value) throws ConstraintViolationException, RepositoryException {
+        if (value == null) {
+            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+        }
+        switch (value.getType()) {
+            case PropertyType.STRING:
+                String text = value.getString();
+                Matcher matcher = pattern.matcher(text);
+                if (!matcher.matches()) {
+                    throw new ConstraintViolationException("'" + text  + "' does not satisfy the constraint '" + getQualifiedDefinition() + "'");
+                }
+                return;
+
+            default:
+                String msg = "STRING constraint can not be applied to value of type: " + PropertyType.nameFromValue(value.getType());
+                log.debug(msg);
+                throw new RepositoryException(msg);
+        }
+    }
+
+}

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

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/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?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraint.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/ValueConstraint.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ValueConstraint.java Wed May 27 09:14:53 2009
@@ -14,32 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
-import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
-import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
-import org.apache.jackrabbit.spi.commons.conversion.NameException;
-import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
-import org.apache.jackrabbit.spi.Name;
-import org.apache.jackrabbit.spi.Path;
-import org.apache.jackrabbit.spi.QPropertyDefinition;
-import org.apache.jackrabbit.spi.QValue;
-import org.apache.jackrabbit.spi.NameFactory;
-import org.apache.jackrabbit.value.DateValue;
-import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
-import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
-import org.slf4j.LoggerFactory;
-import org.slf4j.Logger;
 
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
-import javax.jcr.ValueFormatException;
-import javax.jcr.NamespaceException;
 import javax.jcr.nodetype.ConstraintViolationException;
-import java.util.Calendar;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
+
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.commons.conversion.NamePathResolver;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.nodetype.InvalidConstraintException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * <code>ValueConstraint</code> and its subclasses are used to check the
@@ -265,645 +254,5 @@
             }
         }
     }
-}
-
-//---------------------------------------------< Subclass BooleanConstraint >---
-/**
- * <code>BooleanConstraint</code> ...
- */
-class BooleanConstraint extends ValueConstraint {
-    final boolean reqBool;
-
-    BooleanConstraint(String definition) throws InvalidConstraintException {
-        super(definition);
-
-        // constraint format: 'true' or 'false'
-        if (definition.equals("true")) {
-            reqBool = true;
-        } else if (definition.equals("false")) {
-            reqBool = false;
-        } else {
-            String msg = "'" + definition
-                    + "' is not a valid value constraint format for BOOLEAN values";
-            log.debug(msg);
-            throw new InvalidConstraintException(msg);
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '"  + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.BOOLEAN:
-                boolean b = Boolean.valueOf(value.getString()).booleanValue();
-                if (b != reqBool) {
-                    throw new ConstraintViolationException("'" + b + "' does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-                }
-                return;
-
-            default:
-                String msg = "BOOLEAN constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-//----------------------------------------------< Subclass StringConstraint >---
-/**
- * <code>StringConstraint</code> ...
- */
-class StringConstraint extends ValueConstraint {
-    final Pattern pattern;
-
-    StringConstraint(String definition) throws InvalidConstraintException {
-        super(definition);
-
-        // constraint format: regexp
-        try {
-            pattern = Pattern.compile(definition);
-        } catch (PatternSyntaxException pse) {
-            String msg = "'" + definition + "' is not valid regular expression syntax";
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, pse);
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.STRING:
-                String text = value.getString();
-                Matcher matcher = pattern.matcher(text);
-                if (!matcher.matches()) {
-                    throw new ConstraintViolationException("'" + text  + "' does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-                }
-                return;
-
-            default:
-                String msg = "STRING constraint can not be applied to value of type: " + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-//---------------------------------------------< Subclass NumericConstraint >---
-/**
- * <code>NumericConstraint</code> ...
- */
-class NumericConstraint extends ValueConstraint {
-    final boolean lowerInclusive;
-    final Double lowerLimit;
-    final boolean upperInclusive;
-    final Double upperLimit;
-
-    NumericConstraint(String definition) throws InvalidConstraintException {
-        super(definition);
-
-        // format: '(<min>, <max>)',  '[<min>, <max>]', '(, <max>)' etc.
-        Pattern pattern = Pattern.compile("([\\(\\[]) *(\\-?\\d+\\.?\\d*)? *, *(\\-?\\d+\\.?\\d*)? *([\\)\\]])");
-        Matcher matcher = pattern.matcher(definition);
-        if (matcher.matches()) {
-            try {
-                // group 1 is lower inclusive/exclusive
-                String s = matcher.group(1);
-                lowerInclusive = s.equals("[");
-                // group 2 is lower limit
-                s = matcher.group(2);
-                if (s == null || s.length() == 0) {
-                    lowerLimit = null;
-                } else {
-                    lowerLimit = Double.valueOf(matcher.group(2));
-                }
-                // group 3 is upper limit
-                s = matcher.group(3);
-                if (s == null || s.length() == 0) {
-                    upperLimit = null;
-                } else {
-                    upperLimit = Double.valueOf(matcher.group(3));
-                }
-                // group 4 is lower inclusive/exclusive
-                s = matcher.group(4);
-                upperInclusive = s.equals("]");
-                if (lowerLimit == null && upperLimit == null) {
-                    String msg = "'" + definition + "' is not a valid value constraint"
-                            + " format for numeric types: neither lower- nor upper-limit specified";
-                    log.debug(msg);
-                    throw new InvalidConstraintException(msg);
-                }
-                if (lowerLimit != null && upperLimit != null) {
-                    if (lowerLimit.doubleValue() > upperLimit.doubleValue()) {
-                        String msg = "'" + definition
-                                + "' is not a valid value constraint format for numeric types: lower-limit exceeds upper-limit";
-                        log.debug(msg);
-                        throw new InvalidConstraintException(msg);
-                    }
-                }
-            } catch (NumberFormatException nfe) {
-                String msg = "'" + definition
-                        + "' is not a valid value constraint format for numeric types";
-                log.debug(msg);
-                throw new InvalidConstraintException(msg, nfe);
-            }
-        } else {
-            String msg = "'" + definition
-                    + "' is not a valid value constraint format for numeric values";
-            log.debug(msg);
-            throw new InvalidConstraintException(msg);
-        }
-    }
 
-    private void check(double number) throws ConstraintViolationException {
-        if (lowerLimit != null) {
-            if (lowerInclusive) {
-                if (number < lowerLimit.doubleValue()) {
-                    throw new ConstraintViolationException(number
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            } else {
-                if (number <= lowerLimit.doubleValue()) {
-                    throw new ConstraintViolationException(number
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            }
-        }
-        if (upperLimit != null) {
-            if (upperInclusive) {
-                if (number > upperLimit.doubleValue()) {
-                    throw new ConstraintViolationException(number
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            } else {
-                if (number >= upperLimit.doubleValue()) {
-                    throw new ConstraintViolationException(number
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            }
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '"
-                    + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.LONG:
-                check(value.getLong());
-                return;
-
-            case PropertyType.DOUBLE:
-                check(value.getDouble());
-                return;
-
-            case PropertyType.BINARY:
-                long length = value.getLength();
-                if (length != -1) {
-                    check(length);
-                } else {
-                    log.warn("failed to determine length of binary value");
-                }
-                return;
-
-            default:
-                String msg = "numeric constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
 }
-
-//------------------------------------------------< Subclass DateConstraint >---
-/**
- * <code>DateConstraint</code> ...
- */
-class DateConstraint extends ValueConstraint {
-
-    final boolean lowerInclusive;
-    final Calendar lowerLimit;
-    final boolean upperInclusive;
-    final Calendar upperLimit;
-
-    DateConstraint(String definition) throws InvalidConstraintException {
-        super(definition);
-
-        // format: '(<fromDate>, <toDate>)', '[<fromDate>, <toDate>]', '[, <toDate>]' etc.
-        Pattern pattern = Pattern.compile("([\\(\\[]) *([0-9TZ\\.\\+-:]*)? *, *([0-9TZ\\.\\+-:]*)? *([\\)\\]])");
-        Matcher matcher = pattern.matcher(definition);
-        if (matcher.matches()) {
-            try {
-                // group 1 is lower inclusive/exclusive
-                String s = matcher.group(1);
-                lowerInclusive = s.equals("[");
-                // group 2 is lower limit
-                s = matcher.group(2);
-                if (s == null || s.length() == 0) {
-                    lowerLimit = null;
-                } else {
-                    lowerLimit = DateValue.valueOf(matcher.group(2)).getDate();
-                }
-                // group 3 is upper limit
-                s = matcher.group(3);
-                if (s == null || s.length() == 0) {
-                    upperLimit = null;
-                } else {
-                    upperLimit = DateValue.valueOf(matcher.group(3)).getDate();
-                }
-                // group 4 is upepr inclusive/exclusive
-                s = matcher.group(4);
-                upperInclusive = s.equals("]");
-
-                if (lowerLimit == null && upperLimit == null) {
-                    String msg = "'" + definition
-                            + "' is not a valid value constraint format for dates: neither min- nor max-date specified";
-                    log.debug(msg);
-                    throw new InvalidConstraintException(msg);
-                }
-                if (lowerLimit != null && upperLimit != null) {
-                    if (lowerLimit.after(upperLimit)) {
-                        String msg = "'" + definition
-                                + "' is not a valid value constraint format for dates: min-date > max-date";
-                        log.debug(msg);
-                        throw new InvalidConstraintException(msg);
-                    }
-                }
-            } catch (ValueFormatException vfe) {
-                String msg = "'" + definition
-                        + "' is not a valid value constraint format for dates";
-                log.debug(msg);
-                throw new InvalidConstraintException(msg, vfe);
-            } catch (RepositoryException re) {
-                String msg = "'" + definition
-                        + "' is not a valid value constraint format for dates";
-                log.debug(msg);
-                throw new InvalidConstraintException(msg, re);
-            }
-        } else {
-            String msg = "'" + definition
-                    + "' is not a valid value constraint format for dates";
-            log.debug(msg);
-            throw new InvalidConstraintException(msg);
-        }
-    }
-
-    private void check(Calendar cal) throws ConstraintViolationException {
-        if (cal == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        if (lowerLimit != null) {
-            if (lowerInclusive) {
-                if (cal.getTimeInMillis() < lowerLimit.getTimeInMillis()) {
-                    throw new ConstraintViolationException(cal
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            } else {
-                if (cal.getTimeInMillis() <= lowerLimit.getTimeInMillis()) {
-                    throw new ConstraintViolationException(cal
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            }
-        }
-        if (upperLimit != null) {
-            if (upperInclusive) {
-                if (cal.getTimeInMillis() > upperLimit.getTimeInMillis()) {
-                    throw new ConstraintViolationException(cal
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            } else {
-                if (cal.getTimeInMillis() >= upperLimit.getTimeInMillis()) {
-                    throw new ConstraintViolationException(cal
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-            }
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.DATE:
-                check(value.getCalendar());
-                return;
-
-            default:
-                String msg = "DATE constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-//------------------------------------------------< Subclass PathConstraint >---
-/**
- * <code>PathConstraint</code> ...
- */
-class PathConstraint extends ValueConstraint {
-
-    final Path path;
-    final boolean deep;
-
-    static PathConstraint create(String qualifiedDefinition) throws InvalidConstraintException {
-        // constraint format: qualified absolute or relative path with optional trailing wildcard
-        boolean deep = qualifiedDefinition.endsWith("*");
-        Path path;
-        // TODO improve. don't rely on a specific factory impl
-        if (deep) {
-            path = PathFactoryImpl.getInstance().create(qualifiedDefinition.substring(0, qualifiedDefinition.length() - 1));
-        } else {
-            path = PathFactoryImpl.getInstance().create(qualifiedDefinition);
-        }
-        return new PathConstraint(qualifiedDefinition, path, deep);
-    }
-
-    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("/*");
-            if (deep) {
-                // 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());
-
-            return new PathConstraint(qualifiedDefinition.toString(), path, deep);
-        } catch (NameException e) {
-            String msg = "Invalid path expression specified as value constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        } catch (NamespaceException e) {
-            String msg = "Invalid path expression specified as value constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        }
-    }
-
-    private PathConstraint(String qualifiedDefinition, Path path, boolean deep) throws InvalidConstraintException {
-        super(qualifiedDefinition);
-        this.path = path;
-        this.deep = deep;
-    }
-
-    /**
-     * Uses {@link NamePathResolver#getJCRPath(Path)} to convert the
-     * qualified <code>Path</code> into a JCR path.
-     *
-     * @see ValueConstraint#getDefinition(NamePathResolver)
-     * @param resolver
-     */
-    public String getDefinition(NamePathResolver resolver) {
-        try {
-            String p = resolver.getJCRPath(path);
-            if (!deep) {
-                return p;
-            } else if (path.denotesRoot()) {
-                return p + "*";
-            } else {
-                return p + "/*";
-            }
-        } catch (NamespaceException e) {
-            // should never get here, return raw definition as fallback
-            return getQualifiedDefinition();
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.PATH:
-                Path p = value.getPath();
-                // normalize paths before comparing them
-                Path p0, p1;
-                try {
-                    p0 = path.getNormalizedPath();
-                    p1 = p.getNormalizedPath();
-                } catch (RepositoryException e) {
-                    throw new ConstraintViolationException("path not valid: " + e);
-                }
-                if (deep) {
-                    try {
-                        if (!p0.isAncestorOf(p1)) {
-                            throw new ConstraintViolationException(p
-                                + " does not satisfy the constraint '"
-                                + getQualifiedDefinition() + "'");
-                        }
-                    } catch (RepositoryException e) {
-                        // can't compare relative with absolute path
-                        throw new ConstraintViolationException(p
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                    }
-                } else {
-                    // exact match required
-                    if (!p0.equals(p1)) {
-                        throw new ConstraintViolationException(p
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                    }
-                }
-                return;
-
-            default:
-                String msg = "PATH constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-//------------------------------------------------< Subclass NameConstraint >---
-/**
- * <code>NameConstraint</code> ...
- */
-class NameConstraint extends ValueConstraint {
-
-    private final Name name;
-
-    static NameConstraint create(String qualifiedDefinition) {
-        // constraint format: String representation of qualified name
-        return new NameConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
-    }
-
-    static NameConstraint create(String definition, NameResolver resolver)
-            throws InvalidConstraintException {
-        // constraint format: JCR name in prefix form
-        try {
-            Name name = resolver.getQName(definition);
-            return new NameConstraint(name.toString(), name);
-        } catch (NameException e) {
-            String msg = "Invalid name constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        } catch (NamespaceException e) {
-            String msg = "Invalid name constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        }
-    }
-
-    private NameConstraint(String qualifiedDefinition, Name name) {
-        super(qualifiedDefinition);
-        this.name = name;
-    }
-
-    /**
-     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
-     * qualified <code>Name</code> into a JCR name.
-     *
-     * @see ValueConstraint#getDefinition(NamePathResolver)
-     * @param resolver
-     */
-    public String getDefinition(NamePathResolver resolver) {
-        try {
-            return resolver.getJCRName(name);
-        } catch (NamespaceException e) {
-            // should never get here, return raw definition as fallback
-            return getQualifiedDefinition();
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.NAME:
-                Name n = value.getName();
-                if (!name.equals(n)) {
-                    throw new ConstraintViolationException(n
-                            + " does not satisfy the constraint '"
-                            + getQualifiedDefinition() + "'");
-                }
-                return;
-
-            default:
-                String msg = "NAME constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-//-------------------------------------------< Subclass ReferenceConstraint >---
-/**
- * <code>ReferenceConstraint</code> ...
- */
-class ReferenceConstraint extends ValueConstraint {
-
-    private final Name ntName;
-
-    static ReferenceConstraint create(String qualifiedDefinition) {
-        // constraint format: String representation of qualified name
-        return new ReferenceConstraint(qualifiedDefinition, NAME_FACTORY.create(qualifiedDefinition));
-    }
-
-    static ReferenceConstraint create(String definition, NameResolver resolver)
-            throws InvalidConstraintException {
-        // constraint format: JCR name in prefix form
-        try {
-            Name name = resolver.getQName(definition);
-            return new ReferenceConstraint(name.toString(), name);
-        } catch (NameException e) {
-            String msg = "Invalid name constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        } catch (NamespaceException e) {
-            String msg = "Invalid name constraint: " + definition;
-            log.debug(msg);
-            throw new InvalidConstraintException(msg, e);
-        }
-    }
-
-    private ReferenceConstraint(String qualifiedDefinition, Name ntName) {
-        super(qualifiedDefinition);
-        this.ntName = ntName;
-    }
-
-    /**
-     * Uses {@link NamePathResolver#getJCRName(Name)} to convert the
-     * qualified <code>Name</code> into a JCR name.
-     *
-     * @see ValueConstraint#getDefinition(NamePathResolver)
-     * @param 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();
-        }
-    }
-
-    /**
-     * @see ValueConstraint#check(QValue)
-     */
-    void check(QValue value) throws ConstraintViolationException, RepositoryException {
-        if (value == null) {
-            throw new ConstraintViolationException("Null value does not satisfy the constraint '" + getQualifiedDefinition() + "'");
-        }
-        switch (value.getType()) {
-            case PropertyType.REFERENCE:
-                // TODO check REFERENCE value constraint (requires a session)
-                log.warn("validation of REFERENCE constraint is not yet implemented");
-                return;
-
-            default:
-                String msg = "REFERENCE constraint can not be applied to value of type: "
-                        + PropertyType.nameFromValue(value.getType());
-                log.debug(msg);
-                throw new RepositoryException(msg);
-        }
-    }
-}
-
-
-

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/BooleanConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/BooleanConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/BooleanConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/BooleanConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.apache.jackrabbit.spi.QValue;
 import org.slf4j.Logger;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/DateConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/DateConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/DateConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/DateConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NameConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NameConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NameConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NameConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NumericConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NumericConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/NumericConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/NumericConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/PathConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/PathConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/PathConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/PathConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ReferenceConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ReferenceConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/ReferenceConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/ReferenceConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.apache.jackrabbit.spi.QValue;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;

Copied: jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java (from r779049, jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/StringConstraintTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java?p2=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java&p1=jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/StringConstraintTest.java&r1=779049&r2=779068&rev=779068&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/StringConstraintTest.java (original)
+++ jackrabbit/trunk/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/nodetype/constraint/StringConstraintTest.java Wed May 27 09:14:53 2009
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.jackrabbit.spi.commons.nodetype;
+package org.apache.jackrabbit.spi.commons.nodetype.constraint;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;