org.vfny.geoserver.responses.wfs
Class LockResponse

java.lang.Object
  extended byorg.vfny.geoserver.responses.wfs.LockResponse
All Implemented Interfaces:
Response

public class LockResponse
extends java.lang.Object
implements Response

Handles a Lock request and creates a LockResponse string.


Constructor Summary
LockResponse(GeoServer gs)
          Constructor
 
Method Summary
 void abort(GeoServer gs)
          Release locks if lockAll failed.
 void execute(Request req)
          Excecutes a request.
 java.lang.String getContentType(GeoServer gs)
          MIME type of this Response - example "text/xml".
static java.lang.String performLock(LockRequest request, boolean getXml)
          Parses the LockFeature reqeust and returns either the full xml lock result or just the lockId.
 void writeTo(java.io.OutputStream out)
          Writes this respone to the provided output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockResponse

public LockResponse(GeoServer gs)
Constructor

Parameters:
gs - DOCUMENT ME!
Method Detail

execute

public void execute(Request req)
             throws WfsException
Description copied from interface: Response
Excecutes a request. If this method finalizes without throwing an Exception, the Response instance should be ready to write the response content through the writeTo method with the minimal posible risk of failure other than not beeing able to write to the output stream due to external reassons

We should clarify when a ServiceException is thrown? I would assume that a "failed" request should still result in a Response that we could write out.

Specified by:
execute in interface Response
Parameters:
req - a Request object that implementations should cast to it's Request specialization, wich must contain the parsed and ready to use parameters sent by the calling client. In general, such a Request will be created by either a KVP or XML request reader; resulting in a Request object more usefull than a set of raw parameters, as can be the list of feature types requested as a set of FeatureTypeInfo objects rather than just a list of String type names
Throws:
WfsException

getContentType

public java.lang.String getContentType(GeoServer gs)
Description copied from interface: Response
MIME type of this Response - example "text/xml".

thinked to be called after excecute(), this method must return the MIME type of the response content that will be writen when writeTo were called

an implementation of this interface is required to throw an IllegalStateException if execute has not been called yet, to indicate that an inconsistence in the work flow that may result in an inconsistence between the response content and the content type declared for it, if such an implementation can return different contents based on the request that has originated it. i.e. a WMS GetMap response will return different content encodings based on the FORMAT requested, so it would be impossible to it knowing the exact MIME response type if it has not processed the request yet.

There is some MIME stuff in JDK for reference:

Specified by:
getContentType in interface Response
Returns:
the MIME type of the generated or ready to generate response content

writeTo

public void writeTo(java.io.OutputStream out)
             throws ServiceException
Description copied from interface: Response
Writes this respone to the provided output stream.

To implememt streaming, execution is sometimes delayed until the write opperation (for example of this see FeatureResponse). Hopefully this is okay? GR:the idea for minimize risk error at writing time, is that execute performs any needed query/processing, leaving to this method just the risk of encountering an uncaught or IO exception. i.e. FeatureResponse should execute the queries inside the execute method, and have a set of FeatureReader's (or results) ready to be streamed here. This approach fits well with the Chirs' idea of configuring geoserver for speed or full conformance, wich ends in just writing directly to the http response output stream or to a ByteArrayOutputStream

JG: Consider using a Writer here? GR: I don't think so, because not all responses will be char sequences, such as an image in a WMS GetImage response.

Specified by:
writeTo in interface Response
Parameters:
out -
Throws:
ServiceException - wrapping of any unchecked exception or other predictable exception except an IO error while writing to out

performLock

public static java.lang.String performLock(LockRequest request,
                                           boolean getXml)
                                    throws WfsException,
                                           java.io.IOException
Parses the LockFeature reqeust and returns either the full xml lock result or just the lockId.

Parameters:
request - the locks to attempt
getXml - if true then the full xml response is returned, if false then only the lockId is returned.
Returns:
XML response or lockId, depending on getXml
Throws:
WfsException - for any problems doing the lock.
java.io.IOException - DOCUMENT ME!

abort

public void abort(GeoServer gs)
Release locks if lockAll failed.

Specified by:
abort in interface Response
See Also:
org.vfny.geoserver.responses.Response#abort()