uk.org.ogsadai.engine.controlflow
Interface ResponseBuilder

All Known Implementing Classes:
ResponseBuilderImpl

public interface ResponseBuilder

Interface for building a response document. Note that implementations of this interface must be threadsafe.

A response document describes the results of an OGSA-DAI request. An instance is assembled over a series of invocations of the various build methods. The product is then retrievable using the getResponseDocument method.

This is an example of the Builder design pattern. It separates the creation of response documents from the code that processes requests and allows different representations of response documents to be created.

Author:
The OGSA-DAI Project Team

Method Summary
 void buildError(java.lang.String name, java.lang.Exception cause)
          Assembles part of the response document describing an error that has occurred while processing part of a request.
 void buildRequestError(java.lang.String cause)
          Assembles the part of the response document describing the status of a request that has failed due to an error.
 void buildRequestStatus(Status status)
          Assembles the part of the response document describing the status of the request.
 void buildResult(java.lang.String name, Status status, byte[] data)
          Assembles part of the response document describing the result of processing part of the request.
 org.w3c.dom.Document getResponseDocument()
          Gets the assembled response document.
 

Method Detail

buildRequestStatus

public void buildRequestStatus(Status status)
Assembles the part of the response document describing the status of the request.

Parameters:
status - the Status of the request
Throws:
java.lang.IllegalArgumentException - if the status is null

buildRequestError

public void buildRequestError(java.lang.String cause)
Assembles the part of the response document describing the status of a request that has failed due to an error.

Parameters:
cause - the cause string for the error
Throws:
java.lang.IllegalArgumentException - if the cause is null

buildResult

public void buildResult(java.lang.String name,
                        Status status,
                        byte[] data)
Assembles part of the response document describing the result of processing part of the request.

Parameters:
name - the name associated with the result
status - the status of the result
data - the result data. This may be null or an empty String if the result contains no result data.
Throws:
java.lang.IllegalArgumentException - if the name or status is null

buildError

public void buildError(java.lang.String name,
                       java.lang.Exception cause)
Assembles part of the response document describing an error that has occurred while processing part of a request.

Parameters:
name - the name associated with the error
cause - the Exception that was raised by the error
Throws:
java.lang.IllegalArgumentException - if the name or cause is null

getResponseDocument

public org.w3c.dom.Document getResponseDocument()
Gets the assembled response document. This should be invoked after the building process has been completed.

Returns:
the response Document