|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.webdav.WebdavContext
public abstract class WebdavContext
This class is an Abstract Representation of a Webdav Context. It is used to:
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 |
---|
public static final 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 Hashtable<Integer,String> mapStatusCodes
protected static final Set<Integer> setOkStatusCodes
public static final org.jdom.Namespace NAMESPACE
protected static final Set<WebdavProperty> propRFC2518Set
public static final org.jdom.Namespace NAMESPACE_MS
protected static final Set<WebdavProperty> propMSWebFolderSet
protected static final Set<WebdavProperty> propAllSet
protected static final Set<WebdavProperty> propFileSet
protected static final Set<WebdavProperty> propSubSet
protected SimpleDateFormat httpDateUS
protected SimpleDateFormat httpDate
protected SimpleDateFormat isoDate
public static final String EMPTY_STRING
public static final int INFINITY
protected List<String> statusPath
protected List<Integer> statusCode
protected List<String> statusMsg
protected List<org.jdom.Element> statusElm
protected boolean hasError
protected byte[] inputStreamContent
protected String servletURI
public javax.servlet.http.HttpServletRequest req
public javax.servlet.http.HttpServletResponse res
public javax.servlet.ServletConfig conf
public String lang
public Locale locale
protected String originalPathHeader
Constructor Detail |
---|
public WebdavContext()
Method Detail |
---|
public static String getStatusText(int nHttpStatusCode)
nHttpStatusCode
- [IN] HTTP or WebDAV status code
protected static void addStatusCodeMap(int nKey, 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 String getRealPath(String uri)
uri
- the path of the resource
public byte[] getInputStreamContent()
public String getServletURI()
public String getInitParam(String name)
name
- the prameter name
public Iterator<String> getInitParameterNames()
public String getDestinationHeader()
public String getPathHeader()
public String getOriginalPathHeader()
public boolean getOverwriteHeader()
public int getDepthHeader()
public String getIfHeader()
public String getIfRangeHeader()
public String getRangeHeader()
public String getLockTokenHeader()
public String getLockTokenValue()
public int getTimeoutHeader()
public org.jdom.Element writeResponse(String path, List<org.jdom.Element> contentList)
path
- the resource pathcontentList
- the XML to put inside
public org.jdom.Element writeResponseProperties(String resPath, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, Collection<WebdavProperty> properties, WebdavContext ctxt)
protected List<org.jdom.Element> writeProperties(String resourcePath, String statusMsg, com.jalios.jcms.webdav.WebdavManager.PropFindType propType, 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, String message)
code
- the HTTP Status codemessage
- the message to display or null
public org.jdom.Element writeLocks(Collection<WebdavLock> locks)
locks
- a Collection of WebdavLock locks
public org.jdom.Element writeLock(WebdavLock lock)
lock
- a WebdavLock
public List<org.jdom.Element> writePropPatch(WebdavResource resource, List<WebdavProperty> wdPropList)
resource
- the Webdav ResourcewdPropList
- the List of WebdavProperty to update (remove when value is null, add/update otherwise)
public List<org.jdom.Element> writeProperties_FindPropertyNames()
public List<org.jdom.Element> writeProperties_FindAllProp(String resourcePath)
resourcePath
- the resource path to work with
writeProperties_FindPropertyNames()
public List<org.jdom.Element> writeProperties_FindByProperty(String resourcePath, Collection<WebdavProperty> props, Collection<WebdavProperty> propertiesNotFound)
resourcePath
- the resource path to work withprops
- a Collection of properties to work withpropertiesNotFound
- a Collection filled by wrong properties
writeProperties_FindPropertyNames()
public String writeHtmlFolder(WebdavResource res)
res
- the WebdavResource to work with
public void sendSingleStatus(int status, 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(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(List<org.jdom.Element> responseElms)
responseElms
- the responses tagpublic void sendStatus()
public void sendError(int code, String message)
code
- the error codemessage
- the error messagepublic void sendError()
public void sendHtml(int code, 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(String key, String value)
key
- the header keyvalue
- the header valuepublic void setHeader(String key, String value)
key
- the header keyvalue
- the header valuepublic boolean isError(int code)
code
- the StatusCode
public boolean hasErrors()
public void appendStatus(int code, String message, 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, String message, String path)
code
- the status codemessage
- the status messagepath
- the status path. Must start with a /public void appendStatus(int code, String message)
code
- the status codemessage
- the status messagepublic void appendStatus(int code)
code
- the status codepublic static String escapeWebdavChars(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 escape
public String getISO8601Date(long date)
date
- a long representing a date
public final String getHttpDate(long date)
date
- a long representing a date
public final String getHttpDate(long date, Locale locale)
date
- a long representing a datelocale
- the locale to use
public static String encodePath(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 String decodePath(String path)
path
- the URL encoded path
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |