Download Nuxeo Enterprise Platform

Transcript
Chapter 20. Content Transformation
20.1. Introduction
Transforms are operations that perform any action modifying an input document. This can cover file conversion
as well as mail merging or information extraction.
20.2. Plugins module
The various plugins are stored in the nuxeo-plateform-transforms-plugins.* module. They are declared as a
contribution of the org.nuxeo.ecm.platform.transform.service.TransformService component at extension
point plugins.
The plugins are the engines that perform the needed transformations.
20.2.1. Creating a plugin
A transform plugin follows a framework defined in the nuxeo-plateform-transforms-core module. It is
basically a class that extends a org.nuxeo.ecm.platform.transform.interfaces.Plugin. The main common
method that has to be exposed is transform
List<TransformDocument> transform(
Map<String, Serializable> options, TransformDocument... sources);
The transform method returns a list of TransformDocument and accepts an options map and
TransformDocument sources. TransformDocument object is defined in
org.nuxeo.ecm.platform.transform.interfaces.TransformDocument and holds the binary as well as other
information such as mimetype.
The options map holds all the necessary options to be passed to the plugin. Please note that the keys are the
plugin names. See the officeMerger plugin below for an implementation example.
20.2.2. Declaring a plugin module
We first declare a contribution to the extension point plugins of
org.nuxeo.ecm.platform.transform.service.TransformService:
<extension target="org.nuxeo.ecm.platform.transform.service.TransformService" point="plugins">
<plugin name="any2odt"
class="org.nuxeo.ecm.platform.transform.plugin.joooconverter.impl.JOOoConvertPluginImpl"
destinationMimeType="application/vnd.oasis.opendocument.text">
<sourceMimeType>text/xml</sourceMimeType>
<sourceMimeType>text/plain</sourceMimeType>
<sourceMimeType>text/rtf</sourceMimeType>
<!-- Microsoft office documents -->
<sourceMimeType>application/msword</sourceMimeType>
<!-- OpenOffice.org 1.x documents -->
<sourceMimeType>application/vnd.sun.xml.writer</sourceMimeType>
<sourceMimeType>application/vnd.sun.xml.writer.template</sourceMimeType>
<!-- OpenOffice.org 2.x documents -->
<sourceMimeType>application/vnd.oasis.opendocument.text</sourceMimeType>
<sourceMimeType>application/vnd.oasis.opendocument.text-template</sourceMimeType>
<option name="ooo_host_name">localhost</option>
<option name="ooo_host_port">8100</option>
</plugin>
</extension>
Nuxeo EP 5.1 / 5.2
134