-
Notifications
You must be signed in to change notification settings - Fork 6
Creating a document type
In this section I will explain how you can define a document type and register it into ECR.
First you need to create a new plugin as explained in Creating a plugin
A document type is defined using extension points. So you need to write an XML file that looks like this one:
<?xml version="1.0"?>
<component name="org.eclipse.ecr.sample.doctypes" version="1.0">
<extension target="org.nuxeo.ecm.core.schema.TypeService"
point="schema">
<documentation>The core schemas</documentation>
<schema name="dublincore" prefix="dc" src="schema/dublincore.xsd"/>
<schema name="file" src="schema/file.xsd"/>
</extension>
<extension target="org.nuxeo.ecm.core.schema.TypeService"
point="doctype">
<doctype name="Folder" extends="Document">
<schema name="dublincore"/>
<facet name="Folderish"/>
</doctype>
<doctype name="Workspace" extends="Folder">
<facet name="SuperSpace"/>
</doctype>
<doctype name="File" extends="Document">
<schema name="file"/>
<schema name="dublincore"/>
<facet name="Downloadable"/>
<facet name="Versionable"/>
<facet name="Publishable"/>
</doctype>
</extension>
</component>
Here we are declaring 3 document types: a Folder which inherit the base type Document, a Workspace which inherit the Folder type, and a File type which inherit the base type Document. The Document type is a built-in type which doesn't define anything. It' just a marker used to identify any document types. Each of these defined types are specifying a set of schemas and optionally a set of facets. Facets are marking document types to provide a capability while schemas are used to define the structure of a document (in term of properties).
Schemas are declared as extensions too, and points to the XSD files that define the document schema.
To complete you definition you should define the schemas you are referencing in your extension (if these schemas are not yet defined by the ECR platform).
To do so you need provide the schema definition as an XSD file in your bundle. Note that these files will be located using Bundle.getEntry method.
Here are the definition of the two referenced schemas - dublincore and file:
<xs:schema
targetNamespace="http://www.nuxeo.org/ecm/schemas/dublincore/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:nxs="http://www.nuxeo.org/ecm/schemas/dublincore/"
>
<xs:simpleType name="subjectList">
<xs:list itemType="xs:string" />
</xs:simpleType>
<xs:simpleType name="contributorList">
<xs:list itemType="xs:string" />
</xs:simpleType>
<xs:element name="title" type="xs:string"/>
<xs:element name="description" type="xs:string"/>
<xs:element name="subjects" type="nxs:subjectList"/>
<xs:element name="rights" type="xs:string"/>
<xs:element name="source" type="xs:string"/>
<xs:element name="coverage" type="xs:string"/>
<xs:element name="created" type="xs:date"/>
<xs:element name="modified" type="xs:date"/>
<xs:element name="issued" type="xs:date"/>
<xs:element name="valid" type="xs:date"/>
<xs:element name="expired" type="xs:date"/>
<xs:element name="format" type="xs:string"/>
<xs:element name="language" type="xs:string"/>
<xs:element name="creator" type="xs:string"/>
<xs:element name="contributors" type="nxs:contributorList"/>
<xs:element name="lastContributor" type="xs:string"/>
<!-- Corresponds to the dublincore type element,
but renamed to avoid conflicts -->
<xs:element name="nature" type="xs:string"/>
</xs:schema>
<?xml version="1.0"?>
<xs:schema targetNamespace="http://www.nuxeo.org/ecm/schemas/files/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:nxs="http://www.nuxeo.org/ecm/schemas/files/">
<xs:complexType name="content">
<xs:sequence>
<xs:element name="encoding" type="xs:string" />
<xs:element name="mime-type" type="xs:string" />
<xs:element name="data" type="xs:base64Binary" />
<xs:element name="name" type="xs:string" />
<xs:element name="length" type="xs:long" />
<xs:element name="digest" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="content" type="nxs:content" />
</xs:schema>
Now, to finish your document type declaration you need to declare your XML configuration component in the MANIFEST.MF:
Nuxeo-Component: OSGI-INF/types-contrib.xml
where OSGI-INF/types-contrib.xml is the path of your XML configuration component in your bundle.