Creating a Resource Type, Part 1: Prerequisites and Declaration

This section explains how to create a new resource type. For more information
on resource types, refer to the resource types reference.
For the sake of simplicity, we'll test the resource type with the default publication.

Our resource type will support storing details (name, address, etc.) of people.
We'll call it person. Since we're too lazy (and too smart) to invent our
own XML schema, we'll just use the one provided by the
FoaF
project.

You can checkout the source code of this example from the Subversion repository at the URL
http://svn.apache.org/repos/asf/lenya/sandbox/modules/person.

Adding a Module

We'll add a module which will contain the resource type. This makes it
self-contained, and it will be very easy to re-use our resource type
in different publications. Create the person directory (see section
Prerequisites) with the following directory layout:

Now we have to let Lenya know that we've added a new module. Edit the
file $LENYA_HOME/local.build.properties and add the path
to your modules directory (the parent of $MODULE_HOME)
at the end of the modules.root.dirs declaration:

modules.root.dirs=...:/home/john/src/lenya/modules

Finally, we'll have to declare the module in the publications which use it
(in our case, the default publication). Edit $PUB_HOME/config/publication.xml
and add the entry

<module name="person"/>

to the <modules/> section. Additionally, you can assign a workflow
to the resource type in the <resource-types> section of
publication.xml:

Declaring the Resource Type

To let Lenya know that a new resource type exists, we'll add the
resource type declaration file resourcetype-person.xconf.
This is a patch for the cocoon.xconf file and therefore
located in $MODULE_HOME/config/cocoon-xconf.