org.mmbase.applications.dove
Class AbstractDove

java.lang.Object
  |
  +--org.mmbase.applications.dove.AbstractDove
Direct Known Subclasses:
Dove

public abstract class AbstractDove
extends java.lang.Object

This class handles Remote Procedure Calls described using a DOM model. The original data is received in xml, likely through a specialized servlet such as the DoveServlet (but this is not required. it may, for instance, be possible to use this class in conjunction with SOAP or even outside a servlet context). The call should result in a new DOM tree (see the EditWizard API for details).
XXX: Currently, this class performs some type of validation on the xml received. If errors occur, they are included in the response, at the place where they occur. This means that the <error > tag can occur anywhere in the response, which is not very neat.
Errors have three types:
parser : the xml given is invalid or does not follow the grammar. This likely means there is a bug in the client code.
server : the code invoked is either not yet implemented or another, server-related, error occurred (such as no memory, bad configuration, etc.). Server errors entirely fail a request.
client : The data requested could not be retrieved or values specified were invalid. I.e. a requested node does not exist (any more), or a put failed due to locking or invalid data.

This is ONLY for debugging purposes! XML validation should occur at the parser and be captured early. If we reach consensus that we must always validate, the xml-checking can be left out, as we can then assumes a correct model. This will optimize processing.

Since:
MMBase-1.5
Version:
$Id: AbstractDove.java,v 1.9.2.1 2003/06/02 12:20:56 vpro Exp $
Author:
Pierre van Rooden

Field Summary
static java.lang.String DESCRIPTION
           
protected  org.w3c.dom.Document doc
          The document that is being constructed.
static java.lang.String DOCTYPE_REQUEST
           
static java.lang.String DOCTYPE_RESPONSE
           
static java.lang.String ELM_CREATEDIR
           
static java.lang.String ELM_DESTINATION
           
static java.lang.String ELM_DESTINATIONTYPE
           
static java.lang.String ELM_DIRECTIONS
           
static java.lang.String ELM_HREF
           
static java.lang.String ELM_ID
           
static java.lang.String ELM_LANG
           
static java.lang.String ELM_MAYDELETE
           
static java.lang.String ELM_MAYWRITE
           
static java.lang.String ELM_NAME
           
static java.lang.String ELM_NUMBER
           
static java.lang.String ELM_OLDNUMBER
           
static java.lang.String ELM_ORDERBY
           
static java.lang.String ELM_ROLE
           
static java.lang.String ELM_SEARCHDIR
           
static java.lang.String ELM_SOURCE
           
static java.lang.String ELM_SOURCETYPE
           
static java.lang.String ELM_STATUS
           
static java.lang.String ELM_TYPE
           
static java.lang.String ELM_WHERE
           
static java.lang.String ELM_XPATH
           
static java.lang.String ERROR
           
static java.lang.String FIELD
           
static java.lang.String FIELDS
           
static java.lang.String GETCONSTRAINTS
           
static java.lang.String GETDATA
           
static java.lang.String GETLIST
           
static java.lang.String GETNEW
           
static java.lang.String GETNEWRELATION
           
static java.lang.String GETRELATIONS
           
static java.lang.String GUINAME
           
static java.lang.String GUITYPE
           
static java.lang.String IS_CLIENT
           
static java.lang.String IS_FALSE
           
static java.lang.String IS_PARSER
           
static java.lang.String IS_SERVER
           
static java.lang.String IS_TRUE
           
static java.lang.String MAXLENGTH
           
static java.lang.String NEW
           
static java.lang.String OBJECT
           
static java.lang.String ORIGINAL
           
static java.lang.String PLURALNAME
           
static java.lang.String PUT
           
static java.lang.String QUERY
           
static java.lang.String RELATION
           
static java.lang.String RELATIONS
           
static java.lang.String REQUEST
           
static java.lang.String REQUIRED
           
static java.lang.String RESPONSE
           
static java.lang.String SECURITY
           
static java.lang.String SECURITY_CLOUD
           
static java.lang.String SECURITY_METHOD
           
static java.lang.String SECURITY_NAME
           
static java.lang.String SECURITY_PASSWORD
           
static java.lang.String SINGULARNAME
           
 
Constructor Summary
AbstractDove(org.w3c.dom.Document doc)
          Constructor
 
Method Summary
protected  org.w3c.dom.Element addContentElement(java.lang.String tagname, java.lang.String content, org.w3c.dom.Element out)
          Creates a DOM element which contains a Text Node, and adds it to the specified node as a child.
 void doRequest(org.w3c.dom.Element in, org.w3c.dom.Element out)
          Handles a request running one or more RPCs.
abstract  void doRequest(org.w3c.dom.Element in, org.w3c.dom.Element out, Cloud cloud, java.util.Map repository)
          Handles a request running one or more RPCs.
 org.w3c.dom.Element executeRequest(org.w3c.dom.Element in)
          This method executes the request from the editors, it can be invoked directly
 org.w3c.dom.Element executeRequest(org.w3c.dom.Element in, Cloud cloud, java.util.Map repository)
          This method executes the request from the editors, it can be invoked directly
protected  org.w3c.dom.Element getFirstElement(org.w3c.dom.Node item)
          Retrieves the first child node of an element that is itself an element.
protected  org.w3c.dom.Element getFirstElement(org.w3c.dom.Node item, java.lang.String tagname)
          Retrieves the first child node of an element that is itself an element, and has the specified tagname.
protected  org.w3c.dom.Element getNextElement(org.w3c.dom.Node item)
          Retrieves the next sibling of an element that is itself an element.
protected  org.w3c.dom.Element getNextElement(org.w3c.dom.Node item, java.lang.String tagname)
          Retrieves the the next sibling of an element that is itself an element, and has the specified tagname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOCTYPE_REQUEST

public static final java.lang.String DOCTYPE_REQUEST

DOCTYPE_RESPONSE

public static final java.lang.String DOCTYPE_RESPONSE

REQUEST

public static final java.lang.String REQUEST

RESPONSE

public static final java.lang.String RESPONSE

SECURITY

public static final java.lang.String SECURITY

GETDATA

public static final java.lang.String GETDATA

GETNEW

public static final java.lang.String GETNEW

GETNEWRELATION

public static final java.lang.String GETNEWRELATION

GETRELATIONS

public static final java.lang.String GETRELATIONS

GETCONSTRAINTS

public static final java.lang.String GETCONSTRAINTS

GETLIST

public static final java.lang.String GETLIST

PUT

public static final java.lang.String PUT

SECURITY_NAME

public static final java.lang.String SECURITY_NAME

SECURITY_PASSWORD

public static final java.lang.String SECURITY_PASSWORD

SECURITY_CLOUD

public static final java.lang.String SECURITY_CLOUD

SECURITY_METHOD

public static final java.lang.String SECURITY_METHOD

OBJECT

public static final java.lang.String OBJECT

FIELD

public static final java.lang.String FIELD

ORIGINAL

public static final java.lang.String ORIGINAL

NEW

public static final java.lang.String NEW

RELATIONS

public static final java.lang.String RELATIONS

RELATION

public static final java.lang.String RELATION

ERROR

public static final java.lang.String ERROR

QUERY

public static final java.lang.String QUERY

SINGULARNAME

public static final java.lang.String SINGULARNAME

PLURALNAME

public static final java.lang.String PLURALNAME

DESCRIPTION

public static final java.lang.String DESCRIPTION

FIELDS

public static final java.lang.String FIELDS

GUINAME

public static final java.lang.String GUINAME

GUITYPE

public static final java.lang.String GUITYPE

MAXLENGTH

public static final java.lang.String MAXLENGTH

REQUIRED

public static final java.lang.String REQUIRED

ELM_ID

public static final java.lang.String ELM_ID

ELM_NUMBER

public static final java.lang.String ELM_NUMBER

ELM_OLDNUMBER

public static final java.lang.String ELM_OLDNUMBER

ELM_TYPE

public static final java.lang.String ELM_TYPE

ELM_STATUS

public static final java.lang.String ELM_STATUS

ELM_NAME

public static final java.lang.String ELM_NAME

ELM_ROLE

public static final java.lang.String ELM_ROLE

ELM_DESTINATION

public static final java.lang.String ELM_DESTINATION

ELM_DESTINATIONTYPE

public static final java.lang.String ELM_DESTINATIONTYPE

ELM_SOURCETYPE

public static final java.lang.String ELM_SOURCETYPE

ELM_SEARCHDIR

public static final java.lang.String ELM_SEARCHDIR

ELM_CREATEDIR

public static final java.lang.String ELM_CREATEDIR

ELM_LANG

public static final java.lang.String ELM_LANG

ELM_XPATH

public static final java.lang.String ELM_XPATH

ELM_WHERE

public static final java.lang.String ELM_WHERE

ELM_ORDERBY

public static final java.lang.String ELM_ORDERBY

ELM_DIRECTIONS

public static final java.lang.String ELM_DIRECTIONS

ELM_SOURCE

public static final java.lang.String ELM_SOURCE

ELM_HREF

public static final java.lang.String ELM_HREF

ELM_MAYWRITE

public static final java.lang.String ELM_MAYWRITE

ELM_MAYDELETE

public static final java.lang.String ELM_MAYDELETE

IS_PARSER

public static final java.lang.String IS_PARSER

IS_SERVER

public static final java.lang.String IS_SERVER

IS_CLIENT

public static final java.lang.String IS_CLIENT

IS_TRUE

public static final java.lang.String IS_TRUE

IS_FALSE

public static final java.lang.String IS_FALSE

doc

protected org.w3c.dom.Document doc
The document that is being constructed. This should be used to construct new DOM elements.
Constructor Detail

AbstractDove

public AbstractDove(org.w3c.dom.Document doc)
Constructor
Parameters:
doc - the Document that is constructed. This should only be used to construct new DOM elements. New (child) nodes should not be added to this document, but to the out element.
Method Detail

addContentElement

protected org.w3c.dom.Element addContentElement(java.lang.String tagname,
                                                java.lang.String content,
                                                org.w3c.dom.Element out)
Creates a DOM element which contains a Text Node, and adds it to the specified node as a child. Used for creating field and error tags.
Parameters:
tagname - name of the new element
content - content of the new element as a string
out - the element to which to add the new Element.
Returns:
the newly created element

getFirstElement

protected org.w3c.dom.Element getFirstElement(org.w3c.dom.Node item)
Retrieves the first child node of an element that is itself an element. If none exist, it returns null.
Parameters:
item - the element to find the first child element of
Returns:
the first child element, or null.

getFirstElement

protected org.w3c.dom.Element getFirstElement(org.w3c.dom.Node item,
                                              java.lang.String tagname)
Retrieves the first child node of an element that is itself an element, and has the specified tagname. If none exist, it returns null.
Parameters:
item - the element to find the first child element of
tagname - the tagname of the element desired
Returns:
the first child element, or null.

getNextElement

protected org.w3c.dom.Element getNextElement(org.w3c.dom.Node item)
Retrieves the next sibling of an element that is itself an element. If none exist, it returns null.
Parameters:
item - the element to find the sibling element of
Returns:
the sibling element, or null.

getNextElement

protected org.w3c.dom.Element getNextElement(org.w3c.dom.Node item,
                                             java.lang.String tagname)
Retrieves the the next sibling of an element that is itself an element, and has the specified tagname. If none exist, it returns null.
Parameters:
item - the element to find the sibling element of
tagname - the tagname of the element desired
Returns:
the first child element, or null.

doRequest

public abstract void doRequest(org.w3c.dom.Element in,
                               org.w3c.dom.Element out,
                               Cloud cloud,
                               java.util.Map repository)
Handles a request running one or more RPCs. This method accepts a root DOM element, which should contain as it child nodes elements describing the call(s) to perform. Each element is an xml element with as the tagname the name of the call to run. Valid calls are getdata, getrelations, getlist, getconstraints, getnew, and put. The calls are redirected to the appropriate encapsulating method in this class. The end result of each call should be a DOM tree, built using the given parameters, which is then appended to the out element.
XXX:This method runs all commands in order of entrance. It does not currently check whether all child nodes refer to the same call. This means that it is possible to mix 'getdata' and 'getrelations' calls in one request. Ina dditon, it ignores calls it does not know how to handle. as described above, this should be handled by the xml parser. Note also that if no id was given for a call, a NullPointer exception is thrown.
Parameters:
in - the element that described the request (or input). The childnodes should describe the calls to perform.
out - the element that described the response (or return value). Results of calls should be added as childs to this element.
cloud - the MMCI cloud to use, if applicable.
repository - Repository that contains the blobs

doRequest

public void doRequest(org.w3c.dom.Element in,
                      org.w3c.dom.Element out)
Handles a request running one or more RPCs.
Parameters:
in - the element that described the request (or input). The childnodes should describe the calls to perform.
out - the element that described the response (or return value). Results of calls should be added as childs to this element.

executeRequest

public org.w3c.dom.Element executeRequest(org.w3c.dom.Element in,
                                          Cloud cloud,
                                          java.util.Map repository)
This method executes the request from the editors, it can be invoked directly
Parameters:
in - the element that described the request (or input). The childnodes should describe the calls to perform.
cloud - the MMCI cloud to use, if applicable.
repository - Repository that contains the blobs
Returns:
the element that described the response (or return value). Results of calls should be added as childs to this element.

executeRequest

public org.w3c.dom.Element executeRequest(org.w3c.dom.Element in)
This method executes the request from the editors, it can be invoked directly
Parameters:
in - the element that described the request (or input). The childnodes should describe the calls to perform.
Returns:
the element that described the response (or return value). Results of calls should be added as childs to this element.


MMBase build 1.6.5.20030923