public abstract class WebdavContext
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
javax.servlet.ServletConfig |
conf |
static java.lang.String |
EMPTY_STRING
EMPTY_STRING Convenient empty String
|
protected boolean |
hasError |
protected java.text.SimpleDateFormat |
httpDate |
protected java.text.SimpleDateFormat |
httpDateUS |
static int |
INFINITY
INFINITY used for internal RFC2518
|
protected byte[] |
inputStreamContent |
protected java.text.SimpleDateFormat |
isoDate |
java.lang.String |
lang |
java.util.Locale |
locale |
protected static java.util.Hashtable<java.lang.Integer,java.lang.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 java.lang.String |
originalPathHeader |
protected static java.util.Set<WebdavProperty> |
propAllSet |
protected static java.util.Set<WebdavProperty> |
propFileSet |
protected static java.util.Set<WebdavProperty> |
propMSWebFolderSet
Microsoft Implementation can be found here:
http://msdn.microsoft.com/library/default.asp?
|
protected static java.util.Set<WebdavProperty> |
propRFC2518Set
Sets of webdav properties used to filter webdav
properties for folder, files, microsoft, rfc2518
|
protected static java.util.Set<WebdavProperty> |
propSubSet |
javax.servlet.http.HttpServletRequest |
req |
javax.servlet.http.HttpServletResponse |
res |
static java.lang.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 java.lang.String |
servletURI |
protected static java.util.Set<java.lang.Integer> |
setOkStatusCodes
This HashSet contains all StatusCodes that doesn't
define an error.
|
protected java.util.List<java.lang.Integer> |
statusCode |
protected java.util.List<org.jdom.Element> |
statusElm |
protected java.util.List<java.lang.String> |
statusMsg |
protected java.util.List<java.lang.String> |
statusPath |
Constructor and Description |
---|
WebdavContext() |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String key,
java.lang.String value)
Encapsulate response.addHeader()
|
protected static void |
addStatusCodeMap(int nKey,
java.lang.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,
java.lang.String message)
Append a StatusCode to the Context.
|
void |
appendStatus(int code,
java.lang.String message,
java.lang.String path)
Append a StatusCode to the Context.
|
void |
appendStatus(int code,
java.lang.String message,
java.lang.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 java.lang.String |
decodePath(java.lang.String path)
Call URLDecoder with try/catch
|
static java.lang.String |
encodePath(java.lang.String s)
Convenient method to encode a WebDav path using webdav encoding.
|
static java.lang.String |
escapeWebdavChars(java.lang.String str)
Replace characters not supported in WebDAV from the specfied string.
|
int |
getDepthHeader()
Decode the depth Header or INFINITY if none
|
java.lang.String |
getDestinationHeader()
Decode the Destination Path
|
java.lang.String |
getHttpDate(long date)
Get the HTTP format of the specified date.
|
java.lang.String |
getHttpDate(long date,
java.util.Locale locale)
Get the HTTP format of the specified date.
|
java.lang.String |
getIfHeader()
Decode the if Header
|
java.lang.String |
getIfRangeHeader()
Decode the If-Range Header
|
java.lang.String |
getInitParam(java.lang.String name)
This method wrap ServletConfig.getInitParameter()
|
java.util.Iterator<java.lang.String> |
getInitParameterNames()
This method wrap the ServletConfig.getInitParameterNames()
|
byte[] |
getInputStreamContent()
This method will cache the request InputStream
to allow multiple parsing
|
java.lang.String |
getISO8601Date(long date)
Format a Date using the format: yyyy-MM-dd'T'HH:mm:ss'Z'
ISO 8601
|
java.lang.String |
getLockTokenHeader()
Decode the Lock-Token Header
|
java.lang.String |
getLockTokenValue()
Retrieve the value extracted from the Lock-Token header.
|
java.lang.String |
getOriginalPathHeader() |
boolean |
getOverwriteHeader()
Decode the Overwrite Header or INFINITY if none
|
java.lang.String |
getPathHeader()
Decode the Path Header
|
java.lang.String |
getRangeHeader()
Decode the Range
|
java.lang.String |
getRealPath(java.lang.String uri)
Returns the real file path for the given uri.
|
java.lang.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 java.lang.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,
java.lang.String message)
Send an error throught response
|
void |
sendFile(int code,
WebdavResource resource,
boolean printContent)
Send a File throught response
|
void |
sendHtml(int code,
java.lang.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(java.util.List<org.jdom.Element> responseElms)
Send a multivalued response status
|
void |
sendMultiStatus(java.util.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,
java.lang.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(java.lang.String key,
java.lang.String value)
Encapsulate response.setHeader()
|
java.lang.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(java.util.Collection<WebdavLock> locks)
<lockdiscovery>The lock list</lockdiscovery>
|
java.util.List<org.jdom.Element> |
writeProperties_FindAllProp(java.lang.String resourcePath) |
java.util.List<org.jdom.Element> |
writeProperties_FindByProperty(java.lang.String resourcePath,
java.util.Collection<WebdavProperty> props,
java.util.Collection<WebdavProperty> propertiesNotFound) |
java.util.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?
|
protected java.util.List<org.jdom.Element> |
writeProperties(java.lang.String resourcePath,
java.lang.String statusMsg,
com.jalios.jcms.webdav.WebdavManager.PropFindType propType,
java.util.Collection<WebdavProperty> properties,
WebdavContext ctxt)
This method will write all properties of a given resource in a given type
|
java.util.List<org.jdom.Element> |
writePropPatch(WebdavResource resource,
java.util.List<WebdavProperty> wdPropList)
Write PropPatch XML answer for the given WebdavResource.
|
org.jdom.Element |
writeResponse(java.lang.String path,
java.util.List<org.jdom.Element> contentList)
<response>
<href></href>
content
</response>
|
org.jdom.Element |
writeResponseProperties(java.lang.String resPath,
com.jalios.jcms.webdav.WebdavManager.PropFindType propType,
java.util.Collection<WebdavProperty> properties,
WebdavContext ctxt) |
org.jdom.Element |
writeStatus(int code,
java.lang.String message)
<status>HTTP/1.1 code message</status>
|
public static final java.lang.String REVISION
public static final int SC_OK
public static final int SC_CREATED
public static final int SC_ACCEPTED
public static final int SC_NO_CONTENT
public static final int SC_MOVED_PERMANENTLY
public static final int SC_MOVED_TEMPORARILY
public static final int SC_NOT_MODIFIED
public static final int SC_BAD_REQUEST
public static final int SC_UNAUTHORIZED
public static final int SC_FORBIDDEN
public static final int SC_NOT_FOUND
public static final int SC_INTERNAL_SERVER_ERROR
public static final int SC_NOT_IMPLEMENTED
public static final int SC_BAD_GATEWAY
public static final int SC_SERVICE_UNAVAILABLE
public static final int SC_CONTINUE
public static final int SC_METHOD_NOT_ALLOWED
public static final int SC_CONFLICT
public static final int SC_PRECONDITION_FAILED
public static final int SC_REQUEST_TOO_LONG
public static final int SC_UNSUPPORTED_MEDIA_TYPE
public static final int SC_MULTI_STATUS
public static final int SC_UNPROCESSABLE_ENTITY
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE
public static final int SC_METHOD_FAILURE
public static final int SC_LOCKED
protected static final java.util.Hashtable<java.lang.Integer,java.lang.String> mapStatusCodes
protected static final java.util.Set<java.lang.Integer> setOkStatusCodes
public static final org.jdom.Namespace NAMESPACE
protected static final java.util.Set<WebdavProperty> propRFC2518Set
public static final org.jdom.Namespace NAMESPACE_MS
protected static final java.util.Set<WebdavProperty> propMSWebFolderSet
protected static final java.util.Set<WebdavProperty> propAllSet
protected static final java.util.Set<WebdavProperty> propFileSet
protected static final java.util.Set<WebdavProperty> propSubSet
protected java.text.SimpleDateFormat httpDateUS
protected java.text.SimpleDateFormat httpDate
protected java.text.SimpleDateFormat isoDate
public static final java.lang.String EMPTY_STRING
public static final int INFINITY
protected java.util.List<java.lang.String> statusPath
protected java.util.List<java.lang.Integer> statusCode
protected java.util.List<java.lang.String> statusMsg
protected java.util.List<org.jdom.Element> statusElm
protected boolean hasError
protected byte[] inputStreamContent
protected java.lang.String servletURI
public javax.servlet.http.HttpServletRequest req
public javax.servlet.http.HttpServletResponse res
public javax.servlet.ServletConfig conf
public java.lang.String lang
public java.util.Locale locale
protected java.lang.String originalPathHeader
public static java.lang.String getStatusText(int nHttpStatusCode)
nHttpStatusCode
- [IN] HTTP or WebDAV status codeprotected static void addStatusCodeMap(int nKey, java.lang.String strVal)
nKey
- [IN] HTTP or WebDAV status codestrVal
- [IN] HTTP status textprotected static void addStatusCodeSet(int nKey)
nKey
- [IN] HTTP or WebDAV status codepublic void init(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, javax.servlet.ServletConfig conf)
req
- the HttpServletRequestres
- the HttpServletResponseconf
- the ServletConfigpublic boolean initAfterAuthentication()
public boolean service()
public abstract WebdavFileSystem getWebdavFileSystem()
public abstract boolean authenticate()
public java.lang.String getRealPath(java.lang.String uri)
uri
- the path of the resourcepublic byte[] getInputStreamContent()
public java.lang.String getServletURI()
public java.lang.String getInitParam(java.lang.String name)
name
- the prameter namepublic java.util.Iterator<java.lang.String> getInitParameterNames()
public java.lang.String getDestinationHeader()
public java.lang.String getPathHeader()
public java.lang.String getOriginalPathHeader()
public boolean getOverwriteHeader()
public int getDepthHeader()
public java.lang.String getIfHeader()
public java.lang.String getIfRangeHeader()
public java.lang.String getRangeHeader()
public java.lang.String getLockTokenHeader()
public java.lang.String getLockTokenValue()
public int getTimeoutHeader()
public org.jdom.Element writeResponse(java.lang.String path, java.util.List<org.jdom.Element> contentList)
path
- the resource pathcontentList
- the XML to put insidepublic org.jdom.Element writeResponseProperties(java.lang.String resPath, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, java.util.Collection<WebdavProperty> properties, WebdavContext ctxt)
protected java.util.List<org.jdom.Element> writeProperties(java.lang.String resourcePath, java.lang.String statusMsg, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, java.util.Collection<WebdavProperty> properties, WebdavContext ctxt)
resourcePath
- the resource to work withstatusMsg
- the status message (May be null or an Error if resource is locked)propType
- the type of property to displayproperties
- the list of property to displayctxt
- the Webdav Contextpublic org.jdom.Element writeStatus(int code, java.lang.String message)
code
- the HTTP Status codemessage
- the message to display or nullpublic org.jdom.Element writeLocks(java.util.Collection<WebdavLock> locks)
locks
- a Collection of WebdavLock lockspublic org.jdom.Element writeLock(WebdavLock lock)
lock
- a WebdavLockpublic java.util.List<org.jdom.Element> writePropPatch(WebdavResource resource, java.util.List<WebdavProperty> wdPropList)
resource
- the Webdav ResourcewdPropList
- the List of WebdavProperty to update (remove when value is null, add/update otherwise)public java.util.List<org.jdom.Element> writeProperties_FindPropertyNames()
public java.util.List<org.jdom.Element> writeProperties_FindAllProp(java.lang.String resourcePath)
resourcePath
- the resource path to work withwriteProperties_FindPropertyNames()
public java.util.List<org.jdom.Element> writeProperties_FindByProperty(java.lang.String resourcePath, java.util.Collection<WebdavProperty> props, java.util.Collection<WebdavProperty> propertiesNotFound)
resourcePath
- the resource path to work withprops
- a Collection of properties to work withpropertiesNotFound
- a Collection filled by wrong propertieswriteProperties_FindPropertyNames()
public java.lang.String writeHtmlFolder(WebdavResource res)
res
- the WebdavResource to work withpublic void sendSingleStatus(int status, java.lang.String responseText)
status
- the response statusresponseText
- the response tagpublic void sendSingleStatus(int status, org.jdom.Element responseElm)
status
- the response statusresponseElm
- the response tagpublic void sendMultiStatus(java.util.List<org.jdom.Element> responseElms, int status)
status
- the response statusresponseElms
- the response tagpublic void sendMultiStatus(org.jdom.Element responseElm)
responseElm
- the response tagpublic void sendMultiStatus(java.util.List<org.jdom.Element> responseElms)
responseElms
- the responses tagpublic void sendStatus()
public void sendError(int code, java.lang.String message)
code
- the error codemessage
- the error messagepublic void sendError()
public void sendHtml(int code, java.lang.String html, WebdavResource resource, boolean printContent)
code
- the status codehtml
- the html to sendresource
- the WebdavResourceprintContent
- HEAD or GET ?public void sendFile(int code, WebdavResource resource, boolean printContent)
code
- the error coderesource
- the WebdavResourceprintContent
- HEAD or GET ?public void addHeader(java.lang.String key, java.lang.String value)
key
- the header keyvalue
- the header valuepublic void setHeader(java.lang.String key, java.lang.String value)
key
- the header keyvalue
- the header valuepublic boolean isError(int code)
code
- the StatusCodepublic boolean hasErrors()
public void appendStatus(int code, java.lang.String message, java.lang.String path, org.jdom.Element elm)
code
- the status codemessage
- the status messagepath
- the status path. Must start with a /elm
- an optionnal elm element to use for output instead of simple messagepublic void appendStatus(int code, java.lang.String message, java.lang.String path)
code
- the status codemessage
- the status messagepath
- the status path. Must start with a /public void appendStatus(int code, java.lang.String message)
code
- the status codemessage
- the status messagepublic void appendStatus(int code)
code
- the status codepublic static java.lang.String escapeWebdavChars(java.lang.String str)
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
str
- the string to escapepublic java.lang.String getISO8601Date(long date)
date
- a long representing a datepublic final java.lang.String getHttpDate(long date)
date
- a long representing a datepublic final java.lang.String getHttpDate(long date, java.util.Locale locale)
date
- a long representing a datelocale
- the locale to usepublic static java.lang.String encodePath(java.lang.String s)
URLEncoder.encode(String, String)
,
but space is encoded with %20 and '/' is not encoded.s
- String
to be translated.String
.Util.encodeUrl(String, String)
public static java.lang.String decodePath(java.lang.String path)
path
- the URL encoded pathCopyright © 2001-2010 Jalios SA. All Rights Reserved.