com.jalios.jcms.webdav
Class WebdavContext

java.lang.Object
  extended by com.jalios.jcms.webdav.WebdavContext
Direct Known Subclasses:
CatWebdavContext, FileWebdavContext

public abstract class WebdavContext
extends Object

This class is an Abstract Representation of a Webdav Context. It is used to:

Since:
jcms-5.5.0
Version:
$Revision: 21024 $
Author:
Jean-Philippe Encausse

Field Summary
 javax.servlet.ServletConfig conf
           
static String EMPTY_STRING
          EMPTY_STRING Convenient empty String
protected  boolean hasError
           
protected  SimpleDateFormat httpDate
           
protected  SimpleDateFormat httpDateUS
           
static int INFINITY
          INFINITY used for internal RFC2518
protected  byte[] inputStreamContent
           
protected  SimpleDateFormat isoDate
           
 String lang
           
 Locale locale
           
protected static Hashtable mapStatusCodes
          This Hashtable contains the mapping of HTTP and WebDAV status codes to descriptive text.
static Map memoryProperties
          This is an in Memory Property manager used to handle PROPPATCH even if JCMS will handle it
static String NAMESPACE
          NAMESPACE shortcut for DAV: default value is D:
static String NAMESPACE_MS
          When PROPFINDing collections, the webfolder client tries to retrieve values for a set of properties in the "DAV:" namespace, although they aren't defined in any WebDAV related specification (DAV:contentclass, DAV:defaultdocument, DAV:href, DAV:iscollection, DAV:ishidden, DAV:isreadonly, DAV:isroot, DAV:isstructureddocument, DAV:lastaccessed, DAV:name and DAV:parentname).
static String NAMESPACEINFO
          NAMESPACEINFO DAV: used for RFC2518 Properties declaration
static String NAMESPACEINFO_MS
           
protected  String originalPathHeader
           
protected static Set propAllSet
           
protected static Set propFileSet
           
protected static Set propMSWebFolderSet
          Microsoft Implementation can be found here: http://msdn.microsoft.com/library/default.asp?
protected static Set propRFC2518Set
          Sets of webdav properties used to filter webdav properties for folder, files, microsoft, rfc2518
protected static Set propSubSet
           
 javax.servlet.http.HttpServletRequest req
           
 javax.servlet.http.HttpServletResponse res
           
static String REVISION
           
static int SC_ACCEPTED
          Status code (202) indicating that a request was accepted for processing, but was not completed.
static int SC_BAD_GATEWAY
          Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway.
static int SC_BAD_REQUEST
          Status code (400) indicating the request sent by the client was syntactically incorrect.
static int SC_CONFLICT
          Status code (409) indicating that the request could not be completed due to a conflict with the current state of the resource.
static int SC_CONTINUE
          Status code (100) indicating the client may continue with its request.
static int SC_CREATED
          Status code (201) indicating the request succeeded and created a new resource on the server.
static int SC_FORBIDDEN
          Status code (403) indicating the server understood the request but refused to fulfill it.
static int SC_INSUFFICIENT_SPACE_ON_RESOURCE
          Status code (419) indicating that the resource does not have sufficient space to record the state of the resource after the execution of this method.
static int SC_INTERNAL_SERVER_ERROR
          Status code (500) indicating an error inside the HTTP service which prevented it from fulfilling the request.
static int SC_LOCKED
          Status code (423) indicating the destination resource of a method is locked, and either the request did not contain a valid Lock-Info header, or the Lock-Info header identifies a lock held by another principal.
static int SC_METHOD_FAILURE
          Status code (420) indicating the method was not executed on a particular resource within its scope because some part of the method's execution failed causing the entire method to be aborted.
static int SC_METHOD_NOT_ALLOWED
          Status code (405) indicating the method specified is not allowed for the resource.
static int SC_MOVED_PERMANENTLY
          Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.
static int SC_MOVED_TEMPORARILY
          Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.
static int SC_MULTI_STATUS
          Status code (207) indicating that the response requires providing status for multiple independent operations.
static int SC_NO_CONTENT
          Status code (204) indicating that the request succeeded but that there was no new information to return.
static int SC_NOT_FOUND
          Status code (404) indicating that the requested resource is not available.
static int SC_NOT_IMPLEMENTED
          Status code (501) indicating the HTTP service does not support the functionality needed to fulfill the request.
static int SC_NOT_MODIFIED
          Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.
static int SC_OK
          Status code (200) indicating the request succeeded normally.
static int SC_PRECONDITION_FAILED
          Status code (412) indicating the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
static int SC_REQUEST_TOO_LONG
          Status code (413) indicating the server is refusing to process a request because the request entity is larger than the server is willing or able to process.
static int SC_SERVICE_UNAVAILABLE
          Status code (503) indicating that the HTTP service is temporarily overloaded, and unable to handle the request.
static int SC_UNAUTHORIZED
          Status code (401) indicating that the request requires HTTP authentication.
static int SC_UNPROCESSABLE_ENTITY
          Status code (418) indicating the entity body submitted with the PATCH method was not understood by the resource.
static int SC_UNSUPPORTED_MEDIA_TYPE
          Status code (415) indicating the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
protected  String servletURI
           
protected static Set setOkStatusCodes
          This HashSet contains all StatusCodes that doesn't define an error.
protected  List statusCode
           
protected  List statusMsg
           
protected  List statusPath
           
static String SUPPORTED_LOCKS
          SUPPORTED_LOCKS convenient method for locks discovery
 
Constructor Summary
WebdavContext()
           
 
Method Summary
 void addHeader(String key, String value)
          Encapsulate response.addHeader()
 void addProperty(String key, String value, String resourcePath)
          Add a property for the given resource path
protected static void addStatusCodeMap(int nKey, String strVal)
          Adds a new status code -> status text mapping.
protected static void addStatusCodeSet(int nKey)
          Adds a new status code.
 void appendStatus(int code)
          Append a StatusCode to the Context.
 void appendStatus(int code, String message)
          Append a StatusCode to the Context.
 void appendStatus(int code, String message, String path)
          Append a StatusCode to the Context.
abstract  boolean authenticate()
          This method have to do all authentication stuff with any behavior
static String decodePath(String path)
          Call URLDecoder with try/catch
static String encodePath(String path)
          Encode Href to work display correct URL
static String escapeWebdavChars(String str)
           
 Map getAllProperties()
           
 int getDepthHeader()
          Decode the depth Header or INFINITY if none
 String getDestinationHeader()
          Decode the Destination Path
 String getHttpDate(long date)
          Get the HTTP format of the specified date.
 String getHttpDate(long date, Locale locale)
          Get the HTTP format of the specified date.
 String getIfHeader()
          Decode the if Header
 String getIfRangeHeader()
          Decode the If-Range Header
 String getInitParam(String name)
          This method wrap ServletConfig.getInitParameter()
 Iterator getInitParameterNames()
          This method wrap the ServletConfig.getInitParameterNames()
 byte[] getInputStreamContent()
          This method will cache the request InputStream to allow multiple parsing
 String getISO8601Date(long date)
          Format a Date using the format: yyyy-MM-dd'T'HH:mm:ss'Z' ISO 8601
 String getLockTokenHeader()
          Decode the Lock-Token Header
 String getOriginalPathHeader()
           
 boolean getOverwriteHeader()
          Decode the Overwrite Header or INFINITY if none
 String getPathHeader()
          Decode the Path Header
 Map getProperties(String resourcePath)
          Return all the properties for a given resource
 String getRangeHeader()
          Decode the Range
 String getRealPath(String uri)
          Returns the real file path for the given uri.
 String getServletURI()
          Return the Servlet URI ie http://server:port/webapp/servlet/my/path/resource.ext -> /webapp/servlet
ie http://server:port/webapp/servlet/my/path/ -> /webapp/servlet
TODO: Should check behavior with all application Server
static String getStatusText(int nHttpStatusCode)
          Returns the HTTP status text for the HTTP or WebDav status code specified by looking it up in the static mapping.
 int getTimeoutHeader()
          Decode the Timeout Header
abstract  WebdavFileSystem getWebdavFileSystem()
           
 boolean hasErrors()
          Check if the Context contains errors
 void init(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.ServletConfig conf)
          This method will initialize the WebdavContext with given HttpServletRequest, HttpServletResponse, and ServletConfig.
 boolean initAfterAuthentication()
          This method will initialize the WebdavContext.
 boolean isError(int code)
          Check the kind of a Status Code.
 void removeProperties(String resourcePath)
          Remove all properties for a given resource
 void removeProperty(String key, String resourcePath)
          Remove a property for the given resource path
 void sendError()
          Lookig for first error append then send an error throught response.
 void sendError(int code, String message)
          Send an error throught response
 void sendFile(int code, WebdavResource resource, boolean printContent)
          Send a File throught response
 void sendHtml(int code, String html, WebdavResource resource, boolean printContent)
          Send html representation of a Webdav Folder throught response
 void sendMultiStatus(String response)
          Send a multivalued response status
 void sendMultiStatus(String response, int status)
          Send a multivalued response status Set the response status code Set the Content Type Add XML Tag <multistatus> Embed in the tag the response
 void sendSingleStatus(int status, String response)
          Send a response status Set the Content Type
 void sendStatus()
          If there is no Status code then return If there is only one status code then sendError() or setStatus() If there is more than one Status code then sendMultiStatus()
 boolean service()
          Hook for service method to do Authentification and other filters
 void setHeader(String key, String value)
          Encapsulate response.setHeader()
 void setProperties(String resourcePath, Map properties)
          Overrided properties for a given resource path TODO: Should merge with existing Map ?
 String writeHtmlFolder(WebdavResource res)
          This method will generate an HTML Page representing a Web Folder TODO: Should Format Strings to be Web Compatible
 String writeLock(WebdavLock lock)
          <activelock>   <locktype></locktype>   <lockscope></lockscope>   <depth></depth>   <owner></owner>   <timeout></timeout>   <locktoken>     <href></href>   </locktoken> </activelock>
 String writeLocks(Collection locks)
          <lockdiscovery>The lock list</lockdiscovery>
 String writeProperties_FindAllProp(String resourcePath)
           
 String writeProperties_FindByProperty(String resourcePath, Collection props, Collection propertiesNotFound)
           
 String writeProperties_FindPropertyNames()
          From RFC 2518 <creationdate/> <displayname/> <getcontentlanguage/> <getcontentlength/> <getcontenttype/> <getetag/> <getlastmodified/> <resourcetype/> <source/> <lockdiscovery/> <supportedlock/> From Microsoft Web Folders http://msdn.microsoft.com/library/default.asp?
protected  void writeProperties(String resourcePath, String statusMsg, int propType, Collection properties, WebdavContext ctxt, XMLWriter xmlWriter)
          This method will write all properties of a given resource in a given type
 String writePropPatch(WebdavResource resource, Set propToSet, Set propToDel)
          Write PropPatch XML answer for the given WebdavResource.
 String writeResponse(String path, String content)
          <response> <href></href> content </response>
 void writeResponseProperties(String resPath, int propType, Collection properties, XMLWriter xmlWriter, WebdavContext ctxt)
           
 String writeStatus(int code, String message)
          <status>HTTP/1.1 code message</status>
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

SC_OK

public static final int SC_OK
Status code (200) indicating the request succeeded normally.

See Also:
Constant Field Values

SC_CREATED

public static final int SC_CREATED
Status code (201) indicating the request succeeded and created a new resource on the server.

See Also:
Constant Field Values

SC_ACCEPTED

public static final int SC_ACCEPTED
Status code (202) indicating that a request was accepted for processing, but was not completed.

See Also:
Constant Field Values

SC_NO_CONTENT

public static final int SC_NO_CONTENT
Status code (204) indicating that the request succeeded but that there was no new information to return.

See Also:
Constant Field Values

SC_MOVED_PERMANENTLY

public static final int SC_MOVED_PERMANENTLY
Status code (301) indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests.

See Also:
Constant Field Values

SC_MOVED_TEMPORARILY

public static final int SC_MOVED_TEMPORARILY
Status code (302) indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource.

See Also:
Constant Field Values

SC_NOT_MODIFIED

public static final int SC_NOT_MODIFIED
Status code (304) indicating that a conditional GET operation found that the resource was available and not modified.

See Also:
Constant Field Values

SC_BAD_REQUEST

public static final int SC_BAD_REQUEST
Status code (400) indicating the request sent by the client was syntactically incorrect.

See Also:
Constant Field Values

SC_UNAUTHORIZED

public static final int SC_UNAUTHORIZED
Status code (401) indicating that the request requires HTTP authentication.

See Also:
Constant Field Values

SC_FORBIDDEN

public static final int SC_FORBIDDEN
Status code (403) indicating the server understood the request but refused to fulfill it.

See Also:
Constant Field Values

SC_NOT_FOUND

public static final int SC_NOT_FOUND
Status code (404) indicating that the requested resource is not available.

See Also:
Constant Field Values

SC_INTERNAL_SERVER_ERROR

public static final int SC_INTERNAL_SERVER_ERROR
Status code (500) indicating an error inside the HTTP service which prevented it from fulfilling the request.

See Also:
Constant Field Values

SC_NOT_IMPLEMENTED

public static final int SC_NOT_IMPLEMENTED
Status code (501) indicating the HTTP service does not support the functionality needed to fulfill the request.

See Also:
Constant Field Values

SC_BAD_GATEWAY

public static final int SC_BAD_GATEWAY
Status code (502) indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway.

See Also:
Constant Field Values

SC_SERVICE_UNAVAILABLE

public static final int SC_SERVICE_UNAVAILABLE
Status code (503) indicating that the HTTP service is temporarily overloaded, and unable to handle the request.

See Also:
Constant Field Values

SC_CONTINUE

public static final int SC_CONTINUE
Status code (100) indicating the client may continue with its request. This interim response is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server.

See Also:
Constant Field Values

SC_METHOD_NOT_ALLOWED

public static final int SC_METHOD_NOT_ALLOWED
Status code (405) indicating the method specified is not allowed for the resource.

See Also:
Constant Field Values

SC_CONFLICT

public static final int SC_CONFLICT
Status code (409) indicating that the request could not be completed due to a conflict with the current state of the resource.

See Also:
Constant Field Values

SC_PRECONDITION_FAILED

public static final int SC_PRECONDITION_FAILED
Status code (412) indicating the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.

See Also:
Constant Field Values

SC_REQUEST_TOO_LONG

public static final int SC_REQUEST_TOO_LONG
Status code (413) indicating the server is refusing to process a request because the request entity is larger than the server is willing or able to process.

See Also:
Constant Field Values

SC_UNSUPPORTED_MEDIA_TYPE

public static final int SC_UNSUPPORTED_MEDIA_TYPE
Status code (415) indicating the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.

See Also:
Constant Field Values

SC_MULTI_STATUS

public static final int SC_MULTI_STATUS
Status code (207) indicating that the response requires providing status for multiple independent operations.

See Also:
Constant Field Values

SC_UNPROCESSABLE_ENTITY

public static final int SC_UNPROCESSABLE_ENTITY
Status code (418) indicating the entity body submitted with the PATCH method was not understood by the resource.

See Also:
Constant Field Values

SC_INSUFFICIENT_SPACE_ON_RESOURCE

public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE
Status code (419) indicating that the resource does not have sufficient space to record the state of the resource after the execution of this method.

See Also:
Constant Field Values

SC_METHOD_FAILURE

public static final int SC_METHOD_FAILURE
Status code (420) indicating the method was not executed on a particular resource within its scope because some part of the method's execution failed causing the entire method to be aborted.

See Also:
Constant Field Values

SC_LOCKED

public static final int SC_LOCKED
Status code (423) indicating the destination resource of a method is locked, and either the request did not contain a valid Lock-Info header, or the Lock-Info header identifies a lock held by another principal.

See Also:
Constant Field Values

mapStatusCodes

protected static final Hashtable mapStatusCodes
This Hashtable contains the mapping of HTTP and WebDAV status codes to descriptive text. This is a static variable.


setOkStatusCodes

protected static final Set setOkStatusCodes
This HashSet contains all StatusCodes that doesn't define an error.


propRFC2518Set

protected static final Set propRFC2518Set
Sets of webdav properties used to filter webdav properties for folder, files, microsoft, rfc2518


propMSWebFolderSet

protected static final Set propMSWebFolderSet
Microsoft Implementation can be found here:


propAllSet

protected static final Set propAllSet

propFileSet

protected static final Set propFileSet

propSubSet

protected static final Set propSubSet

httpDateUS

protected SimpleDateFormat httpDateUS

httpDate

protected SimpleDateFormat httpDate

isoDate

protected SimpleDateFormat isoDate

NAMESPACEINFO

public static final String NAMESPACEINFO
NAMESPACEINFO DAV: used for RFC2518 Properties declaration

See Also:
Constant Field Values

NAMESPACE

public static final String NAMESPACE
NAMESPACE shortcut for DAV: default value is D:

See Also:
Constant Field Values

SUPPORTED_LOCKS

public static final String SUPPORTED_LOCKS
SUPPORTED_LOCKS convenient method for locks discovery

See Also:
Constant Field Values

EMPTY_STRING

public static final String EMPTY_STRING
EMPTY_STRING Convenient empty String

See Also:
Constant Field Values

INFINITY

public static final int INFINITY
INFINITY used for internal RFC2518

See Also:
Constant Field Values

NAMESPACE_MS

public static final String NAMESPACE_MS
When PROPFINDing collections, the webfolder client tries to retrieve values for a set of properties in the "DAV:" namespace, although they aren't defined in any WebDAV related specification (DAV:contentclass, DAV:defaultdocument, DAV:href, DAV:iscollection, DAV:ishidden, DAV:isreadonly, DAV:isroot, DAV:isstructureddocument, DAV:lastaccessed, DAV:name and DAV:parentname). Except one (DAV:hidden), none of these properties seems to be actually used by the client. Note that proprietary properties (vendor extensions) MUST NOT use the "DAV:" namespace.

See Also:
Constant Field Values

NAMESPACEINFO_MS

public static final String NAMESPACEINFO_MS
See Also:
NAMESPACE_MS, Constant Field Values

statusPath

protected List statusPath

statusCode

protected List statusCode

statusMsg

protected List statusMsg

hasError

protected boolean hasError

inputStreamContent

protected byte[] inputStreamContent

servletURI

protected String servletURI

req

public javax.servlet.http.HttpServletRequest req

res

public javax.servlet.http.HttpServletResponse res

conf

public javax.servlet.ServletConfig conf

lang

public String lang

locale

public Locale locale

originalPathHeader

protected String originalPathHeader

memoryProperties

public static final Map memoryProperties
This is an in Memory Property manager used to handle PROPPATCH even if JCMS will handle it

Constructor Detail

WebdavContext

public WebdavContext()
Method Detail

getStatusText

public static String getStatusText(int nHttpStatusCode)
Returns the HTTP status text for the HTTP or WebDav status code specified by looking it up in the static mapping. This is a static function.

Parameters:
nHttpStatusCode - [IN] HTTP or WebDAV status code
Returns:
A string with a short descriptive phrase for the HTTP status code (e.g., "OK").

addStatusCodeMap

protected static void addStatusCodeMap(int nKey,
                                       String strVal)
Adds a new status code -> status text mapping. This is a static method because the mapping is a static variable.

Parameters:
nKey - [IN] HTTP or WebDAV status code
strVal - [IN] HTTP status text

addStatusCodeSet

protected static void addStatusCodeSet(int nKey)
Adds a new status code. This is a static method because the mapping is a static variable.

Parameters:
nKey - [IN] HTTP or WebDAV status code

init

public void init(javax.servlet.http.HttpServletRequest req,
                 javax.servlet.http.HttpServletResponse res,
                 javax.servlet.ServletConfig conf)
This method will initialize the WebdavContext with given HttpServletRequest, HttpServletResponse, and ServletConfig.

Parameters:
req - the HttpServletRequest
res - the HttpServletResponse
conf - the ServletConfig

initAfterAuthentication

public boolean initAfterAuthentication()
This method will initialize the WebdavContext.


service

public boolean service()
Hook for service method to do Authentification and other filters

Returns:
false to stop request processing

getWebdavFileSystem

public abstract WebdavFileSystem getWebdavFileSystem()
Returns:
WebdavFileSystem the Webdav FileSystem from the context or any other ways.

authenticate

public abstract boolean authenticate()
This method have to do all authentication stuff with any behavior

Returns:
true if authentication has been done

getRealPath

public String getRealPath(String uri)
Returns the real file path for the given uri. The file path will be in native path format (with native path separators). This method calls context.getRealPath() but it cleans the results to be cross-AppServer. It insures that if the uri contains, resp. does not contains, a trailing '/' the return path will, resp. will not, contains a trailing File.separator.

Parameters:
uri - the path of the resource
Returns:
path relative to the application root to be translated.

getInputStreamContent

public byte[] getInputStreamContent()
This method will cache the request InputStream to allow multiple parsing

Returns:
byte[] the cached response

getServletURI

public String getServletURI()
Return the Servlet URI ie http://server:port/webapp/servlet/my/path/resource.ext -> /webapp/servlet
ie http://server:port/webapp/servlet/my/path/ -> /webapp/servlet
TODO: Should check behavior with all application Server

Returns:
String the Servlet URI with the Webapp name

getInitParam

public String getInitParam(String name)
This method wrap ServletConfig.getInitParameter()

Parameters:
name - the prameter name
Returns:
String the parameter value for the given name

getInitParameterNames

public Iterator getInitParameterNames()
This method wrap the ServletConfig.getInitParameterNames()

Returns:
Iterator on the init parameter names

getDestinationHeader

public String getDestinationHeader()
Decode the Destination Path

Returns:
String the Destination Path Header

getPathHeader

public String getPathHeader()
Decode the Path Header

Returns:
String the Path Header

getOriginalPathHeader

public String getOriginalPathHeader()

getOverwriteHeader

public boolean getOverwriteHeader()
Decode the Overwrite Header or INFINITY if none

Returns:
boolean the Overwrite Header

getDepthHeader

public int getDepthHeader()
Decode the depth Header or INFINITY if none

Returns:
int the depth Header

getIfHeader

public String getIfHeader()
Decode the if Header

Returns:
String the if Header

getIfRangeHeader

public String getIfRangeHeader()
Decode the If-Range Header

Returns:
String the If-Range Header

getRangeHeader

public String getRangeHeader()
Decode the Range

Returns:
String the Range Header

getLockTokenHeader

public String getLockTokenHeader()
Decode the Lock-Token Header

Returns:
String the Lock-Token Header

getTimeoutHeader

public int getTimeoutHeader()
Decode the Timeout Header

Returns:
int the Timeout Header

writeResponse

public String writeResponse(String path,
                            String content)
<response> <href></href> content </response>

Parameters:
path - the resource path
content - the XML to put inside
Returns:
String an XML String

writeResponseProperties

public void writeResponseProperties(String resPath,
                                    int propType,
                                    Collection properties,
                                    XMLWriter xmlWriter,
                                    WebdavContext ctxt)

writeProperties

protected void writeProperties(String resourcePath,
                               String statusMsg,
                               int propType,
                               Collection properties,
                               WebdavContext ctxt,
                               XMLWriter xmlWriter)
This method will write all properties of a given resource in a given type

Parameters:
resourcePath - the resource to work with
statusMsg - the status message (May be null or an Error if resource is locked)
propType - the type of property to display
properties - the list of property to display
ctxt - the Webdav Context

writeStatus

public String writeStatus(int code,
                          String message)
<status>HTTP/1.1 code message</status>

Parameters:
code - the HTTP Status code
message - the message to display or null
Returns:
String an XML String

writeLocks

public String writeLocks(Collection locks)
<lockdiscovery>The lock list</lockdiscovery>

Parameters:
locks - a Collection of WebdavLock locks
Returns:
String an XML String

writeLock

public String writeLock(WebdavLock lock)
<activelock>   <locktype></locktype>   <lockscope></lockscope>   <depth></depth>   <owner></owner>   <timeout></timeout>   <locktoken>     <href></href>   </locktoken> </activelock>

Parameters:
lock - a WebdavLock
Returns:
String an XML String

addProperty

public void addProperty(String key,
                        String value,
                        String resourcePath)
Add a property for the given resource path

Parameters:
key - the property name
value - the property value
resourcePath - the path of the resource

removeProperty

public void removeProperty(String key,
                           String resourcePath)
Remove a property for the given resource path

Parameters:
key - the property name
resourcePath - the taret resource

setProperties

public void setProperties(String resourcePath,
                          Map properties)
Overrided properties for a given resource path TODO: Should merge with existing Map ?

Parameters:
resourcePath - the path of the resource
properties - the Map of properties

removeProperties

public void removeProperties(String resourcePath)
Remove all properties for a given resource

Parameters:
resourcePath - the path of the resource

getProperties

public Map getProperties(String resourcePath)
Return all the properties for a given resource

Parameters:
resourcePath - the path of the resource
Returns:
Map the map of properties

getAllProperties

public Map getAllProperties()
Returns:
Map of Map of all properties for all resources

writePropPatch

public String writePropPatch(WebdavResource resource,
                             Set propToSet,
                             Set propToDel)
Write PropPatch XML answer for the given WebdavResource. This method has not been correctly tested because JCMS does handle correctly PROPATCH for the moment.

Parameters:
resource - the Webdav Resource
propToSet - the Set of Properties to Set
propToDel - the Set of Properties to remove
Returns:
String representing the XML response.

writeProperties_FindPropertyNames

public String writeProperties_FindPropertyNames()
From RFC 2518 From Microsoft Web Folders http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wss/wss/_cdo_schema_dav.asp http://www.greenbytes.de/tech/webdav/webdavfaq.html http://www.greenbytes.de/tech/webdav/draft-hopmann-collection-props-00.txt

Returns:
String an XML String

writeProperties_FindAllProp

public String writeProperties_FindAllProp(String resourcePath)
Parameters:
resourcePath - the resource path to work with
Returns:
String an XML String
See Also:
writeProperties_FindPropertyNames()

writeProperties_FindByProperty

public String writeProperties_FindByProperty(String resourcePath,
                                             Collection props,
                                             Collection propertiesNotFound)
Parameters:
resourcePath - the resource path to work with
props - a Collection of properties to work with
propertiesNotFound - a Collection filled by wrong properties
Returns:
String an XML String
See Also:
writeProperties_FindPropertyNames()

writeHtmlFolder

public String writeHtmlFolder(WebdavResource res)
This method will generate an HTML Page representing a Web Folder TODO: Should Format Strings to be Web Compatible

Parameters:
res - the WebdavResource to work with
Returns:
String an HTML Web Page representation

sendSingleStatus

public void sendSingleStatus(int status,
                             String response)
Send a response status

Parameters:
status - the response status
response - the response tag

sendMultiStatus

public void sendMultiStatus(String response,
                            int status)
Send a multivalued response status

Parameters:
status - the response status
response - the response tag

sendMultiStatus

public void sendMultiStatus(String response)
Send a multivalued response status

Parameters:
response - the response tag

sendStatus

public void sendStatus()
If there is no Status code then return If there is only one status code then sendError() or setStatus() If there is more than one Status code then sendMultiStatus()


sendError

public void sendError(int code,
                      String message)
Send an error throught response

Parameters:
code - the error code
message - the error message

sendError

public void sendError()
Lookig for first error append then send an error throught response.


sendHtml

public void sendHtml(int code,
                     String html,
                     WebdavResource resource,
                     boolean printContent)
Send html representation of a Webdav Folder throught response

Parameters:
code - the status code
html - the html to send
resource - the WebdavResource
printContent - HEAD or GET ?

sendFile

public void sendFile(int code,
                     WebdavResource resource,
                     boolean printContent)
Send a File throught response

Parameters:
code - the error code
resource - the WebdavResource
printContent - HEAD or GET ?

addHeader

public void addHeader(String key,
                      String value)
Encapsulate response.addHeader()

Parameters:
key - the header key
value - the header value

setHeader

public void setHeader(String key,
                      String value)
Encapsulate response.setHeader()

Parameters:
key - the header key
value - the header value

isError

public boolean isError(int code)
Check the kind of a Status Code.

Parameters:
code - the StatusCode
Returns:
true if the Status Code is an Error

hasErrors

public boolean hasErrors()
Check if the Context contains errors

Returns:
true if Context contains errors status codes

appendStatus

public void appendStatus(int code,
                         String message,
                         String path)
Append a StatusCode to the Context.

Parameters:
code - the status code
message - the status message
path - the status path. Must start with a /

appendStatus

public void appendStatus(int code,
                         String message)
Append a StatusCode to the Context.

Parameters:
code - the status code
message - the status message

appendStatus

public void appendStatus(int code)
Append a StatusCode to the Context.

Parameters:
code - the status code

escapeWebdavChars

public static String escapeWebdavChars(String str)

getISO8601Date

public String getISO8601Date(long date)
Format a Date using the format: yyyy-MM-dd'T'HH:mm:ss'Z' ISO 8601

Parameters:
date - a long representing a date
Returns:
String a formated Date

getHttpDate

public final String getHttpDate(long date)
Get the HTTP format of the specified date. The used format is EEE, dd MMM yyyy HH:mm:ss zzz

Parameters:
date - a long representing a date
Returns:
String a formated Date

getHttpDate

public final String getHttpDate(long date,
                                Locale locale)
Get the HTTP format of the specified date. The used format is EEE, dd MMM yyyy HH:mm:ss zzz

Parameters:
date - a long representing a date
locale - the locale to use
Returns:
String a formated Date

decodePath

public static String decodePath(String path)
Call URLDecoder with try/catch

Parameters:
path - the URL encoded path
Returns:
String the decoded path

encodePath

public static String encodePath(String path)
Encode Href to work display correct URL

Parameters:
path - the path to encode
Returns:
String the encoded path


Copyright © 2001-2007 Jalios SA. All Rights Reserved.