org.skunk.dav.client
Class AbstractDAVMethod

java.lang.Object
  |
  +--org.skunk.dav.client.AbstractDAVMethod
All Implemented Interfaces:
DAVMethod
Direct Known Subclasses:
CopyMethod, DeleteMethod, GetMethod, HeadMethod, LockMethod, MkcolMethod, OptionsMethod, PostMethod, PropFindMethod, PropPatchMethod, PutMethod, TraceMethod, UnlockMethod

public abstract class AbstractDAVMethod
extends java.lang.Object
implements DAVMethod

base class for DAV methods.


Constructor Summary
AbstractDAVMethod(java.lang.String path)
           
 
Method Summary
protected static java.lang.Integer extractStatus(java.lang.String statusLine)
          convenience function for parsing the status header.
 DAVFile getDAVFile()
           
 java.lang.String getHost()
          gets the hostname of the server.
 int getPort()
          gets the port where the file in question is served.
 java.lang.String getProtocol()
          returns the protocol
 byte[] getRequestBody()
          returns the body of the request
 java.util.Map getRequestHeaders()
          gets the headers of the request
 java.lang.String getRequestURL()
          returns the path requested
 byte[] getResponseBody()
          returns the body of the response
 java.util.Map getResponseHeaders()
           
 int getStatus()
           
protected  void processPropElement(DAVFile file, XMLElement elem)
          by default, passes the properties off to PropertyHandler
 void processRequestBody()
          a hook for processing the request body.
 void processRequestHeaders()
          a hook for processing the request headers.
 void processResponseBody()
          a hook into processing the body of the response.
 void processResponseHeaders()
          a hook for processing the response headers.
 void setHost(java.lang.String host)
          sets the hostname
 void setPort(int port)
          sets the port
 void setProtocol(java.lang.String protocol)
          sets the protocol
 void setRequestBody(byte[] b)
          sets the body of the request.
 void setRequestHeaders(java.util.Map m)
          sets the headers of the request
 void setResponseBody(byte[] body)
          used to populate the body of the response
 void setResponseHeaders(java.util.Map headers)
          used to populate the headers of the response
 void setStatus(int status)
          used to the populate the status of the response
protected static java.lang.String stripLastSlash(java.lang.String path)
          chomps the last slash off a path, which may not be null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.skunk.dav.client.DAVMethod
getRequestMethodName
 

Constructor Detail

AbstractDAVMethod

public AbstractDAVMethod(java.lang.String path)
Parameters:
path - the resource on which the method is performed
Method Detail

setProtocol

public void setProtocol(java.lang.String protocol)
sets the protocol
Specified by:
setProtocol in interface DAVMethod
Parameters:
protocol - the protocol

getProtocol

public java.lang.String getProtocol()
returns the protocol
Returns:
the protocol

setHost

public void setHost(java.lang.String host)
sets the hostname
Specified by:
setHost in interface DAVMethod
Parameters:
host - the hostname

setPort

public void setPort(int port)
sets the port
Specified by:
setPort in interface DAVMethod
Parameters:
port - the port

getHost

public java.lang.String getHost()
gets the hostname of the server.
Returns:
the hostname

getPort

public int getPort()
gets the port where the file in question is served.
Returns:
the port

getRequestHeaders

public java.util.Map getRequestHeaders()
gets the headers of the request
Specified by:
getRequestHeaders in interface DAVMethod
Returns:
the request headers

setRequestHeaders

public void setRequestHeaders(java.util.Map m)
sets the headers of the request
Specified by:
setRequestHeaders in interface DAVMethod
Parameters:
m - a map of header names and values

setRequestBody

public void setRequestBody(byte[] b)
sets the body of the request.
Specified by:
setRequestBody in interface DAVMethod
Parameters:
b - the new request body

getRequestURL

public java.lang.String getRequestURL()
returns the path requested
Specified by:
getRequestURL in interface DAVMethod
Returns:
the path requested.

getRequestBody

public byte[] getRequestBody()
returns the body of the request
Specified by:
getRequestBody in interface DAVMethod
Returns:
the body of the request, if any, or null

setResponseHeaders

public void setResponseHeaders(java.util.Map headers)
used to populate the headers of the response
Specified by:
setResponseHeaders in interface DAVMethod
Parameters:
headers - a mapping of headers names to values

setResponseBody

public void setResponseBody(byte[] body)
used to populate the body of the response
Specified by:
setResponseBody in interface DAVMethod
Following copied from interface: org.skunk.dav.client.DAVMethod
Parameters:
b - the new request body

getResponseHeaders

public java.util.Map getResponseHeaders()
Specified by:
getResponseHeaders in interface DAVMethod
Returns:
the headers of the response

getResponseBody

public byte[] getResponseBody()
Description copied from interface: DAVMethod
returns the body of the response
Specified by:
getResponseBody in interface DAVMethod
Returns:
the body of the response

getStatus

public int getStatus()
Specified by:
getStatus in interface DAVMethod
Returns:
the status of the response

setStatus

public void setStatus(int status)
used to the populate the status of the response
Specified by:
setStatus in interface DAVMethod
Parameters:
status - the status

getDAVFile

public DAVFile getDAVFile()
Specified by:
getDAVFile in interface DAVMethod
Returns:
the DAVFile corresponding to the resourceURL.

processResponseBody

public void processResponseBody()
                         throws MalformedXMLException
a hook into processing the body of the response. By default will parse a multistatus response; otherwise, does nothing.
Specified by:
processResponseBody in interface DAVMethod
Following copied from interface: org.skunk.dav.client.DAVMethod
Throws:
MalformedXMLException - if an XML response is expected and it is not well-formed.

processResponseHeaders

public void processResponseHeaders()
a hook for processing the response headers. By default does nothing.
Specified by:
processResponseHeaders in interface DAVMethod

processRequestHeaders

public void processRequestHeaders()
a hook for processing the request headers. By default does nothing.
Specified by:
processRequestHeaders in interface DAVMethod

processRequestBody

public void processRequestBody()
a hook for processing the request body. By default does nothing.
Specified by:
processRequestBody in interface DAVMethod

stripLastSlash

protected static final java.lang.String stripLastSlash(java.lang.String path)
chomps the last slash off a path, which may not be null.
Parameters:
path - the path to chomp

processPropElement

protected void processPropElement(DAVFile file,
                                  XMLElement elem)
by default, passes the properties off to PropertyHandler
Parameters:
file - the DAVFile in which the results are stored
elem - the prop XMLElement being processed

extractStatus

protected static final java.lang.Integer extractStatus(java.lang.String statusLine)
convenience function for parsing the status header.
Parameters:
statusLine - the HTTP status line
Returns:
the status as an Integer