Class WebdavNsNode
- java.lang.Object
-
- org.bedework.webdav.servlet.shared.WebdavNsNode
-
- All Implemented Interfaces:
Serializable,org.bedework.util.logging.Logged
- Direct Known Subclasses:
WebdavPrincipalNode
public abstract class WebdavNsNode extends Object implements Serializable, org.bedework.util.logging.Logged
Represents a node in 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.- Author:
- Mike Douglass douglm rpi.edu
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWebdavNsNode.PropertyTagEntrystatic classWebdavNsNode.PropValstatic classWebdavNsNode.SetPropertyResultResult from setting or removing property
-
Field Summary
Fields Modifier and Type Field Description protected booleanaliastrue if this is an aliasprotected booleanallowsGetTrue if GET is allowedprotected booleancollectionTrue if this node is a collectionprotected booleanexistsDoes the resource exist?protected booleangroupPrincipalTrue if this node is a groupprotected StringpathSuitable for displayprotected intstatusCan be set to indicate some sort of abnormal condition on this node, e.g.protected StringtargetUriprotected StringuriUri of the node.protected UrlHandlerurlHandlerprotected booleanuserPrincipalTrue if this node is a userprotected WdSysIntfwdSysIntf
-
Constructor Summary
Constructors Constructor Description WebdavNsNode(WdSysIntf sysi, UrlHandler urlHandler, String path, boolean collection, String uri)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidaddPropEntry(HashMap<QName,WebdavNsNode.PropertyTagEntry> propertyNames, QName tag)protected static voidaddPropEntry(HashMap<QName,WebdavNsNode.PropertyTagEntry> propertyNames, QName tag, boolean inAllProp)abstract booleanallowsSyncReport()booleanequals(Object o)voidgenerateHref(org.bedework.util.xml.XmlEmit xml)voidgenerateHref(org.bedework.util.xml.XmlEmit xml, String uri)booleangeneratePropertyValue(QName tag, WebdavNsIntf intf, boolean allProp)Emit the property indicated by the tag.voidgenerateUrl(org.bedework.util.xml.XmlEmit xml, QName tag, String uri, boolean exists)booleangetAlias()booleangetAllowsGet()abstract Collection<? extends WdEntity<?>>getChildren(Supplier<Object> filterGetter)Return a collection of children objects.abstract WdCollection<?>getCollection(boolean deref)The node may refer to a collection object which may in fact be an alias to another.WebdavNsIntf.ContentgetContent(String contentType)Returns the content.abstract booleangetContentBinary()abstract StringgetContentLang()abstract longgetContentLen()InputStreamgetContentStream()Returns an InputStream for the content.StringgetContentString(String contentType)Return string contentabstract StringgetContentType()A content type of null implies no content (or we don't know)abstract StringgetCreDate()abstract org.bedework.access.CurrentAccessgetCurrentAccess()Get the current access granted to this principal for this node.abstract booleangetDeleted()abstract StringgetDisplayname()StringgetEncodedUri()StringgetEncodedUri(String uri)abstract StringgetEtagValue(boolean strong)Entity tags are defined in RFC2068 - they are supposed to provide some sort of indication the data has changed - e.g.booleangetExists()abstract WdCollection<?>getImmediateTargetCollection()abstract StringgetLastmodDate()org.bedework.util.logging.BwLoggergetLogger()abstract org.bedework.access.AccessPrincipalgetOwner()Should return a value suitable for WebdavNsIntf.makeUserHrefStringgetPath()StringgetPrefixedUri()StringgetPrefixedUri(String uri)Collection<WebdavNsNode.PropertyTagEntry>getPropertyNames()Return a set of PropertyTagEntry defining properties this node supports.intgetStatus()Collection<QName>getSupportedReports()Return a set of QName defining reports this node supports.abstract StringgetSyncToken()StringgetTargetUri()StringgetUri()Get uriinthashCode()voidinit(boolean content)This method is called before each setter/getter takes any action.booleanisCollection()booleanisPrincipal()Return true if this represents a principalbooleanknownProperty(QName tag)Return true if a call to generatePropertyValue will return a value.booleanremoveProperty(Element val, WebdavNsNode.SetPropertyResult spr)Remove the given property for this node.voidsetAlias(boolean val)voidsetAllowsGet(boolean val)voidsetDefaults(QName methodTag)voidsetExists(boolean val)booleansetProperty(Element val, WebdavNsNode.SetPropertyResult spr)Set the given property for this node.voidsetStatus(int val)voidsetTargetUri(String val)voidsetUri(String val)Set uriabstract booleantrailSlash()Trailing "/" on uri?abstract voidupdate()Update this node after changes.abstract StringwriteContent(org.bedework.util.xml.XmlEmit xml, Writer wtr, String contentType)Called during xml emission to write the content for the node.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bedework.util.logging.Logged
audit, debug, debug, enableAuditLogger, enableErrorLogger, enableMetricsLogger, error, error, error, getLogLevel, info, isAuditLoggerEnabled, isErrorLoggerEnabled, isMetricsDebugEnabled, isMetricsLoggerEnabled, metrics, setLoggerClass, setLoggerClass, trace, trace, warn
-
-
-
-
Field Detail
-
exists
protected boolean exists
Does the resource exist?
-
wdSysIntf
protected WdSysIntf wdSysIntf
-
uri
protected String uri
Uri of the node. These are relative to the root of the namespace this interface represents and should start with a "/". For example, if this namespace is part of a file system starting at uabc in /var/local/uabc and we are referring to a directory x at /var/local/uabc/a/x then the uri should be /a/x/
-
path
protected String path
Suitable for display
-
collection
protected boolean collection
True if this node is a collection
-
userPrincipal
protected boolean userPrincipal
True if this node is a user
-
groupPrincipal
protected boolean groupPrincipal
True if this node is a group
-
allowsGet
protected boolean allowsGet
True if GET is allowed
-
status
protected int status
Can be set to indicate some sort of abnormal condition on this node, e.g. no access.
-
alias
protected boolean alias
true if this is an alias
-
targetUri
protected String targetUri
-
urlHandler
protected UrlHandler urlHandler
-
-
Constructor Detail
-
WebdavNsNode
public WebdavNsNode(WdSysIntf sysi, UrlHandler urlHandler, String path, boolean collection, String uri)
Constructor- Parameters:
sysi- system interfaceurlHandler- - needed for building hrefs.path- - resource pathcollection- - true if this is a collectionuri- - the uri (XXX is that the same as the path?)
-
-
Method Detail
-
getCurrentAccess
public abstract org.bedework.access.CurrentAccess getCurrentAccess() throws WebdavExceptionGet the current access granted to this principal for this node.- Returns:
- CurrentAccess
- Throws:
WebdavException
-
update
public abstract void update() throws WebdavExceptionUpdate this node after changes.- Throws:
WebdavException
-
trailSlash
public abstract boolean trailSlash()
Trailing "/" on uri?- Returns:
- boolean
-
getChildren
public abstract Collection<? extends WdEntity<?>> getChildren(Supplier<Object> filterGetter) throws WebdavException
Return a collection of children objects. For example, this is object represents a folder, they may be file objects or a mix of file and folder objects. These are not node objects.Default is to return null
- Parameters:
filterGetter- non-null if there is a filter- Returns:
- Collection of children
- Throws:
WebdavException- on fatal error
-
getPath
public String getPath()
- Returns:
- String
-
generateHref
public void generateHref(org.bedework.util.xml.XmlEmit xml) throws WebdavException- Parameters:
xml- emitter- Throws:
WebdavException
-
generateHref
public void generateHref(org.bedework.util.xml.XmlEmit xml, String uri) throws WebdavException- Parameters:
xml- emitteruri-- Throws:
WebdavException
-
getPrefixedUri
public String getPrefixedUri() throws WebdavException
- Returns:
- this nodes fully prefixed uri
- Throws:
WebdavException
-
getPrefixedUri
public String getPrefixedUri(String uri) throws WebdavException
- Parameters:
uri-- Returns:
- fully prefixed uri
- Throws:
WebdavException
-
generateUrl
public void generateUrl(org.bedework.util.xml.XmlEmit xml, QName tag, String uri, boolean exists) throws WebdavException- Parameters:
xml- emittertag-uri-exists- - true if we KNOW it exists- Throws:
WebdavException
-
removeProperty
public boolean removeProperty(Element val, WebdavNsNode.SetPropertyResult spr) throws WebdavException
Remove the given property for this node.- Parameters:
val- Element defining property to removespr- Holds reult of removing property- Returns:
- boolean true if property recognized.
- Throws:
WebdavException
-
setProperty
public boolean setProperty(Element val, WebdavNsNode.SetPropertyResult spr) throws WebdavException
Set the given property for this node.- Parameters:
val- Element defining property to setspr- Holds result of setting property- Returns:
- boolean true if property recognized and processed.
- Throws:
WebdavException
-
knownProperty
public boolean knownProperty(QName tag)
Return true if a call to generatePropertyValue will return a value.- Parameters:
tag-- Returns:
- boolean
-
generatePropertyValue
public boolean generatePropertyValue(QName tag, WebdavNsIntf intf, boolean allProp) throws WebdavException
Emit the property indicated by the tag.- Parameters:
tag- QName defining propertyintf- WebdavNsIntfallProp- true if we're doing allprop- Returns:
- boolean true if emitted
- Throws:
WebdavException
-
init
public void init(boolean content)
This method is called before each setter/getter takes any action. It allows the concrete implementation to defer some expensive operation to just before the first call.- Parameters:
content- boolean flag indicating if this is a content related property - that is a property which requires fetching and/or rendering the content
-
isPrincipal
public boolean isPrincipal()
Return true if this represents a principal- Returns:
- boolean
-
getPropertyNames
public Collection<WebdavNsNode.PropertyTagEntry> getPropertyNames() throws WebdavException
Return a set of PropertyTagEntry defining properties this node supports.- Returns:
- Collection of PropertyTagEntry
- Throws:
WebdavException
-
getSupportedReports
public Collection<QName> getSupportedReports() throws WebdavException
Return a set of QName defining reports this node supports.- Returns:
- Collection of QName
- Throws:
WebdavException
-
setExists
public void setExists(boolean val)
- Parameters:
val- boolean true if node exists
-
getExists
public boolean getExists()
- Returns:
- boolean true if node exists
-
setUri
public void setUri(String val)
Set uri- Parameters:
val-
-
getUri
public String getUri()
Get uri- Returns:
- String uri
-
getEncodedUri
public String getEncodedUri() throws WebdavException
- Returns:
- String encoded uri
- Throws:
WebdavException
-
getEncodedUri
public String getEncodedUri(String uri) throws WebdavException
- Parameters:
uri- to be encoded- Returns:
- String encoded uri
- Throws:
WebdavException
-
isCollection
public boolean isCollection()
- Returns:
- boolean true for a collection
-
setAllowsGet
public void setAllowsGet(boolean val)
- Parameters:
val- boolean true if node allows get
-
getAllowsGet
public boolean getAllowsGet()
- Returns:
- true if node allows get
-
setStatus
public void setStatus(int val)
- Parameters:
val- in status
-
getStatus
public int getStatus()
- Returns:
- int sttaus
-
setAlias
public void setAlias(boolean val) throws WebdavException- Parameters:
val-- Throws:
WebdavException
-
getAlias
public boolean getAlias() throws WebdavException- Returns:
- boolean true if an alias
- Throws:
WebdavException
-
setTargetUri
public void setTargetUri(String val) throws WebdavException
- Parameters:
val-- Throws:
WebdavException
-
getTargetUri
public String getTargetUri() throws WebdavException
- Returns:
- String uri
- Throws:
WebdavException
-
getContent
public WebdavNsIntf.Content getContent(String contentType) throws WebdavException
Returns the content.- Parameters:
contentType-- Returns:
- Content object
- Throws:
WebdavException
-
getContentStream
public InputStream getContentStream() throws WebdavException
Returns an InputStream for the content.- Returns:
- InputStream A reader for the content.
- Throws:
WebdavException
-
getContentString
public String getContentString(String contentType) throws WebdavException
Return string content- Returns:
- String content.
- Throws:
WebdavException
-
setDefaults
public void setDefaults(QName methodTag) throws WebdavException
- Parameters:
methodTag- - acts as a flag for the method type- Throws:
WebdavException
-
writeContent
public abstract String writeContent(org.bedework.util.xml.XmlEmit xml, Writer wtr, String contentType) throws WebdavException
Called during xml emission to write the content for the node.- Parameters:
xml- - if this is embedded in an xml streamwtr- - if standalone output or no xml stream initialized.contentType- desired content type or null for default.- Returns:
- actual contentType
- Throws:
WebdavException
-
getContentBinary
public abstract boolean getContentBinary() throws WebdavException- Returns:
- boolean true if this is binary content
- Throws:
WebdavException
-
getContentLang
public abstract String getContentLang() throws WebdavException
- Returns:
- String lang
- Throws:
WebdavException
-
getContentLen
public abstract long getContentLen() throws WebdavException- Returns:
- long content length
- Throws:
WebdavException
-
getContentType
public abstract String getContentType() throws WebdavException
A content type of null implies no content (or we don't know)- Returns:
- String content type
- Throws:
WebdavException
-
getCreDate
public abstract String getCreDate() throws WebdavException
- Returns:
- String credate
- Throws:
WebdavException
-
getDisplayname
public abstract String getDisplayname() throws WebdavException
- Returns:
- String name
- Throws:
WebdavException
-
getEtagValue
public abstract String getEtagValue(boolean strong) throws WebdavException
Entity tags are defined in RFC2068 - they are supposed to provide some sort of indication the data has changed - e.g. a checksum.There are weak and strong tags
This methods should return a suitable value for that tag.
- Parameters:
strong-- Returns:
- String
- Throws:
WebdavException
-
getLastmodDate
public abstract String getLastmodDate() throws WebdavException
- Returns:
- String last mod date
- Throws:
WebdavException
-
getOwner
public abstract org.bedework.access.AccessPrincipal getOwner() throws WebdavExceptionShould return a value suitable for WebdavNsIntf.makeUserHref- Returns:
- AccessPrincipal owner
- Throws:
WebdavException
-
getCollection
public abstract WdCollection<?> getCollection(boolean deref) throws WebdavException
The node may refer to a collection object which may in fact be an alias to another. For deletions we want to remove the alias itself.Move and rename are also targetted at the alias.
Other operations are probably intended to work on the underlying target of the alias.
- Parameters:
deref- true if we want to act upon the target of an alias.- Returns:
- Collection this node represents
- Throws:
WebdavException
-
getImmediateTargetCollection
public abstract WdCollection<?> getImmediateTargetCollection() throws WebdavException
- Throws:
WebdavException
-
allowsSyncReport
public abstract boolean allowsSyncReport() throws WebdavException- Returns:
- true if this node allows a sync-report.
- Throws:
WebdavException
-
getDeleted
public abstract boolean getDeleted() throws WebdavException- Returns:
- true if this represents a deleted resource.
- Throws:
WebdavException
-
getSyncToken
public abstract String getSyncToken() throws WebdavException
- Returns:
- String sync-token, a URI
- Throws:
WebdavException
-
addPropEntry
protected static void addPropEntry(HashMap<QName,WebdavNsNode.PropertyTagEntry> propertyNames, QName tag)
-
addPropEntry
protected static void addPropEntry(HashMap<QName,WebdavNsNode.PropertyTagEntry> propertyNames, QName tag, boolean inAllProp)
-
getLogger
public org.bedework.util.logging.BwLogger getLogger()
- Specified by:
getLoggerin interfaceorg.bedework.util.logging.Logged
-
-