Monday, March 29, 2010

Custom Content Transformer

Alfresco has content transformer for most of mime type we are using day to day. But We wanted to have Custom Content Transformer,to show preview of .xfdl file.

.xfdl is extension for electronic form provided by Lotus Forms. This blog is more of creating a Custom Content Transformer for xfdl mime type.

1.How to register new Content Type i.e. “.xfdl”
Create new file “mimetype-custom-extensions.xml” at level “alfresco/mimetype” parallel level to “alfresco/extension” it should not go under “alfresco/extension” e.g. say mimetype-custom-extensions.xml
In this file we configure alfresco-config for area mimetype-map. Define correct mimetype for your extension here.

2.How to register new Custom Content Transformer
Create new file custom-services-context.xml under “alfresco/extension” folder e.g. custom-services-context.xml

In this file we need to define bean for "mimetypeConfigService" and new bean "transformer.xfdlToText" for Transformer "XFDLContentTransformer".

3. Create Custom Content Transformer “”
This is class where Transformation will take place for you extension mimetype. This class will extends the functionality from "AbstractContentTransformer" . This class uses a "transformText" method to transform it. You have different for you different extension and mimetype.

You can download the code from here ...