cancel
Showing results for 
Search instead for 
Did you mean: 

Constraints type path

dev
Champ in-the-making
Champ in-the-making
Hi,

I am trying to validate my date of Birth property in my content model, so that it does not allow future dates to be put it.
I have tried writing constraints for the property.

Following the examples in the internet, I am trying to add a constraint in my content model to do it.

<constraint name="cus:noFutureDate" type="org.alfresco.repo.dictionary.constraint.FutureDateConstraint"/>


But I do not know where do I exactly place my FutureDateConstraint.java?

Please help.


Thanks In Advance
5 REPLIES 5

jpotts
World-Class Innovator
World-Class Innovator
Compile your class and then place it in $TOMCAT_HOME/webapps/alfresco/WEB-INF/classes. Or, put it in a JAR file and put the JAR file in $TOMCAT_HOME/webapps/alfresco/WEB-INF/lib.

With that said, you'll likely have other things you'll be adding to your Alfresco installation. The best way to package them all together is by creating an AMP file and then using the MMT to install the AMP into your WAR. You can read more about packaging extensions here: http://wiki.alfresco.com/wiki/Packaging_And_Deploying_Extensions

Jeff

dev
Champ in-the-making
Champ in-the-making
Hi,

Thanks for your reply.

I have created a java class FutureDateConstraint which extends org.alfresco.repo.dictionary.constraint.AbstractConstraint

and exported it as a jar named future-date-constraint.jar and placed it in tomcat/webapps/workdesk/WEB-INF/lib

I have defined my constraint in the content model such as


<constraints>
     <constraint name="cus:onlyPastDate" type="com.myCompany.alfresco.FutureDateConstraint" />
</constraints>


and have referenced it in my property in the content model as

    <property name="cus:dateOfBirth">
       <title>Date of Birth</title>
       <type>d:date</type>
       <mandatory>true</mandatory>
       <constraints>
           <constraint ref="onlyPastDate"/>
       </constraints>
    </property>


But when I try to activate and save my content model it gives me an error which says "Failed to compile model".

My content model does not seem to recognize my class file.

Could you please tell me what is it that I have done wrong or need to do more.

Thanks In Advance

jpotts
World-Class Innovator
World-Class Innovator
Your constraint ref is missing the namespace. It should be:


<constraint ref="cus:onlyPastDate" />


Jeff

dev
Champ in-the-making
Champ in-the-making
Hi Jeff,

Thanks for the reply. But that was just a typing mistake.

In my actual content model, I did put in the namesapce in the constraint reference. But it still does not work and gives me the same error when I try and save the content model.

In my FutureDateConstraint class, only coding I have done is to implement my date checking code in the overridden function evaluateSingleValue(Object value).

jpotts
World-Class Innovator
World-Class Innovator
If the error message is "failed to compile model" then the problem is most likely with your model file XML and has nothing to do with your Java class.

If you post your content model file that will help.

Jeff
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.