Property constraint dictionary support

Constraint implementation support
Regular expression constraint


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2547 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-03-14 22:57:50 +00:00
parent f3658f2a58
commit 783de4f80a
24 changed files with 1066 additions and 54 deletions

View File

@@ -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.
* <p>
* 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.
* <p>
* Attention to performance is <u>crucial</u> for all implementations as
* instances of this class are heavily used.
* <p>
* 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);
}

View File

@@ -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();
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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<ConstraintDefinition> getConstraints();
}