diff --git a/source/java/org/alfresco/service/cmr/dictionary/Constraint.java b/source/java/org/alfresco/service/cmr/dictionary/Constraint.java
new file mode 100644
index 0000000000..413423d31d
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/dictionary/Constraint.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * 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.alfresco.service.cmr.dictionary;
+
+
+/**
+ * The interface for classes that implement constraints on property values.
+ *
+ * Implementations of the actual constraint code should must not synchronize
+ * or in any other way block threads. Concurrent access of the evaluation
+ * method is expected, but will always occur after initialization has completed.
+ *
+ * Attention to performance is crucial for all implementations as
+ * instances of this class are heavily used.
+ *
+ * The constraint implementations can provide standard setter methods that will
+ * be populated by bean setter injection. Once all the available properties have
+ * been set, the contraint will be initialized.
+ *
+ * @author Derek Hulley
+ */
+public interface Constraint
+{
+ /**
+ * Initializes the constraint with appropriate values, which will depend
+ * on the implementation itself. This method can be implemented as a
+ * once-off, i.e. reinitialization does not have to be supported.
+ *
+ * @param parameters constraint parameters
+ */
+ public void initialize();
+
+ /**
+ * Evaluates a property value according to the implementation and initialization
+ * parameters provided.
+ *
+ * @param value the property value to check
+ *
+ * @throws ConstraintException if the value doesn't pass all constraints
+ */
+ public void evaluate(Object value);
+}
diff --git a/source/java/org/alfresco/service/cmr/dictionary/ConstraintDefinition.java b/source/java/org/alfresco/service/cmr/dictionary/ConstraintDefinition.java
new file mode 100644
index 0000000000..b4cf79aba7
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/dictionary/ConstraintDefinition.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * 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.alfresco.service.cmr.dictionary;
+
+import org.alfresco.service.namespace.QName;
+
+/**
+ * Property constraint definition
+ *
+ * @author Derek Hulley
+ */
+public interface ConstraintDefinition
+{
+ /**
+ * @return defining model
+ */
+ public ModelDefinition getModel();
+
+ /**
+ * @return Returns the qualified name of the constraint
+ */
+ public QName getName();
+
+ /**
+ * @return Returns the constraint implementation
+ */
+ public Constraint getConstraint();
+}
diff --git a/source/java/org/alfresco/service/cmr/dictionary/ConstraintException.java b/source/java/org/alfresco/service/cmr/dictionary/ConstraintException.java
new file mode 100644
index 0000000000..1a84ba2d5a
--- /dev/null
+++ b/source/java/org/alfresco/service/cmr/dictionary/ConstraintException.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * 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.alfresco.service.cmr.dictionary;
+
+import org.alfresco.error.AlfrescoRuntimeException;
+
+/**
+ * Thrown when property value fails to meet a property constraint.
+ *
+ * @author Derek Hulley
+ */
+public class ConstraintException extends AlfrescoRuntimeException
+{
+ private static final long serialVersionUID = -3925105163386197586L;
+
+ public ConstraintException(String msgId, Object ... args)
+ {
+ super(msgId, args);
+ }
+}
diff --git a/source/java/org/alfresco/service/cmr/dictionary/DictionaryException.java b/source/java/org/alfresco/service/cmr/dictionary/DictionaryException.java
index fb62d706cd..b9d3c6dbbf 100644
--- a/source/java/org/alfresco/service/cmr/dictionary/DictionaryException.java
+++ b/source/java/org/alfresco/service/cmr/dictionary/DictionaryException.java
@@ -16,13 +16,14 @@
*/
package org.alfresco.service.cmr.dictionary;
+import org.alfresco.error.AlfrescoRuntimeException;
/**
* Base Exception of Data Dictionary Exceptions.
*
* @author David Caruana
*/
-public class DictionaryException extends RuntimeException
+public class DictionaryException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 3257008761007847733L;
@@ -36,4 +37,13 @@ public class DictionaryException extends RuntimeException
super(msg, cause);
}
+ public DictionaryException(String msgId, Object ... args)
+ {
+ super(msgId, args);
+ }
+
+ public DictionaryException(String msgId, Throwable cause, Object ... args)
+ {
+ super(msgId, args, cause);
+ }
}
diff --git a/source/java/org/alfresco/service/cmr/dictionary/PropertyDefinition.java b/source/java/org/alfresco/service/cmr/dictionary/PropertyDefinition.java
index af519bf2f8..4b38993c6f 100644
--- a/source/java/org/alfresco/service/cmr/dictionary/PropertyDefinition.java
+++ b/source/java/org/alfresco/service/cmr/dictionary/PropertyDefinition.java
@@ -16,6 +16,8 @@
*/
package org.alfresco.service.cmr.dictionary;
+import java.util.List;
+
import org.alfresco.service.namespace.QName;
/**
@@ -98,4 +100,10 @@ public interface PropertyDefinition
*/
public boolean isIndexedAtomically();
+ /**
+ * Get all constraints that apply to the property value
+ *
+ * @return Returns a list of property constraint definitions
+ */
+ public List getConstraints();
}