Dove 1.1 XML API

MMBase 1.5 includes a beta version of Dove. Version 1.0 was released with MMBase 1.5.1. Version 1.1 is included with MMBase 1.6.


Table of Contents

1. Introduction
1.1. Passing Commands
1.2. Security
1.3. Errors
2. Commands
3. getdata
4. getrelations
5. Nesting calls (getdata/getrelations)
6. getnew
7. getnewrelation
8. getconstraints
9. getlist
10. put
11. Configuration

The Dove is a support class for MMBase, which adds a protocol for communication with, and passing commands to, the MMBase system using an XML format. The current implementation (org.mmbase.applications.dove.Dove) makes use of the MMCI to communicate with MMBase. Alternate implementations (i.e. versions that work on the core) can be implemented by extending the AbstractDove class. Every implementation should at the least support the XML format presented here, though it is possible that implementations add custom commands or functionality. Commands are run by passing an XML DOM root element to an instance of Dove (the request). The calling member function returns an Element that contains the result of the passed command (the response). This document focuses on the structure of the request and response XML (the Dove Communication API). The actual mechanics for instantiation of the Dove class and calling its member functions are documented in the Dove class API.

The version noted here is version 1.1, which is included with MMBase version 1.6 and higher.

The root element of the request xml is the request tag.

Each request tag contains at most one security tag (containing user login information), and one or more dove command tags (each tag being one command). If more than one command is passed, the commands are handled in the order that they appear in the xml.

<!ELEMENT request (security?,(getdata|getnew|getnewrelation|getrelations| getconstraints|getlist|put)+) >
      

The commands that should be comprehended are : getdata, getnew, getnewrelation, getrelations, getconstraints, getlist, and put.

The command tags support an id attribute. The attribute has no significance to the Dove, but is meant to support a client-generated id system. When an id attribute is provided, this attribute is also returned in the appropriate tag in the response.

The result of the commands are tallied and returned in an xml with as root the response tag.

The body of the xml contains either an error tag (when connecting to MMBase failed), or a list of tags containing the results of the command passed, in the order that those commands were given. The response does not contain any security information, even if the request did.

<!ELEMENT response (getdata|getnew|getnewrelation|getrelations|getconstraints|getlist|put|error)+ >
      

Each command contains the result of that command or an error tag if the command failed.

The following pages list the commands that can be passed to the Dove.

An implementation should support the following commands:

A getdata command retrieves objects from MMBase by their number.

The command should contain one or more object tags, each tag referencing an object through the number attribute. If the referenced object can be found, the object, along with type and all its fields, is returned in the response. If retrieving the object fails, the returned response object tag contains an error tag describing the problem.

If you do not want to retrieve all the object's fields, you can specify the fields you want to retrieve by including field tags in the body of the object tag. The field tags' name attribute identifies the fields you want to retrieve. If at least one field tag is given, only the selected fields are returned. Note that you should not retrieve relation objects directly - use getrelations instead.

<!ELEMENT getdata (object+) >
<!ATTLIST getdata id ID #IMPLIED>

<!ELEMENT object (field*)>
<!ATTLIST object number NMTOKEN #REQUIRED >

<!ELEMENT field EMPTY>
<!ATTLIST field name NMTOKEN #REQUIRED >
  

The response contains, aside from the fields, the type of the object.

<!ELEMENT getdata (object+) >
<!ATTLIST getdata id ID #IMPLIED>

<!ELEMENT object (field*)>
<!ATTLIST object did ID #IMPLIED>
<!ATTLIST object number NMTOKEN #REQUIRED >
<!ATTLIST object type NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA) >
<!ATTLIST field did ID #IMPLIED>
<!ATTLIST field name NMTOKEN #REQUIRED >
  

A getrelations command obtains the relation objects belonging to the specified objects, filtered by a specified destination type or relation role.

The command should contain one or more object tags, each tag referencing an object through the number attribute. If the referenced object can be found, the object's relations are retrieved and returned.

An object tag may include one or more relation tags, allowing to retrieve a narrow selection of relations, relating to a specified type of object or using a specified role. Restricting the selection is done by supplying a role or a destinationtype attribute (or both) to a relation tag.

By default, all fields of a relation are returned. If you only want to retrieve certain fields, you can do so by specifying these fields by including field tags in the body of the relation tag. The field tags' name attribute identifies the fields you want to retrieve. If at least one field tag is given, only the selected fields are returned.

<!ENTITY % searchdir "(source,destination,both)">

<!ELEMENT getrelations (object+) >
<!ATTLIST getrelations id ID #IMPLIED>

<!ELEMENT object (relation*)>
<!ATTLIST object number NMTOKEN #REQUIRED >

<!ELEMENT relation (field*)>
<!ATTLIST relation role NMTOKEN #IMPLIED >
<!ATTLIST relation searchdir %searchdir #IMPLIED >
<!ATTLIST relation destinationtype NMTOKEN #IMPLIED >

<!ELEMENT field (#PCDATA) >
<!ATTLIST field name NMTOKEN #REQUIRED >
  

The response contains the requested relation objects, wrapped by the object used to retrieve them. All additional fields of the relations are also returned.

<!ELEMENT getrelations (object+) >
<!ATTLIST getrelations id ID #IMPLIED>

<!ELEMENT object (relation*)>
<!ATTLIST object number NMTOKEN #REQUIRED >

<!ELEMENT relation (field*)>
<!ATTLIST relation number NMTOKEN #REQUIRED >
<!ATTLIST relation type NMTOKEN #REQUIRED >
<!ATTLIST relation role NMTOKEN #REQUIRED >
<!ATTLIST relation source NMTOKEN #REQUIRED >
<!ATTLIST relation destination NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA) >
<!ATTLIST field name NMTOKEN #REQUIRED >
  

Loading one object or set of relations at a time can be time consuming, especially if a lot of interrelated objects need to be loaded.

It is possible to define a load action of related objects in one command, by nesting objects and their relations.

The nested request should follow this DTD:

<!ELEMENT object ((field|relation)*)>
<!ATTLIST object number NMTOKEN #IMPLIED >

<!ELEMENT relation ((field|object)*)>
<!ATTLIST relation searchdir %searchdir #IMPLIED >
<!ATTLIST relation role NMTOKEN #IMPLIED >
<!ATTLIST relation destinationtype NMTOKEN #REQUIRED >

and the nested response should follow this one:


<!ELEMENT object ((field|relation)*)>
<!ATTLIST object number NMTOKEN #REQUIRED >
<!ATTLIST object type NMTOKEN #REQUIRED >

<!ELEMENT relation ((field|object)*)>
<!ATTLIST relation number NMTOKEN #REQUIRED >
<!ATTLIST relation type NMTOKEN #REQUIRED >
<!ATTLIST relation role NMTOKEN #REQUIRED>
<!ATTLIST relation source NMTOKEN #REQUIRED >
<!ATTLIST relation destination NMTOKEN #REQUIRED >

Example 6. Example

A possible combination of nesting objects and relations could look like this:

<request>
<getdata id="1">
    <object number="672">

      <field name="title" />

      <relation role="part">
        <object >
          <field name="name" />
          <relation destinationtype="people" role=actor" >
            <object >
               <field name="firstname" />
               <field name="lastname" />
            </object>
          </relation>
        </object>
      </relation>

      <relation destinationtype="scenes" role="posrel">
        <field name="pos" />
        <object>
          <field name="title" />
        </object>
      </relation>

    </object>

  </getdata>

</request>
  

And this could be the response:

<response>

  <getdata id="1">
    <object number="672" type="movies">

     <field name="title" >
      <relation number="677" type="insrel" source="672" destination="678" role="part" >
        <object number="678" type="elements">
          <field name="name" >Han Solo</field>
          <relation number="690" type="insrel" source="678" destination="675" role=actor" >
            <object number="690" type="people" >
               <field name="firstname" >Harrison</field>
               <field name="lastname" >Ford</field>
            </object>
          </relation>
        </object>
      </relation>

      <relation number="700" type="posrel" source="672" destination="699" role="posrel" >
        <field name="pos" >1</field>
        <object number="699" type="scenes">
          <field name="title">Entering Mos Eisly</field>
        </object>
      </relation>
      <relation number="702" type="posrel" source="672" destination="701" role="posrel">
        <field name="pos" >2</field>
        <object number="701" type="scenes">
          <field name="title">These are not the droids you are looking for</field>
        </object>
      </relation>
      <relation number="704" type="posrel" source="672" destination="703" role="posrel">
        <field name="pos" >3</field>
        <object number="703" type="scenes">
          <field name="title">Boring conversation anyway</field>
        </object>
      </relation>

    </object>
  </getdata>

</response>
  

A getnew command creates a new, empty object of a specified object type.

The new object is returned with a (system-generated) temporary object number, and any fields for this object, with default values according to the system. This call is for generating normal objects - for generating relations use getnewrelation.

The command requires a type attribute that holds the type to generate

<!ELEMENT getnew EMPTY >
<!ATTLIST getnew id ID #IMPLIED>
<!ATTLIST getnew type NMTOKEN #REQUIRED>

The response contains the new object, in a fashion similar to getdata. The getnew element itself also contains the original type passed. All fields of the object are returned.

<!ELEMENT getnew (object|error) >
<!ATTLIST getnew id ID #IMPLIED>
<!ATTLIST getnew type NMTOKEN #REQUIRED>

<!ELEMENT object (field*)>
<!ATTLIST object number NMTOKEN #REQUIRED >
<!ATTLIST object type NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA) >
<!ATTLIST field name NMTOKEN #REQUIRED >

A getnewrelation command creates a new, empty relation object with a specified role, source, and destination.

The new object is returned with a (system-generated) temporary object number, role, source, and destination, and any additional fields for this object, with default values according to the system. This call is for generating relations - for normal objects use getnew.

The command requires a role, source, and destination attribute that holds information for the relation to generate.

<!ELEMENT getnewrelation EMPTY>
<!ATTLIST getnewrelation id ID #IMPLIED>
<!ATTLIST getnewrelation role NMTOKEN #REQUIRED >
<!ATTLIST getnewrelation source NMTOKEN #REQUIRED >
<!ATTLIST getnewrelation destination NMTOKEN #REQUIRED >

The response contains the new relation, in a fashion similar to getrelations. The getnewrelation element itself also contains the original attributes passed. All additional fields of the relation are returned.

<!ELEMENT getnewrelation (relation|error)>
<!ATTLIST getnewrelation id ID #IMPLIED>
<!ATTLIST getnewrelation role NMTOKEN #REQUIRED >
<!ATTLIST getnewrelation source NMTOKEN #REQUIRED >
<!ATTLIST getnewrelation destination NMTOKEN #REQUIRED >

<!ELEMENT relation (field*)>
<!ATTLIST relation number NMTOKEN #REQUIRED >
<!ATTLIST relation type NMTOKEN #REQUIRED >
<!ATTLIST relation role NMTOKEN #REQUIRED >
<!ATTLIST relation source NMTOKEN #REQUIRED >
<!ATTLIST relation destination NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA) >
<!ATTLIST field name NMTOKEN #REQUIRED >

A getconstraints command obtains constraint information for an object type.

The type should be specified in the type attribute. An optional xml:lang attribute can be specified to indicate the preferred language of any gui information (help text, prompts, etc.). A Dove implementation that supports this will return data in the preferred language where possible. the language specified should be in the ISO 639-1 format, such as 'en', 'nl', or the like.

<!ELEMENT getconstraints (object+) >
<!ATTLIST getconstraints id ID #IMPLIED>
<!ATTLIST getconstraints type NMTOKEN #REQUIRED>
<!ATTLIST getconstraints xml:lang NMTOKEN "en">

The response contains various tags containing basic information about the object type, the fields of the type, and any allowed relations.

Tags supported in API 1.0 are singularname, pluralname, and description.

The fields tag lists all editable fields of an object. Each field has its own tag, with a name attribute and a number of subtags : guiname, guitype, maxlength and required.

The guitype of a field has a mime-type like format of the form datatype/presentationtype.

The datatype part is one of string, int, long, float, double, datetime, or binary.

The presentationtype may vary (common types are line, text, date, or image).

Note

The description subtag of a field is available only in version 1.0 of the Dove.

<!ELEMENT getconstraints (error|(singularname,pluralname,description,fields,relations))+) >
<!ATTLIST getconstraints id ID #IMPLIED>
<!ATTLIST getconstraints type NMTOKEN #REQUIRED >
<!ATTLIST getconstraints xml:lang NMTOKEN "en" >

<!ELEMENT singularname (#PCDATA) >
<!ATTLIST singularname xml:lang NMTOKEN "en" >

<!ELEMENT pluralname (#PCDATA) >
<!ATTLIST pluralname xml:lang NMTOKEN "en" >

<!ELEMENT description (#PCDATA) >
<!ATTLIST description xml:lang NMTOKEN "en" >

<!ELEMENT fields (field*) >

<!ELEMENT relations (relation*) >

<!ELEMENT relation EMPTY >
<!ATTLIST relation role NMTOKEN #REQUIRED>
<!ATTLIST relation destinationtype NMTOKEN #REQUIRED >

<!ELEMENT field (guiname,description,guitype,maxlength,required)>
<!ATTLIST field name NMTOKEN #REQUIRED >

<!ELEMENT guiname (#PCDATA) >
<!ATTLIST guiname xml:lang NMTOKEN "en" >

<!ELEMENT guitype (#PCDATA) >

<!ELEMENT maxlength (#PCDATA) >

<!ELEMENT required (#PCDATA) >

The getlistcommand is used to retrieve lists of nodes using a set of criteria , such as nodetype and field content. The tag contains a set of query tags, each specifying the constraints to retrieve nodes with.

Each query element should have a xpath attribute to indicate the nodemanager to run the list on, and optionally a where attribute that contains the field-constraints.

The xpath value is a simplified xpath of the format "/*@nodemanagername", such as "/*@people". To do a multilevel query, make a list of nodemanagers seperated by "/" such as "/*@people/roles". It is possible that in future implementations more versatile xpaths can be used

The where attribute uses a SQL syntax to check a field, such as "name LIKE '%a%'". It is in all respects the same as the constraints attribute as used in the mm:listnodes tag of the MMBase taglib (described elsewhere).

Fields to retrieve can be limited in the same way as with a getdata command: by specifying the fields in an object tag. Note that when doing a multilevel query, you must specify an object tag with at least one field.

<!ELEMENT getlist (query+) >
<!ATTLIST getlist id ID #IMPLIED>

<!ELEMENT query (object?)>
<!ATTLIST query xpath CDATA #REQUIRED >
<!ATTLIST query where CDATA #IMPLIED >

<!ELEMENT object (field*)>

<!ELEMENT field EMPTY>
<!ATTLIST field name NMTOKEN #REQUIRED >

The response contains a list of the query tags, each filled with object tags (and their field tags) that follow the constraints.

<!ELEMENT getlist (query+|error) >
<!ATTLIST getlist id ID #IMPLIED>

<!ELEMENT query (object?|error)>
<!ATTLIST query xpath CDATA #REQUIRED >
<!ATTLIST query where CDATA #IMPLIED >

<!ELEMENT object ((field|relation)*)>
<!ATTLIST object number NMTOKEN #REQUIRED >
<!ATTLIST object type NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA)>
<!ATTLIST field name NMTOKEN #REQUIRED >



The put command is used to update MMBase by sending a set of nodes and relations to add or change. Each put command contains two node lists: the original tag contains a set of (original) objects that should be changed or deleted, the new tag contains a corresponding set of object with the needed changes, as well as a set of objects or relations that are new and need to be added.

The object and relation tags in original follow the general format (specifying a number attribute and field tags) and should be existing nodes - the contents of the fields specified in this list should match data in the database. If data is specified that is incorrect, an error is generated by the system, dictating an invalid attempt to change the data

Each object or relation in the original list should have a status attribute which indicates what should happen to the object: 'change' (edit content) or 'delete' (remove the object from the cloud).

The new tag lists all objects that should either be changed or added - objects with a status of 'delete' should not be included in this list. New objects in this list should have the status 'new'. All data mentioned here is changed or added - note that if a field is not mentioned, the content of that field (either default or existing content) is unchanged.

<!ENTITY % putstatus "(change,delete,new)">

<!ELEMENT put (original,new) >
<!ATTLIST put id ID #IMPLIED>

<!ELEMENT original ((object|relation)*) >
<!ELEMENT new ((object|relation)*) >

<!ELEMENT object ((field|relation)*)>
<!ATTLIST object number NMTOKEN #IMPLIED >
<!ATTLIST object status %putstatus #IMPLIED>

<!ELEMENT relation ((field|object)*)>
<!ATTLIST relation role NMTOKEN #IMPLIED >
<!ATTLIST relation searchdir %searchdir #IMPLIED >
<!ATTLIST relation destinationtype NMTOKEN #REQUIRED >
<!ATTLIST relation status %putstatus #IMPLIED>

<!ELEMENT field (#PCDATA)>
<!ATTLIST field name NMTOKEN #REQUIRED >
<!ATTLIST field href CDATA #IMPLIED >

If the out is successful, the response tag contains a result list of object and relation tags in the new tag.

This list consists of all changed and added nodes - deleted nodes are not included.

<!ELEMENT put (new|error) >
<!ATTLIST put id ID #IMPLIED>

<!ELEMENT new ((object|relation)*) >

<!ELEMENT object ((field|relation)*)>
<!ATTLIST object number NMTOKEN #REQUIRED >
<!ATTLIST object type NMTOKEN #REQUIRED >

<!ELEMENT relation ((field|object)*)>
<!ATTLIST relation number NMTOKEN #REQUIRED >
<!ATTLIST relation type NMTOKEN #REQUIRED >
<!ATTLIST relation role NMTOKEN #REQUIRED>
<!ATTLIST relation source NMTOKEN #REQUIRED >
<!ATTLIST relation destination NMTOKEN #REQUIRED >

<!ELEMENT field (#PCDATA)>
<!ATTLIST field name NMTOKEN #REQUIRED >


Since MMBase-1.8.1 (also backported to 1.7.5), dove can be configured with an xml property file in <mmbase config dir>/utils/dove.xml. The only recognized property at the moment is 'changes' which indicates what must happen if changes in the cloud are detected ('exception' to indicate an error, 'ignore' to ignore or 'warn' to log a warning). See the example dove.xml for more information. The file is watched, so if you change properties, they should be taken into effect a few seconds later.


This is part of the MMBase documentation.

For questions and remarks about this documentation mail to: documentation@mmbase.org