Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Tuesday, March 27, 2012

Running Alfresco's TestModel Class from Eclipse

This post shows a minimal setup for running the TestModel class included in Alfresco as referenced by the Wiki.  The TestModel class is used to validate a custom content model.  This validation is more productive than a trial-and-error approach involving Tomcat restarts.

To call the TestModel class included with Alfresco, find all the libraries (.jar files) and folders containing XML.  First create a Java project in Eclipse.

Simple Project Setup to Invoke Alfresco
JAR Files
 
If you have the source available, you can link in the source files so that they can be browsed (Ctrl-Shift-T).  Add all the libraries from the alfresco/WEB-INF/lib folder by right-clicking on the project and setting the build path as in the following screenshot.

Java Build Path for Alfresco JARs
Run Configuration

Next, define a Run Configuration that will invoke the TestModel class (the main method).

Run Configuration for the Alfresco TestModel Class
Pass in the model to validate using the Arguments tab.
XML File Argument
Finally, add to the classpath set up in the previous step by adding the shared/classes and alfresco/WEB-INF/classes folder.  The latter folder is needed so that TestModel doesn't return an error for any of the built-in classes.  Note that the JARs from the build path are included in here, so no duplication is needed.
Adding Folders to the Classpath
Running

Running the TestModel class will provide the following output showing that the model is good.

Errors

If you get an error like the following...

2012-03-27 09:38:25,431  WARN  [repo.dictionary.DictionaryDAO] [http-8080-2] Type not found: {http://www.bekwam.com/model/custom/1.0}content

It may mean that there is a mismatch between the defined type and what appears in the web-client-config-custom.xml file.

Although it's desirable to avoid customizations in Alfresco, a client-specific content model can be very useful.  Setup Eclipse to run TestModel to validate your custom content models and aspects.

No comments:

Post a Comment