Alfresco list constraint that can get available values from an external service

In an on-going project that I am involved in right now, we are using/extending Alfresco as a Content Management System. One of the challenges we have faced is that we have integrate it with an internal CV (Controlled Vocabulary).

CV holds the references of all domain specific entities and the relationships between them. We need the list of values from the CV to show in the user interface, there are two ways to do this.

We can completely do this integration in GUI layer, however if we do this the only place to validate the values is the GUI layer.

Instead we decided to create a generic constraint that can get it’s values from the CV and drive the front-end from the repository. Simply the GUI widget will be populated using the constraint instead of calling the service itself. This way we can do validation on both layers; GUI and repository.

It is possible to create custom constraints in Alfresco, all you have to is to implement Constraint interface and do your magic. The constraint takes parameters like; service_url, enable_caching, time_to_live, etc. I included constraint definition below to give you an idea.

<constraint name="all:colors" type="VCLIST">
    <parameter name="service_url">
    <parameter name="enable_caching"><value>true</value></parameter>
    <parameter name="time_to_live"><value>1000sec</value></parameter>

Since the constraint is generic, parameters are used to configure it. You can create different constraints that can hold different list-of-values.

  • service_url: Service url to call to get the list of values, constraint itself uses proper converter according to the mime type of the response. Currently it only supports XML and JSON. However it naturally expects a certain format either it is XML or JSON.
  • enable_caching: If caching is enabled the constraint stores the list of values temporarily instead of calling the service ever time.
  • time_to_live: TTL for the cache.

Add a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!