AnsweredAssumed Answered

[Solved] Property Integrity Checking in Webscript

Question asked by hyperation on Apr 29, 2010
Latest reply on Apr 29, 2010 by hyperation
Hi Everyone,

I am having trouble trying to figure out how to do Property Value Integrity check within a Java-backed web script.

I have a webscript that allows a user to change property values of an object.  The webscript extends DeclarativeWebscript and the executeImpl method has been override with mechanisms to update an object's property.  I have noticed that Alfresco itself does an Integrity Check for property value updates, but it does not invoked during the webscript execution (it does it after). 
So for instance, I have the following constraint:

         <property name="testdoc:test_number">
            <title>Test Number</title>
               <constraint type="MINMAX">
                  <parameter name="minValue">
                  <parameter name="maxValue">

In my webscript I run this code:

public class UpdateProperties extends DeclarativeWebScript {

    protected Map<String, Object> executeImpl(WebScriptRequest request, Status status) {
        nodeService.setProperty(NODEREF_OF_THE_OBJECT, QNAME_OF_TEST_NUMBER, "9001");
        return model


When the webscript is called, it successfully completes and returns from the executeImpl method.  But since the value inputted does not match the constraint declared, the IntegrityChecker (which is ran after the webscript, automatically) prompts an integrity error that looks like:

Invalid property value:
   Node: workspace://SpacesStore/a04691ca-d154-4944-908d-ebf9693475e1
   Type: {testspace}testdoc
   Property: {testdoc}test_number
   Constraint: 03270012 Numeric value '9001' is not in range [0; 9]
at org.alfresco.repo.node.integrity.IntegrityChecker.checkIntegrity(
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(
at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(

What I need is to do is to have the Integrity Check done inside the webscript so I can return the constraint violation back to the caller of the webscript.

Anyone have any suggestions, idea? I'm open for anything.