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: 30872 $
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<Integer,String> mapStatusCodes
          This Hashtable contains the mapping of HTTP and WebDAV status codes to descriptive text.
static org.jdom.Namespace NAMESPACE
          WebDav RFC2518 NAMESPACE - DAV: used for RFC2518 Properties declaration - D shortcut
static org.jdom.Namespace 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).
protected  String originalPathHeader
           
protected static Set<WebdavProperty> propAllSet
           
protected static Set<WebdavProperty> propFileSet
           
protected static Set<WebdavProperty> propMSWebFolderSet
          Microsoft Implementation can be found here: 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
protected static Set<WebdavProperty> propRFC2518Set
          Sets of webdav properties used to filter webdav properties for folder, files, microsoft, rfc2518
protected static Set<WebdavProperty> 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<Integer> setOkStatusCodes
          This HashSet contains all StatusCodes that doesn't define an error.
protected  List<Integer> statusCode
           
protected  List<org.jdom.Element> statusElm
           
protected  List<String> statusMsg
           
protected  List<String> statusPath
           
 
Constructor Summary
WebdavContext()
           
 
Method Summary
 void addHeader(String key, String value)
          Encapsulate response.addHeader()
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.
 void appendStatus(int code, String message, String path, org.jdom.Element elm)
          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 s)
          Convenient method to encode a WebDav path using webdav encoding.
static String escapeWebdavChars(String str)
          Replace characters not supported in WebDAV from the specfied string.
 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<String> 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 getLockTokenValue()
          Retrieve the value extracted from the Lock-Token header.
 String getOriginalPathHeader()
           
 boolean getOverwriteHeader()
          Decode the Overwrite Header or INFINITY if none
 String getPathHeader()
          Decode the Path Header
 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 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(org.jdom.Element responseElm)
          Send a multivalued response status
 void sendMultiStatus(List<org.jdom.Element> responseElms)
          Send a multivalued response status
 void sendMultiStatus(List<org.jdom.Element> responseElms, 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, org.jdom.Element responseElm)
          Send a response status Set the Content Type
 void sendSingleStatus(int status, String responseText)
          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()
 String writeHtmlFolder(WebdavResource res)
          This method will generate an HTML Page representing a Web Folder TODO: Should Format Strings to be Web Compatible
 org.jdom.Element writeLock(WebdavLock lock)
          <activelock>   <locktype></locktype>   <lockscope></lockscope>   <depth></depth>   <owner></owner>   <timeout></timeout>   <locktoken>     <href></href>   </locktoken> </activelock>
 org.jdom.Element writeLocks(Collection<WebdavLock> locks)
          <lockdiscovery>The lock list</lockdiscovery>
 List<org.jdom.Element> writeProperties_FindAllProp(String resourcePath)
           
 List<org.jdom.Element> writeProperties_FindByProperty(String resourcePath, Collection<WebdavProperty> props, Collection<WebdavProperty> propertiesNotFound)
           
 List<org.jdom.Element> 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?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 <name/> <href/> <isreadonly/> <parentname/> <ishidden/> <contentclass/> <lastaccessed/> <defaultdocument/> <isroot/> <iscollection/> <isstructureddocument/> <save-view-location/> <save-profile-form-location/>
protected  List<org.jdom.Element> writeProperties(String resourcePath, String statusMsg, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, Collection<WebdavProperty> properties, WebdavContext ctxt)
          This method will write all properties of a given resource in a given type
 List<org.jdom.Element> writePropPatch(WebdavResource resource, List<WebdavProperty> wdPropList)
          Write PropPatch XML answer for the given WebdavResource.
 org.jdom.Element writeResponse(String path, List<org.jdom.Element> contentList)
          <response> <href></href> content </response>
 org.jdom.Element writeResponseProperties(String resPath, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, Collection<WebdavProperty> properties, WebdavContext ctxt)
           
 org.jdom.Element 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<Integer,String> 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<Integer> setOkStatusCodes
This HashSet contains all StatusCodes that doesn't define an error.


NAMESPACE

public static final org.jdom.Namespace NAMESPACE
WebDav RFC2518 NAMESPACE - DAV: used for RFC2518 Properties declaration - D shortcut


propRFC2518Set

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


NAMESPACE_MS

public static final org.jdom.Namespace 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.


propMSWebFolderSet

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


propAllSet

protected static final Set<WebdavProperty> propAllSet

propFileSet

protected static final Set<WebdavProperty> propFileSet

propSubSet

protected static final Set<WebdavProperty> propSubSet

httpDateUS

protected SimpleDateFormat httpDateUS

httpDate

protected SimpleDateFormat httpDate

isoDate

protected SimpleDateFormat isoDate

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

statusPath

protected List<String> statusPath

statusCode

protected List<Integer> statusCode

statusMsg

protected List<String> statusMsg

statusElm

protected List<org.jdom.Element> statusElm

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
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.

Returns:
true

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<String> 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

getLockTokenValue

public String getLockTokenValue()
Retrieve the value extracted from the Lock-Token header.

Returns:
null if no lock token was provided or if an invalid lock token was specified, otherwise return the value inside the <>
Since:
jcms-6.1

getTimeoutHeader

public int getTimeoutHeader()
Decode the Timeout Header

Returns:
int the Timeout Header

writeResponse

public org.jdom.Element writeResponse(String path,
                                      List<org.jdom.Element> contentList)
<response> <href></href> content </response>

Parameters:
path - the resource path
contentList - the XML to put inside
Returns:
Element the response Element

writeResponseProperties

public org.jdom.Element writeResponseProperties(String resPath,
                                                com.jalios.jcms.webdav.WebdavManager.PropFindType propType,
                                                Collection<WebdavProperty> properties,
                                                WebdavContext ctxt)

writeProperties

protected List<org.jdom.Element> writeProperties(String resourcePath,
                                                 String statusMsg,
                                                 com.jalios.jcms.webdav.WebdavManager.PropFindType propType,
                                                 Collection<WebdavProperty> properties,
                                                 WebdavContext ctxt)
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 org.jdom.Element 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 org.jdom.Element writeLocks(Collection<WebdavLock> locks)
<lockdiscovery>The lock list</lockdiscovery>

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

writeLock

public org.jdom.Element 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

writePropPatch

public List<org.jdom.Element> writePropPatch(WebdavResource resource,
                                             List<WebdavProperty> wdPropList)
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
wdPropList - the List of WebdavProperty to update (remove when value is null, add/update otherwise)
Returns:
String representing the XML response.

writeProperties_FindPropertyNames

public List<org.jdom.Element> 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 List<org.jdom.Element> writeProperties_FindAllProp(String resourcePath)
Parameters:
resourcePath - the resource path to work with
Returns:
String an XML String
See Also:
writeProperties_FindPropertyNames()

writeProperties_FindByProperty

public List<org.jdom.Element> writeProperties_FindByProperty(String resourcePath,
                                                             Collection<WebdavProperty> props,
                                                             Collection<WebdavProperty> 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 responseText)
Send a response status

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

sendSingleStatus

public void sendSingleStatus(int status,
                             org.jdom.Element responseElm)
Send a response status

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

sendMultiStatus

public void sendMultiStatus(List<org.jdom.Element> responseElms,
                            int status)
Send a multivalued response status

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

sendMultiStatus

public void sendMultiStatus(org.jdom.Element responseElm)
Send a multivalued response status

Parameters:
responseElm - the response tag

sendMultiStatus

public void sendMultiStatus(List<org.jdom.Element> responseElms)
Send a multivalued response status

Parameters:
responseElms - the responses 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,
                         org.jdom.Element elm)
Append a StatusCode to the Context.

Parameters:
code - the status code
message - the status message
path - the status path. Must start with a /
elm - an optionnal elm element to use for output instead of simple message

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)
Replace characters not supported in WebDAV from the specfied string.

Invalid characters are all characters specified in property channel.webdav.invalid-chars.
Those characters are replaced with the character specified by property channel.webdav.invalid-chars.replacement

Parameters:
str - the string to escape
Returns:
the escaped string if any invalid characters were found, otherwise return the same string.

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

encodePath

public static String encodePath(String s)
Convenient method to encode a WebDav path using webdav encoding.
Same implementation as URLEncoder.encode(String, String), but space is encoded with %20 and '/' is not encoded.

Parameters:
s - String to be translated.
Returns:
the translated String.
Since:
jcms-6.1
See Also:
Util.encodeUrl(String, String)

decodePath

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

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


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