Behavior and Policy in Alfresco

There are various instances when we had a requirement in Alfresco in which we need to do certain operation based on particular events like node creation, node deletion etc… First Obvious solution which comes to our mind is Rules. Create rules with business logic embedded in it and invoke those rules when event occur. But it has certain limitations like it cannot be bind with certain service APIs or certain Events like download and view content. For instance we want to keep track of number of times document is viewed we cannot use any rule to meet this requirement. Do not worry we have a feature called behavior which comes to rescue.

Behaviors are used throughout Alfresco. Auditing and versioning are examples where behaviors are involved. In one case we needed to default some metadata values using logic that couldn’t be expressed using the Alfresco content model so we wrote a custom behavior that set the metadata appropriately. In another, we needed a way to synchronize metadata between folders and the items in those folders so we wrote a custom behavior to handle the sync. Like this Alfresco behaviors have come in handy several times in our various implementations.

Next obvious question which comes to our mind is how to bind this behavior with those events and APIs? We have concept called Policies which can serve the purpose. Policies are nothing but a set of Interfaces which provide way to bind behavior to APIs or events. Each of those interfaces contains inner interfaces that represent the policies you can hook into

Ex.

Interface: org.alfresco.repo.content.ContentServicePolicies

Methods: onContentUpdate,onContentRead

We need to find proper set of policies from all available policies which match up our requirement and then need to associate it with custom behavior. Behaviors can be implemented using JAVA or Javascript. Custom behavior with JAVA can implemented by creating a java class which implements the interface corresponding to policy which we want to bind Behavior.

This is brief description about Behavior and Policies in Alfresco in upcoming articles We will see how to create one in Alfresco till then you can try it yourself.

Looking for quality Alfresco Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under Alfresco | RSS 2.0

Author Spotlight

mitpatoliya

mitpatoliya

I love opensource technologies working with those technologies from the time I have stepped in to the Software Industry. Alfresco CMS is my area of expertise. I have worked on various complex implementations which involved integration of Alfresco with other technologies, extensively worked with JBPM workflows and Webscripts.

Leave a Reply

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


× 9 = 27

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>