Class DavResourceImpl
- java.lang.Object
-
- org.apache.jackrabbit.webdav.simple.DavResourceImpl
-
- All Implemented Interfaces:
JcrConstants
,BindableResource
,DavResource
- Direct Known Subclasses:
DeltaVResourceImpl
public class DavResourceImpl extends Object implements DavResource, BindableResource, JcrConstants
DavResourceImpl implements a DavResource.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPLIANCE_CLASSES
static String
METHODS
protected DavPropertySet
properties
protected boolean
propsInitialized
-
Fields inherited from interface org.apache.jackrabbit.JcrConstants
JCR_AUTOCREATED, JCR_BASEVERSION, JCR_CHILD, JCR_CHILDNODEDEFINITION, JCR_CONTENT, JCR_CREATED, JCR_DATA, JCR_DEFAULTPRIMARYTYPE, JCR_DEFAULTVALUES, JCR_ENCODING, JCR_FROZENMIXINTYPES, JCR_FROZENNODE, JCR_FROZENPRIMARYTYPE, JCR_FROZENUUID, JCR_HASORDERABLECHILDNODES, JCR_ISCHECKEDOUT, JCR_ISMIXIN, JCR_LANGUAGE, JCR_LASTMODIFIED, JCR_LOCKISDEEP, JCR_LOCKOWNER, JCR_MANDATORY, JCR_MERGEFAILED, JCR_MIMETYPE, JCR_MIXINTYPES, JCR_MULTIPLE, JCR_NAME, JCR_NODETYPENAME, JCR_ONPARENTVERSION, JCR_PATH, JCR_PREDECESSORS, JCR_PRIMARYITEMNAME, JCR_PRIMARYTYPE, JCR_PROPERTYDEFINITION, JCR_PROTECTED, JCR_REQUIREDPRIMARYTYPES, JCR_REQUIREDTYPE, JCR_ROOTVERSION, JCR_SAMENAMESIBLINGS, JCR_SCORE, JCR_STATEMENT, JCR_SUCCESSORS, JCR_SUPERTYPES, JCR_SYSTEM, JCR_UUID, JCR_VALUECONSTRAINTS, JCR_VERSIONABLEUUID, JCR_VERSIONHISTORY, JCR_VERSIONLABELS, JCR_VERSIONSTORAGE, MIX_LOCKABLE, MIX_REFERENCEABLE, MIX_SHAREABLE, MIX_VERSIONABLE, NT_BASE, NT_CHILDNODEDEFINITION, NT_FILE, NT_FOLDER, NT_FROZENNODE, NT_HIERARCHYNODE, NT_LINKEDFILE, NT_NODETYPE, NT_PROPERTYDEFINITION, NT_QUERY, NT_RESOURCE, NT_UNSTRUCTURED, NT_VERSION, NT_VERSIONEDCHILD, NT_VERSIONHISTORY, NT_VERSIONLABELS
-
-
Constructor Summary
Constructors Constructor Description DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, boolean isCollection)
Create a newDavResource
.DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, Node node)
Create a newDavResource
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLockManager(LockManager lockMgr)
Add an externalLockManager
to this resource.void
addMember(DavResource member, InputContext inputContext)
Adds a new member to this resource.MultiStatusResponse
alterProperties(List<? extends PropEntry> changeList)
Set/add and remove the specified properties from this resource.void
bind(DavResource collection, DavResource newBinding)
Will add a new binding to the given collection referencing this resource.void
copy(DavResource destination, boolean shallow)
Copy this DavResource to the given destination resourceboolean
exists()
Returns true if this webdav resource represents an existing repository item.DavResource
getCollection()
Retrieve the resource this resource is internal member of.String
getComplianceClass()
Returns a comma separated list of all compliance classes the given resource is fulfilling.String
getDisplayName()
Returns the the last segment of the resource path.protected ExportContext
getExportContext(OutputContext outputCtx)
Returns a newExportContext
DavResourceFactory
getFactory()
Return theDavResourceFactory
that created this resource.String
getHref()
Returns the absolute href of this resource as returned in the multistatus response body.protected ImportContext
getImportContext(InputContext inputCtx, String systemId)
Returns a newImportContext
DavResourceLocator
getLocator()
Returns thelocator
object for this webdav resource, which encapsulates the information for building the complete 'href'.ActiveLock
getLock(Type type, Scope scope)
Return the lock present on this webdav resource ornull
if the resource is either not locked or not lockable at all.ActiveLock[]
getLocks()
Returns an array of all locks applied to the given resource.DavResourceIterator
getMembers()
Returns an iterator over all internal members.long
getModificationTime()
Return the time of the last modification or -1 if the modification time could not be retrieved.protected Node
getNode()
Returns the node that is wrapped by this resource.Set<ParentElement>
getParentElements()
Will retrieve a collection of parent elements of the bindable resource representing the parent set.DavPropertySet
getProperties()
Returns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROP
request.DavProperty<?>
getProperty(DavPropertyName name)
Return the webdav property with the specified name.protected PropertyExportContext
getPropertyExportContext()
Returns a newPropertyExportContext
.protected PropertyImportContext
getPropertyImportContext(List<? extends PropEntry> changeList)
Returns a newPropertyImportContext
.DavPropertyName[]
getPropertyNames()
Returns an array of allproperty names
available on this resource.String
getResourcePath()
Returns the path of the hierarchy element defined by thisDavResource
.DavSession
getSession()
Retrieve theDavSession
associated with this resource.String
getSupportedMethods()
Returns a comma separated list of all METHODS supported by the given resource.boolean
hasLock(Type type, Scope scope)
Returns true if a lock applies to this resource.protected void
initProperties()
Fill the set of propertiesboolean
isCollection()
Returns true if this webdav resource has the resourcetype 'collection'.boolean
isLockable(Type type, Scope scope)
Returns true, if the this resource allows locking.ActiveLock
lock(LockInfo lockInfo)
Lock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.void
move(DavResource destination)
Move this DavResource to the given destination resourcevoid
rebind(DavResource collection, DavResource newBinding)
Will rebind the resource to the given collection.ActiveLock
refreshLock(LockInfo lockInfo, String lockToken)
Refresh an existing lock by resetting the timeout.void
removeMember(DavResource member)
Removes the specified member from this resource.void
removeProperty(DavPropertyName propertyName)
Remove the specified property from this resource.void
setProperty(DavProperty<?> property)
Add/Set the specified property on this resource.void
spool(OutputContext outputContext)
If this resource exists and the specified context is notnull
this implementation build a newExportContext
based on the specified context and forwards the export to itsIOManager
.void
unlock(String lockToken)
Remove the lock identified by the included lock token from this resource.
-
-
-
Field Detail
-
METHODS
public static final String METHODS
- See Also:
- Constant Field Values
-
COMPLIANCE_CLASSES
public static final String COMPLIANCE_CLASSES
-
properties
protected DavPropertySet properties
-
propsInitialized
protected boolean propsInitialized
-
-
Constructor Detail
-
DavResourceImpl
public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, boolean isCollection) throws DavException
Create a newDavResource
.- Parameters:
locator
-factory
-session
-config
-isCollection
-- Throws:
DavException
-
DavResourceImpl
public DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, Node node) throws DavException
Create a newDavResource
.- Parameters:
locator
-factory
-session
-config
-node
-- Throws:
DavException
-
-
Method Detail
-
getComplianceClass
public String getComplianceClass()
Description copied from interface:DavResource
Returns a comma separated list of all compliance classes the given resource is fulfilling.- Specified by:
getComplianceClass
in interfaceDavResource
- Returns:
- compliance classes
- See Also:
DavResource.getComplianceClass()
-
getSupportedMethods
public String getSupportedMethods()
Description copied from interface:DavResource
Returns a comma separated list of all METHODS supported by the given resource.- Specified by:
getSupportedMethods
in interfaceDavResource
- Returns:
- DavResource#METHODS
- See Also:
DavResource.getSupportedMethods()
-
exists
public boolean exists()
Description copied from interface:DavResource
Returns true if this webdav resource represents an existing repository item.- Specified by:
exists
in interfaceDavResource
- Returns:
- true, if the resource represents an existing repository item.
- See Also:
)
-
isCollection
public boolean isCollection()
Description copied from interface:DavResource
Returns true if this webdav resource has the resourcetype 'collection'.- Specified by:
isCollection
in interfaceDavResource
- Returns:
- true if the resource represents a collection resource.
- See Also:
DavResource.isCollection()
-
getLocator
public DavResourceLocator getLocator()
Description copied from interface:DavResource
Returns thelocator
object for this webdav resource, which encapsulates the information for building the complete 'href'.- Specified by:
getLocator
in interfaceDavResource
- Returns:
- the locator for this resource.
- See Also:
DavResource.getLocator()
-
getResourcePath
public String getResourcePath()
Description copied from interface:DavResource
Returns the path of the hierarchy element defined by thisDavResource
. This method is a shortcut forDavResource.getLocator().getResourcePath()
.- Specified by:
getResourcePath
in interfaceDavResource
- Returns:
- path of the element defined by this
DavResource
. - See Also:
DavResource.getResourcePath()
-
getHref
public String getHref()
Description copied from interface:DavResource
Returns the absolute href of this resource as returned in the multistatus response body.- Specified by:
getHref
in interfaceDavResource
- Returns:
- href
- See Also:
DavResource.getHref()
-
getDisplayName
public String getDisplayName()
Returns the the last segment of the resource path.Note that this must not correspond to the name of the underlying repository item for two reasons:
- SameNameSiblings have an index appended to their item name.
- the resource path may differ from the item path.
- Specified by:
getDisplayName
in interfaceDavResource
- Returns:
- display name.
- See Also:
DavResource.getDisplayName()
-
getModificationTime
public long getModificationTime()
Description copied from interface:DavResource
Return the time of the last modification or -1 if the modification time could not be retrieved.- Specified by:
getModificationTime
in interfaceDavResource
- Returns:
- time of last modification or -1.
- See Also:
DavResource.getModificationTime()
-
spool
public void spool(OutputContext outputContext) throws IOException
If this resource exists and the specified context is notnull
this implementation build a newExportContext
based on the specified context and forwards the export to itsIOManager
. If theIOManager.exportContent(ExportContext, DavResource)
fails, anIOException
is thrown.- Specified by:
spool
in interfaceDavResource
- Parameters:
outputContext
- The output context.- Throws:
IOException
- if the export fails.- See Also:
DavResource.spool(OutputContext)
,ResourceConfig.getIOManager()
-
getProperty
public DavProperty<?> getProperty(DavPropertyName name)
Description copied from interface:DavResource
Return the webdav property with the specified name.- Specified by:
getProperty
in interfaceDavResource
- Parameters:
name
- name of the webdav property- Returns:
- the
DavProperty
with the given name ornull
if the property does not exist. - See Also:
DavResource.getProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
-
getProperties
public DavPropertySet getProperties()
Description copied from interface:DavResource
Returns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROP
request. The implementation may in addition expose other (protected or calculated) properties which should be marked accordingly (see alsoDavProperty.isInvisibleInAllprop()
.- Specified by:
getProperties
in interfaceDavResource
- Returns:
- a
DavPropertySet
containing at least all properties of this resource that are exposed in 'allprop' PROPFIND request. - See Also:
DavResource.getProperties()
-
getPropertyNames
public DavPropertyName[] getPropertyNames()
Description copied from interface:DavResource
Returns an array of allproperty names
available on this resource.- Specified by:
getPropertyNames
in interfaceDavResource
- Returns:
- an array of property names.
- See Also:
DavResource.getPropertyNames()
-
initProperties
protected void initProperties()
Fill the set of properties
-
setProperty
public void setProperty(DavProperty<?> property) throws DavException
Description copied from interface:DavResource
Add/Set the specified property on this resource.- Specified by:
setProperty
in interfaceDavResource
- Parameters:
property
-- Throws:
DavException
- See Also:
DavResource.setProperty(org.apache.jackrabbit.webdav.property.DavProperty)
-
removeProperty
public void removeProperty(DavPropertyName propertyName) throws DavException
Description copied from interface:DavResource
Remove the specified property from this resource.- Specified by:
removeProperty
in interfaceDavResource
- Parameters:
propertyName
-- Throws:
DavException
- See Also:
DavResource.removeProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
-
alterProperties
public MultiStatusResponse alterProperties(List<? extends PropEntry> changeList) throws DavException
Description copied from interface:DavResource
Set/add and remove the specified properties from this resource.- Specified by:
alterProperties
in interfaceDavResource
- Parameters:
changeList
- list containingDavPropertyName
objects (for properties to be removed) andDavProperty
objects (for properties to be added/set).- Returns:
- multistatus response listing the status resulting from setting and/or removing the specified properties, in order to allow a detailed multistatus response.
- Throws:
DavException
- if an error occurred. This may be the case if the general state of the resource prevents any properties to be set or removed (e.g. due to a lock).
-
getCollection
public DavResource getCollection()
Description copied from interface:DavResource
Retrieve the resource this resource is internal member of.- Specified by:
getCollection
in interfaceDavResource
- Returns:
- resource this resource is an internal member of. In case this resource
is the root
null
is returned. - See Also:
DavResource.getCollection()
-
getMembers
public DavResourceIterator getMembers()
Description copied from interface:DavResource
Returns an iterator over all internal members.- Specified by:
getMembers
in interfaceDavResource
- Returns:
- a
DavResourceIterator
over all internal members. - See Also:
DavResource.getMembers()
-
addMember
public void addMember(DavResource member, InputContext inputContext) throws DavException
Adds a new member to this resource.- Specified by:
addMember
in interfaceDavResource
- Parameters:
member
-DavResource
to be added as internal member.inputContext
- Context providing the properties and content for the internal member to be created or replaced.- Throws:
DavException
- See Also:
DavResource.addMember(DavResource, org.apache.jackrabbit.webdav.io.InputContext)
-
removeMember
public void removeMember(DavResource member) throws DavException
Description copied from interface:DavResource
Removes the specified member from this resource.- Specified by:
removeMember
in interfaceDavResource
- Throws:
DavException
- See Also:
DavResource.removeMember(DavResource)
-
move
public void move(DavResource destination) throws DavException
Description copied from interface:DavResource
Move this DavResource to the given destination resource- Specified by:
move
in interfaceDavResource
- Throws:
DavException
- See Also:
DavResource.move(DavResource)
-
copy
public void copy(DavResource destination, boolean shallow) throws DavException
Description copied from interface:DavResource
Copy this DavResource to the given destination resource- Specified by:
copy
in interfaceDavResource
- Throws:
DavException
- See Also:
DavResource.copy(DavResource, boolean)
-
isLockable
public boolean isLockable(Type type, Scope scope)
Description copied from interface:DavResource
Returns true, if the this resource allows locking. NOTE, that this method does not define, whether a lock/unlock can be successfully executed.- Specified by:
isLockable
in interfaceDavResource
- Parameters:
type
-scope
-- Returns:
- true if type is
Type.WRITE
and scope isScope.EXCLUSIVE
- See Also:
DavResource.isLockable(org.apache.jackrabbit.webdav.lock.Type, org.apache.jackrabbit.webdav.lock.Scope)
-
hasLock
public boolean hasLock(Type type, Scope scope)
Description copied from interface:DavResource
Returns true if a lock applies to this resource. This may be either a lock on this resource itself or a deep lock inherited from a collection above this resource.
Note, that true is returned whenever a lock applies to that resource even if the lock is expired or not effective due to the fact that the request provides the proper lock token.- Specified by:
hasLock
in interfaceDavResource
- Returns:
- true if a lock applies to this resource.
- See Also:
DavResource.hasLock(org.apache.jackrabbit.webdav.lock.Type, org.apache.jackrabbit.webdav.lock.Scope)
-
getLock
public ActiveLock getLock(Type type, Scope scope)
Description copied from interface:DavResource
Return the lock present on this webdav resource ornull
if the resource is either not locked or not lockable at all. Note, that a resource may have a lock that is inherited by a deep lock enforced on one of its 'parent' resources.- Specified by:
getLock
in interfaceDavResource
- Returns:
- lock information of this resource or
null
if this resource has no lock applying it. If an error occurs while retrieving the lock informationnull
is returned as well. - See Also:
DavResource.getLock(Type, Scope)
-
getLocks
public ActiveLock[] getLocks()
Description copied from interface:DavResource
Returns an array of all locks applied to the given resource.- Specified by:
getLocks
in interfaceDavResource
- Returns:
- array of locks. The array is empty if there are no locks applied to this resource.
- See Also:
DavResource.getLocks()
-
lock
public ActiveLock lock(LockInfo lockInfo) throws DavException
Description copied from interface:DavResource
Lock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.- Specified by:
lock
in interfaceDavResource
- Parameters:
lockInfo
- lock info as retrieved from the request.- Returns:
- lockdiscovery object to be returned in the response. If the lock
could not be obtained a
DavException
is thrown. - Throws:
DavException
- if the lock could not be obtained.- See Also:
DavResource.lock(LockInfo)
-
refreshLock
public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException
Description copied from interface:DavResource
Refresh an existing lock by resetting the timeout.- Specified by:
refreshLock
in interfaceDavResource
- Parameters:
lockInfo
- lock info as retrieved from the request.lockToken
- identifying the lock to be refreshed.- Returns:
- lockdiscovery object to be returned in the response body. If the lock
could not be refreshed a
DavException
is thrown. - Throws:
DavException
- if the lock could not be refreshed.- See Also:
DavResource.refreshLock(LockInfo, String)
-
unlock
public void unlock(String lockToken) throws DavException
Description copied from interface:DavResource
Remove the lock identified by the included lock token from this resource. This method will return false if the unlocking did not succeed.- Specified by:
unlock
in interfaceDavResource
- Parameters:
lockToken
- identifying the lock to be removed.- Throws:
DavException
- if the lock could not be removed.- See Also:
DavResource.unlock(String)
-
addLockManager
public void addLockManager(LockManager lockMgr)
Description copied from interface:DavResource
Add an externalLockManager
to this resource. This method may throwUnsupportedOperationException
if the resource does handle locking itself.- Specified by:
addLockManager
in interfaceDavResource
- See Also:
DavResource.addLockManager(org.apache.jackrabbit.webdav.lock.LockManager)
-
getFactory
public DavResourceFactory getFactory()
Description copied from interface:DavResource
Return theDavResourceFactory
that created this resource.- Specified by:
getFactory
in interfaceDavResource
- Returns:
- the factory that created this resource.
- See Also:
DavResource.getFactory()
-
getSession
public DavSession getSession()
Description copied from interface:DavResource
Retrieve theDavSession
associated with this resource.- Specified by:
getSession
in interfaceDavResource
- Returns:
- session object associated with this resource.
- See Also:
DavResource.getSession()
-
bind
public void bind(DavResource collection, DavResource newBinding) throws DavException
Description copied from interface:BindableResource
Will add a new binding to the given collection referencing this resource.- Specified by:
bind
in interfaceBindableResource
- Parameters:
collection
- the collection to create the new binding in.newBinding
- the new binding- Throws:
DavException
- See Also:
BindableResource.rebind(DavResource, DavResource)
-
rebind
public void rebind(DavResource collection, DavResource newBinding) throws DavException
Description copied from interface:BindableResource
Will rebind the resource to the given collection. By definition, this is an atomic move operation.- Specified by:
rebind
in interfaceBindableResource
- Parameters:
collection
- the collection to create the new binding in.newBinding
- the new binding- Throws:
DavException
- See Also:
BindableResource.rebind(DavResource, DavResource)
-
getParentElements
public Set<ParentElement> getParentElements()
Description copied from interface:BindableResource
Will retrieve a collection of parent elements of the bindable resource representing the parent set.- Specified by:
getParentElements
in interfaceBindableResource
- Returns:
- newBinding the new binding
- See Also:
BindableResource.getParentElements()
-
getNode
protected Node getNode()
Returns the node that is wrapped by this resource.- Returns:
- The underlying JCR node instance.
-
getImportContext
protected ImportContext getImportContext(InputContext inputCtx, String systemId) throws IOException
Returns a newImportContext
- Parameters:
inputCtx
-systemId
-- Returns:
- a new
ImportContext
- Throws:
IOException
-
getExportContext
protected ExportContext getExportContext(OutputContext outputCtx) throws IOException
Returns a newExportContext
- Parameters:
outputCtx
-- Returns:
- a new
ExportContext
- Throws:
IOException
-
getPropertyImportContext
protected PropertyImportContext getPropertyImportContext(List<? extends PropEntry> changeList)
Returns a newPropertyImportContext
.- Parameters:
changeList
-- Returns:
- a new
PropertyImportContext
.
-
getPropertyExportContext
protected PropertyExportContext getPropertyExportContext()
Returns a newPropertyExportContext
.- Returns:
- a new
PropertyExportContext
-
-