Class MethodBase
- java.lang.Object
-
- org.bedework.webdav.servlet.common.MethodBase
-
- All Implemented Interfaces:
org.bedework.util.logging.Logged,SecureXml
- Direct Known Subclasses:
AclMethod,CopyMethod,DeleteMethod,GetMethod,LockMethod,OptionsMethod,PostMethod,PropFindMethod,PropPatchMethod,PutMethod,ReportMethod,UnlockMethod
public abstract class MethodBase extends Object implements org.bedework.util.logging.Logged, SecureXml
Base class for all webdav servlet methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMethodBase.MethodInfoAllow servelt to create method.
-
Field Summary
Fields Modifier and Type Field Description protected booleandumpContentprotected booleanhasBriefHeaderprotected WebdavNsIntfnsIntfnamespace interface for this requestprotected org.bedework.util.xml.XmlEmitxml
-
Constructor Summary
Constructors Constructor Description MethodBase()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddDavHeader(javax.servlet.http.HttpServletResponse resp, WebdavNsNode node)protected voidaddHeaders(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode node)voidaddNs(String val)Add a namespaceprotected voidaddStatus(int status, String message)voidcdataProperty(QName tag, String attrName, String attrVal, String val)Emit a propertyprotected voidcheckDepth(int depth, int val)voidcheckServerInfo(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)protected voidcloseTag(QName tag)protected intdefaultDepth(int depth, int def)abstract voiddoMethod(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)voiddoPropFind(WebdavNsNode node, Collection<WebdavProperty> props)Build the response for a single node for a propfind requestvoidemptyTag(QName tag)Emit an empty tagvoidemptyTag(Node nd)Emit an empty tag corresponding to a nodestatic List<String>fixPath(String path)Return a path, broken into its elements, after "." and ".." are removed.protected voidflush()protected StringformatHTTPDate(Timestamp val)protected Collection<Element>getChildren(Node nd)protected Element[]getChildrenArray(Node nd)protected StringgetElementContent(Element el)org.bedework.util.logging.BwLoggergetLogger()StringgetNsAbbrev(String ns)Get a namespace abbreviationWebdavNsIntfgetNsIntf()Get namespace interfaceprotected ElementgetOnlyChild(Node nd)StringgetResourceUri(javax.servlet.http.HttpServletRequest req)Get the decoded and fixed resource URIprotected StringgetStatus(int status, String message)abstract voidinit()Called at each requestvoidinit(WebdavNsIntf nsIntf, boolean dumpContent)Called at each requestprotected booleanisEmpty(Element el)protected voidopenTag(QName tag)protected voidopenTagNoNewline(QName tag)protected DocumentparseContent(int contentLength, Reader reader)Parse a reader and return the DOM representation.protected DocumentparseContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)Parse the Webdav request body, and return the DOM representation.voidproperty(QName tag, Reader val)Emit a propertyvoidproperty(QName tag, String val)Emit a propertyvoidpropertyTagVal(QName tag, QName tagVal)Emit a propertyprotected voidstartEmit(javax.servlet.http.HttpServletResponse resp)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
Methods inherited from interface org.bedework.webdav.servlet.common.SecureXml
parseXmlSafely
-
-
-
-
Field Detail
-
dumpContent
protected boolean dumpContent
-
hasBriefHeader
protected boolean hasBriefHeader
-
nsIntf
protected WebdavNsIntf nsIntf
namespace interface for this request
-
xml
protected org.bedework.util.xml.XmlEmit xml
-
-
Method Detail
-
init
public abstract void init()
Called at each request
-
doMethod
public abstract void doMethod(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws WebdavException- Parameters:
req-resp-- Throws:
WebdavException
-
init
public void init(WebdavNsIntf nsIntf, boolean dumpContent) throws WebdavException
Called at each request- Parameters:
nsIntf-dumpContent-- Throws:
WebdavException
-
getNsIntf
public WebdavNsIntf getNsIntf()
Get namespace interface- Returns:
- WebdavNsIntf
-
getResourceUri
public String getResourceUri(javax.servlet.http.HttpServletRequest req) throws WebdavException
Get the decoded and fixed resource URI- Parameters:
req- Servlet request object- Returns:
- String fixed up uri
- Throws:
WebdavException
-
fixPath
public static List<String> fixPath(String path) throws WebdavException
Return a path, broken into its elements, after "." and ".." are removed. If the parameter path attempts to go above the root we return null. Other than the backslash thing why not use URI?- Parameters:
path- String path to be fixed- Returns:
- String[] fixed path broken into elements
- Throws:
WebdavException
-
defaultDepth
protected int defaultDepth(int depth, int def)
-
checkDepth
protected void checkDepth(int depth, int val) throws WebdavException- Throws:
WebdavException
-
addStatus
protected void addStatus(int status, String message) throws WebdavException- Throws:
WebdavException
-
addHeaders
protected void addHeaders(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode node) throws WebdavException- Throws:
WebdavException
-
checkServerInfo
public void checkServerInfo(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws WebdavException- Throws:
WebdavException
-
addDavHeader
protected void addDavHeader(javax.servlet.http.HttpServletResponse resp, WebdavNsNode node) throws WebdavException- Throws:
WebdavException
-
parseContent
protected Document parseContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws WebdavException
Parse the Webdav request body, and return the DOM representation.- Parameters:
req- Servlet request objectresp- Servlet response object for bad status- Returns:
- Document Parsed body or null for no body
- Throws:
WebdavException- Some error occurred.
-
parseContent
protected Document parseContent(int contentLength, Reader reader) throws WebdavException
Parse a reader and return the DOM representation.- Parameters:
contentLength- Content lengthreader- Reader- Returns:
- Document Parsed body or null for no body
- Throws:
WebdavException- Some error occurred.
-
doPropFind
public void doPropFind(WebdavNsNode node, Collection<WebdavProperty> props) throws WebdavException
Build the response for a single node for a propfind request- Parameters:
node-props-- Throws:
WebdavException- on fatal error
-
getChildren
protected Collection<Element> getChildren(Node nd) throws WebdavException
- Throws:
WebdavException
-
getChildrenArray
protected Element[] getChildrenArray(Node nd) throws WebdavException
- Throws:
WebdavException
-
getOnlyChild
protected Element getOnlyChild(Node nd) throws WebdavException
- Throws:
WebdavException
-
getElementContent
protected String getElementContent(Element el) throws WebdavException
- Throws:
WebdavException
-
isEmpty
protected boolean isEmpty(Element el) throws WebdavException
- Throws:
WebdavException
-
startEmit
protected void startEmit(javax.servlet.http.HttpServletResponse resp) throws WebdavException- Throws:
WebdavException
-
addNs
public void addNs(String val) throws WebdavException
Add a namespace- Parameters:
val-- Throws:
WebdavException
-
getNsAbbrev
public String getNsAbbrev(String ns)
Get a namespace abbreviation- Parameters:
ns- namespace- Returns:
- String abbrev
-
openTag
protected void openTag(QName tag) throws WebdavException
- Throws:
WebdavException
-
openTagNoNewline
protected void openTagNoNewline(QName tag) throws WebdavException
- Throws:
WebdavException
-
closeTag
protected void closeTag(QName tag) throws WebdavException
- Throws:
WebdavException
-
emptyTag
public void emptyTag(QName tag) throws WebdavException
Emit an empty tag- Parameters:
tag-- Throws:
WebdavException
-
emptyTag
public void emptyTag(Node nd) throws WebdavException
Emit an empty tag corresponding to a node- Parameters:
nd-- Throws:
WebdavException
-
property
public void property(QName tag, String val) throws WebdavException
Emit a property- Parameters:
tag-val-- Throws:
WebdavException
-
cdataProperty
public void cdataProperty(QName tag, String attrName, String attrVal, String val) throws WebdavException
Emit a property- Parameters:
tag-val-- Throws:
WebdavException
-
property
public void property(QName tag, Reader val) throws WebdavException
Emit a property- Parameters:
tag-val-- Throws:
WebdavException
-
propertyTagVal
public void propertyTagVal(QName tag, QName tagVal) throws WebdavException
Emit a property- Parameters:
tag-tagVal-- Throws:
WebdavException
-
flush
protected void flush() throws WebdavException- Throws:
WebdavException
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()
- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-
-