Class WebdavNsIntf
java.lang.Object
org.bedework.webdav.servlet.shared.WebdavNsIntf
- All Implemented Interfaces:
Serializable,org.bedework.util.logging.Logged
public abstract class WebdavNsIntf
extends Object
implements org.bedework.util.logging.Logged, Serializable
This acts as an interface to the underlying namespace for which this
servlet is acting as a gateway. This could be a file system, a set of
dynamically created objects or some sort of CMS for example.
A namespace consists of a number of nodes which may be containers for other nodes or leaf nodes.
All nodes are considered identical in their capabilities, that is, a non-terminal node might contain content.
Some nodes are aliases of other nodes (e.g. symlinks in a unix file system). By default these aliases will be followed.
A namespace consists of a number of nodes which may be containers for other nodes or leaf nodes.
All nodes are considered identical in their capabilities, that is, a non-terminal node might contain content.
Some nodes are aliases of other nodes (e.g. symlinks in a unix file system). By default these aliases will be followed.
- Author:
- Mike Douglass
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classObject class passed around as we parse access.static classstatic classResult for putContentprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected booleanstatic final intWe know it exists.static final intMay existstatic final intMust exist.static final intMust not existprotected HashMap<String,MethodBase.MethodInfo> Table of methods - set by servletstatic final intMust be collectionstatic final intMust be entity.static final intMust be a principal.static final intUnknown.protected WebdavServletprotected static final WebdavNsIntf.SessCtMostly to distinguish trace entriesprotected intprotected org.bedework.util.xml.XmlEmit -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidacceptMkcolContent(javax.servlet.http.HttpServletRequest req) Throw an exception if we don't want the content for mkcol.voidaddNamespace(org.bedework.util.xml.XmlEmit xml) Add any namespaces for xml tag names in requests and responses.voidaddStatus(int status) abstract booleancanPut(WebdavNsNode node) Return true if we can PUT this resource/entityabstract voidclose()Called on the way out to allow resources to be freed.voidClose a propstat response with an ok result.voidclosePropstat(int status) Close a propstat response with given result.abstract voidcopyMove(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode from, WebdavNsNode to, boolean copy, boolean overwrite, int depth) Copy or move a resource at the given location to another location.abstract voidcreate(WebdavNsNode node) Create a new node.abstract voidcreateAlias(WebdavNsNode alias) Creates an alias to another node.abstract voiddelete(WebdavNsNode node) Deletes a node from the namespace.abstract voidemitAcl(WebdavNsNode node) voidEmit some failed precondition tagvoidstatic StringReturn a path, beginning with a "/", after "." and ".." are removed.protected StringgenerateHtml(javax.servlet.http.HttpServletRequest req, WebdavNsNode node) Return a String giving an HTML representation of the directory.booleangeneratePropValue(WebdavNsNode node, WebdavProperty pr, boolean allProp) Generate a response for a single webdav property.abstract StringgetAcceptContentType(javax.servlet.http.HttpServletRequest req) abstract booleanReturns true if the namespace supports access controlabstract AccessUtilGet an object suitable for use in parsing acls and generating access.abstract Collection<String>Return all the hrefs found in the access for th egiven node.abstract Stringbooleanabstract WebdavNsIntf.ContentgetBinaryContent(WebdavNsNode node) Returns a Content object for the binary content.abstract Collection<WebdavNsNode>getChildren(WebdavNsNode node, Supplier<Object> filterGetter) Returns the immediate children of a node.Element[]getChildren(Node nd) Get all the children if anyabstract WebdavNsIntf.ContentgetContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String contentType, WebdavNsNode node) Returns a Content object for the content.getDavHeader(WebdavNsNode node) Return DAV headerabstract booleanReturn true if the system disallows directory browsing.abstract Collection<WebdavNsNode>Given a PrincipalMatchReport returns a Collection of matching nodes.getLocation(WebdavNsNode node) Return the complete URL describing the location of the object represented by the nodeorg.bedework.util.logging.BwLoggerReturn the named initialised method or null if no such method or the method requires authentication and we are anonymousabstract WebdavNsNodeRetrieves a node by uri, following any links.getOnlyChild(Node nd) We expect a single childabstract WebdavNsNodegetParent(WebdavNsNode node) Returns the parent of a node.abstract Collection<String>getPrincipalCollectionSet(String resourceUri) Given a uri returns a Collection of uris that allow search operations on principals for that resource.abstract Collection<? extends WebdavNsNode>getPrincipals(String resourceUri, PrincipalPropertySearch pps) Given a PrincipalPropertySearch returns a Collection of matching nodes.getReader(javax.servlet.http.HttpServletRequest req) javax.servlet.http.HttpServletRequestgetResourceUri(javax.servlet.http.HttpServletRequest req) Get the decoded and fixed resource URI.booleanabstract StringReturns the supported locks for the supportedlock property.abstract WdSynchReportgetSynchReport(String path, String token, int limit, boolean recurse) abstract StringgetSyncToken(String path) Used to match tokens in If headerabstract WdSysIntfReturn the part of the href referring to the actual entity, e.g.org.bedework.util.xml.XmlEmitvoidinit(WebdavServlet servlet, javax.servlet.http.HttpServletRequest req, HashMap<String, MethodBase.MethodInfo> methods, boolean dumpContent) Called before any other method is called to allow initialisation to take place at the first or subsequent requestsbooleanknownProperty(WebdavNsNode node, WebdavProperty pr) Return true if a call to generatePropValue will return a value.abstract voidmakeCollection(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode node) Create an empty collection at the given location.Turn val into something which can be used as a name for an entity.Override this to create namespace specific property objects.makeServerInfoUrl(javax.servlet.http.HttpServletRequest req) TODO - make the url value configurableabstract StringmakeUserHref(String id) normalizeUri(String uri) voidOpen a propstat response.Parse a DAV:prop list of property names in any namespace.booleanprefetch(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode node) Called before fetching in GET processing.abstract WebdavNsIntf.PutContentResultputBinaryContent(javax.servlet.http.HttpServletRequest req, WebdavNsNode node, String[] contentTypePars, InputStream contentStream, Headers.IfHeaders ifHeaders) Set the content from a StreamputContent(javax.servlet.http.HttpServletRequest req, String resourceUri, javax.servlet.http.HttpServletResponse resp, boolean fromPost, Headers.IfHeaders ifHeaders) Put content for the PUT or POST methodsabstract WebdavNsIntf.PutContentResultputContent(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, WebdavNsNode node, String[] contentTypePars, Reader contentRdr, Headers.IfHeaders ifHeaders) Set the content from a Readerabstract voidputNode(WebdavNsNode node) Stores/updates an object.abstract voidrollback()Called on the way out before close if there was an error.abstract booleanspecialUri(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String resourceUri) Handle a special resource uri for GET.voidstreamContent(InputStream in, OutputStream out) booleanabstract voidupdateAccess(WebdavNsIntf.AclInfo ainfo) voidwriteContent(Reader in, Writer out) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, trace, warn
-
Field Details
-
session
Mostly to distinguish trace entries -
sessNum
protected int sessNum -
servlet
-
account
-
anonymous
protected boolean anonymous -
dumpContent
protected boolean dumpContent -
xml
protected org.bedework.util.xml.XmlEmit xml -
methods
Table of methods - set by servlet -
existanceNot
public static final int existanceNotMust not exist- See Also:
-
existanceMust
public static final int existanceMustMust exist.- See Also:
-
existanceDoesExist
public static final int existanceDoesExistWe know it exists.- See Also:
-
existanceMay
public static final int existanceMayMay exist- See Also:
-
nodeTypeCollection
public static final int nodeTypeCollectionMust be collection- See Also:
-
nodeTypeEntity
public static final int nodeTypeEntityMust be entity.- See Also:
-
nodeTypePrincipal
public static final int nodeTypePrincipalMust be a principal.- See Also:
-
nodeTypeUnknown
public static final int nodeTypeUnknownUnknown.- See Also:
-
-
Constructor Details
-
WebdavNsIntf
public WebdavNsIntf()
-
-
Method Details
-
init
public void init(WebdavServlet servlet, javax.servlet.http.HttpServletRequest req, HashMap<String, MethodBase.MethodInfo> methods, boolean dumpContent) Called before any other method is called to allow initialisation to take place at the first or subsequent requests- Parameters:
servlet- the WebDAV servletreq- http requestmethods- HashMap table of method infodumpContent- true to provide a debug trace of content
-
getAccount
- Returns:
- String
-
getXmlEmit
public org.bedework.util.xml.XmlEmit getXmlEmit()- Returns:
- XmlEmit xmlemitter
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()- Returns:
- HttpServletRequest
-
getServerInfo
- Returns:
- server info populated for basic webdav
-
syncTokenMatch
- Parameters:
ih- IfHeader- Returns:
- false for a mismatch
- Throws:
WebdavException- for invalid if header
-
emitError
Emit some failed precondition tag- Parameters:
errorTag- to identify errorextra- optional extra infoxml- emitter
-
getSysIntf
- Returns:
- system interface
-
getAccessUtil
Get an object suitable for use in parsing acls and generating access.- Returns:
- AccessUtil implementation.
-
getAddMemberSuffix
- Returns:
- - null if DAV:add-member not supported
-
getMethodNames
- Returns:
- Collection of method names.
-
getMethod
Return the named initialised method or null if no such method or the method requires authentication and we are anonymous- Parameters:
name- name- Returns:
- MethodBase object or null
-
getAnonymous
public boolean getAnonymous()- Returns:
- boolean true for anon access
-
getUri
Return the part of the href referring to the actual entity, e.g.
forhttp://localhost/ucaldav/user/caluser/calendar/2656-uwcal-demouwcalendar@mysite.edu.ics
user/caluser/calendar/2656-uwcal-demouwcalendar@mysite.edu.ics- Parameters:
href-- Returns:
- String
-
makeName
Turn val into something which can be used as a name for an entity. This involves removing path delimiters such as "/".- Parameters:
val- to be converted- Returns:
- modified name
-
getServlet
- Returns:
- WebdavServlet
-
getReturnMultistatusOk
public boolean getReturnMultistatusOk()- Returns:
- boolean
-
addNamespace
public void addNamespace(org.bedework.util.xml.XmlEmit xml) Add any namespaces for xml tag names in requests and responses. An abbreviation will be supplied by the servlet. The name should be globally unique in a global sense so don't return something like "RPI:"Something more like "http://ahost.rpi.edu/webdav/"
- Parameters:
xml-
-
getDirectoryBrowsingDisallowed
public abstract boolean getDirectoryBrowsingDisallowed()Return true if the system disallows directory browsing.- Returns:
- boolean
-
rollback
public abstract void rollback()Called on the way out before close if there was an error. -
close
public abstract void close()Called on the way out to allow resources to be freed. -
getSupportedLocks
Returns the supported locks for the supportedlock property.To ensure these will work always provide the full namespace "DAV:" for example, the result for supported exclusive and shared write locks would be the string "<DAV:lockentry>" + " <DAV:lockscope><DAV:exclusive/><DAV:/lockscope>" + " <DAV:locktype><DAV:write/><DAV:/locktype>" + "<DAV:/lockentry>" + "<DAV:lockentry>" + " <DAV:lockscope><DAV:shared/><DAV:/lockscope>" + "<DAV:/lockentry>"
- Returns:
- String response
-
getAccessControl
public abstract boolean getAccessControl()Returns true if the namespace supports access control- Returns:
- boolean
-
getNode
Retrieves a node by uri, following any links.- Parameters:
uri- String decoded uri of the node to retrieveexistence- Say's something about the state of existencenodeType- Say's something about the type of nodeaddMember- Called from POST with addMember- Returns:
- WebdavNsNode node specified by the URI or the node aliased by the node at the URI.
-
getAcceptContentType
- Returns:
- a valid content type string
-
putContent
public WebdavNsIntf.PutContentResult putContent(javax.servlet.http.HttpServletRequest req, String resourceUri, javax.servlet.http.HttpServletResponse resp, boolean fromPost, Headers.IfHeaders ifHeaders) Put content for the PUT or POST methods- Parameters:
req- the requestresourceUri- if not null use this otherwise obtain from requestresp- the responsefromPost- POST style - createifHeaders- info from headers- Returns:
- PutContentResult result of creating
-
writeContent
- Parameters:
in-out-
-
streamContent
- Parameters:
in-out-
-
normalizeUri
- Parameters:
uri- to check- Returns:
- normalized form
-
acceptMkcolContent
public abstract void acceptMkcolContent(javax.servlet.http.HttpServletRequest req) Throw an exception if we don't want the content for mkcol.- Parameters:
req- HttpServletRequest
-
specialUri
public abstract boolean specialUri(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String resourceUri) Handle a special resource uri for GET. Status is set on return- Parameters:
req- HttpServletRequestresp- HttpServletResponseresourceUri-- Returns:
- boolean true if it was a special uri and is processed
-
getSynchReport
- Parameters:
path- to collectiontoken- sync-token or nulllimit- - negative for no limit on result set sizerecurse- - true for infinite depth- Returns:
- report
-
getSyncToken
Used to match tokens in If header- Parameters:
path- for collection- Returns:
- sync token or null
-
getGroups
Given a PrincipalMatchReport returns a Collection of matching nodes.- Parameters:
resourceUri- - url to base search on.principalUrl- - url of principal or null for current user- Returns:
- Collection of WebdavNsNode
-
getPrincipalCollectionSet
Given a uri returns a Collection of uris that allow search operations on principals for that resource.- Parameters:
resourceUri-- Returns:
- Collection of String
-
makeUserHref
- Parameters:
id-- Returns:
- String href
-
makeServerInfoUrl
TODO - make the url value configurable- Parameters:
req- http request- Returns:
-
openPropstat
public void openPropstat()Open a propstat response. -
closePropstat
public void closePropstat(int status) Close a propstat response with given result.- Parameters:
status- int value
-
closePropstat
public void closePropstat()Close a propstat response with an ok result. -
parseProp
Parse a DAV:prop list of property names in any namespace.- Parameters:
nd- the props node- Returns:
- Collection
-
makeProp
Override this to create namespace specific property objects.- Parameters:
propnode- node specifying proeprty- Returns:
- WebdavProperty
-
addStatus
public void addStatus(int status) - Parameters:
status- int value
-
getResourceUri
Get the decoded and fixed resource URI. This calls getServletPath() to obtain the path information. The description of that method is a little obscure in it's meaning. In a request of this form:
"GET /ucaldav/user/douglm/calendar/1302064354993-g.ics HTTP/1.1[\r][\n]"
getServletPath() will return
/user/douglm/calendar/1302064354993-g.ics
that is the context has been removed. In addition this method will URL decode the path. getRequestUrl() does neither.- Parameters:
req- Servlet request object- Returns:
- String fixed up uri
-
fixPath
Return a path, beginning with a "/", 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
-
getReader
- Parameters:
req- http request- Returns:
- possibly wrapped reader
-
getChildren
Get all the children if any- Parameters:
nd- current node- Returns:
- array of Element
-
getOnlyChild
We expect a single child- Parameters:
nd- current node- Returns:
- Element
-
getElementContent
- Parameters:
el- the element- Returns:
- String
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-