| java.lang.Object com.ibm.webdav.protocol.http.WebDAVMethod
All known Subclasses: com.ibm.webdav.protocol.http.UncheckOutMethod, com.ibm.webdav.protocol.http.PutMethod, com.ibm.webdav.protocol.http.VersionControlMethod, com.ibm.webdav.protocol.http.HeadMethod, com.ibm.webdav.protocol.http.OrderPatchMethod, com.ibm.webdav.protocol.http.PropFindMethod, com.ibm.webdav.protocol.http.CheckInMethod, com.ibm.webdav.protocol.http.CheckOutMethod, com.ibm.webdav.protocol.http.MoveMethod, com.ibm.webdav.protocol.http.OptionsMethod, com.ibm.webdav.protocol.http.DeleteMethod, com.ibm.webdav.protocol.http.CopyMethod, com.ibm.webdav.protocol.http.BindMethod, com.ibm.webdav.protocol.http.UnlockMethod, com.ibm.webdav.protocol.http.SearchMethod, com.ibm.webdav.protocol.http.GetMethod, com.ibm.webdav.protocol.http.LockMethod, com.ibm.webdav.protocol.http.ReportMethod, com.ibm.webdav.protocol.http.MkcolMethod, com.ibm.webdav.protocol.http.PropPatchMethod, com.ibm.webdav.protocol.http.PostMethod,
WebDAVMethod | abstract public class WebDAVMethod extends Object (Code) | | WebDAVMethod is the abstract superclass of classes corresponding to the
WebDAV methods using the command pattern. It maintains the state and logic
that is common to the execution of all webDAV methods. These subclasses
are a good place to see how the WebDAV protocol is mapped back onto the
DAV4J API.
WebDAVMethods are constructed by the HTTP server skeleton ResourceHTTPSkel
in order to dispatch Resource methods to ResourceImpl methods on the server.
This treats HTTP just like any other remote procedure call mechanism, and
unifies the client/server communication.
In general, the execution of a WebDAV method consists of:
- create an instance of a Resource implementation corresponding to the resource being
manipulated by the method
- set the ResourceImpl request context from the request headers using getRequestHeaders()
- get the request entity (if any), parse it, and marshal any arguments
it contains for the method
- call the ResoureImpl method corresponding to the WebDAVMethod subclass (WebDAV or HTTP method)
- put any response context into the result headers using setResponseHeaders()
- output the response if any
- catch exceptions and translate them to set the status code and message
for method
Some of these operations are generic to all methods while others are specific
to each subclass. In particular, how the context values,
request entity, generation of the result entity, and status codes are handled
are subclass specific.
Note it is critical that the execute method sets status codes and the request
and response headers at the right time. The order is, (1) use setStatusCode() and set
other response headers the method needs to set. (2) Call setResponseHeaders() to
copy the resource response context to the response headers. (3) Output any response entity
body. The headers and response code are written the the HTTP response output
stream just before the first byte of the response entity body. Any
headers or status code set after the first byte of the response entity body has
been written will be lost.
|
copy | protected void copy(InputStream in, HttpServletResponse response, int length, String mime) throws WebDAVException(Code) | | Copies input stream to an HTTP output stream.
Parameters: in - the source stream from the NamespaceManager Parameters: out - the destination stream from the servlet response Parameters: length - the number of bytes to read from the steam Parameters: mime - the MIME type of the document to determine if its text or binary |
copy | protected void copy(HttpServletRequest request, OutputStream out, int length, String mime) throws WebDAVException(Code) | | Copies an HTTP input stream to an output stream.
Parameters: in - the source stream from the servlet request Parameters: out - the destination stream from the NamespaceManager Parameters: length - the number of bytes to read from the steam Parameters: mime - the MIME type of the document to determine if its text or binary |
execute | abstract public WebDAVStatus execute() throws WebDAVException(Code) | | Execute this method. Subclasses are expected to override this method to
handle the request entity, do the work, update the context, return
the response entity result if any, and set the status code.
the WebDAV status code. exception: com.ibm.webdav.WebDAVException - |
getMethodName | public String getMethodName()(Code) | | Get the request method name
|
getRequestHeaders | public void getRequestHeaders() throws WebDAVException(Code) | | Initialize the request context from the request headers. This provides
additional parameters for the methods and perhaps other state from the
client for the resource.
exception: com.ibm.webdav.WebDAVException - |
getRequestURL | public URL getRequestURL()(Code) | | Reconstructs the URL used by the client used to make the
request. This accounts for differences such as addressing
scheme (http, https), but does not attempt to
include query parameters. The port is retained even if the
default port was used.
This method is useful for creating redirect messages and for
reporting errors.
|
getResource | public ResourceImpl getResource()(Code) | | Return the Resource the method operates on.
|
getResponseCharset | public String getResponseCharset()(Code) | | Get the client prefered character encoding to be used to encode
text responses. This implementation gets the charset from the Accept
header. TODO: it should probably do something with Accept-Charset too.
the MIME charset |
getStatusCode | public int getStatusCode()(Code) | | Get the status code for this method.
a status code as defined by HTTP/1.1 and WebDAV |
setResponseHeaders | public void setResponseHeaders() throws WebDAVException(Code) | | Set the response headers from the response context. This must be called
after the remote method has been executed, and BEFORE any response entity
is written.
exception: RemoteException - |
setStatusCode | public void setStatusCode(int statusCode)(Code) | | Set the status code for the method. This method must be called before
any of the response entity is written.
Parameters: statusCode - the status code to set as defined by HTTP/1.1and WebDAV. |
|
|