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 StringCOMPLIANCE_CLASSESstatic StringMETHODSprotected DavPropertySetpropertiesprotected booleanpropsInitialized-
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 voidaddLockManager(LockManager lockMgr)Add an externalLockManagerto this resource.voidaddMember(DavResource member, InputContext inputContext)Adds a new member to this resource.MultiStatusResponsealterProperties(List<? extends PropEntry> changeList)Set/add and remove the specified properties from this resource.voidbind(DavResource collection, DavResource newBinding)Will add a new binding to the given collection referencing this resource.voidcopy(DavResource destination, boolean shallow)Copy this DavResource to the given destination resourcebooleanexists()Returns true if this webdav resource represents an existing repository item.DavResourcegetCollection()Retrieve the resource this resource is internal member of.StringgetComplianceClass()Returns a comma separated list of all compliance classes the given resource is fulfilling.StringgetDisplayName()Returns the the last segment of the resource path.protected ExportContextgetExportContext(OutputContext outputCtx)Returns a newExportContextDavResourceFactorygetFactory()Return theDavResourceFactorythat created this resource.StringgetHref()Returns the absolute href of this resource as returned in the multistatus response body.protected ImportContextgetImportContext(InputContext inputCtx, String systemId)Returns a newImportContextDavResourceLocatorgetLocator()Returns thelocatorobject for this webdav resource, which encapsulates the information for building the complete 'href'.ActiveLockgetLock(Type type, Scope scope)Return the lock present on this webdav resource ornullif the resource is either not locked or not lockable at all.ActiveLock[]getLocks()Returns an array of all locks applied to the given resource.DavResourceIteratorgetMembers()Returns an iterator over all internal members.longgetModificationTime()Return the time of the last modification or -1 if the modification time could not be retrieved.protected NodegetNode()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.DavPropertySetgetProperties()Returns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROPrequest.DavProperty<?>getProperty(DavPropertyName name)Return the webdav property with the specified name.protected PropertyExportContextgetPropertyExportContext()Returns a newPropertyExportContext.protected PropertyImportContextgetPropertyImportContext(List<? extends PropEntry> changeList)Returns a newPropertyImportContext.DavPropertyName[]getPropertyNames()Returns an array of allproperty namesavailable on this resource.StringgetResourcePath()Returns the path of the hierarchy element defined by thisDavResource.DavSessiongetSession()Retrieve theDavSessionassociated with this resource.StringgetSupportedMethods()Returns a comma separated list of all METHODS supported by the given resource.booleanhasLock(Type type, Scope scope)Returns true if a lock applies to this resource.protected voidinitProperties()Fill the set of propertiesbooleanisCollection()Returns true if this webdav resource has the resourcetype 'collection'.booleanisLockable(Type type, Scope scope)Returns true, if the this resource allows locking.ActiveLocklock(LockInfo lockInfo)Lock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.voidmove(DavResource destination)Move this DavResource to the given destination resourcevoidrebind(DavResource collection, DavResource newBinding)Will rebind the resource to the given collection.ActiveLockrefreshLock(LockInfo lockInfo, String lockToken)Refresh an existing lock by resetting the timeout.voidremoveMember(DavResource member)Removes the specified member from this resource.voidremoveProperty(DavPropertyName propertyName)Remove the specified property from this resource.voidsetProperty(DavProperty<?> property)Add/Set the specified property on this resource.voidspool(OutputContext outputContext)If this resource exists and the specified context is notnullthis implementation build a newExportContextbased on the specified context and forwards the export to itsIOManager.voidunlock(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:DavResourceReturns a comma separated list of all compliance classes the given resource is fulfilling.- Specified by:
getComplianceClassin interfaceDavResource- Returns:
- compliance classes
- See Also:
DavResource.getComplianceClass()
-
getSupportedMethods
public String getSupportedMethods()
Description copied from interface:DavResourceReturns a comma separated list of all METHODS supported by the given resource.- Specified by:
getSupportedMethodsin interfaceDavResource- Returns:
- DavResource#METHODS
- See Also:
DavResource.getSupportedMethods()
-
exists
public boolean exists()
Description copied from interface:DavResourceReturns true if this webdav resource represents an existing repository item.- Specified by:
existsin interfaceDavResource- Returns:
- true, if the resource represents an existing repository item.
- See Also:
)
-
isCollection
public boolean isCollection()
Description copied from interface:DavResourceReturns true if this webdav resource has the resourcetype 'collection'.- Specified by:
isCollectionin interfaceDavResource- Returns:
- true if the resource represents a collection resource.
- See Also:
DavResource.isCollection()
-
getLocator
public DavResourceLocator getLocator()
Description copied from interface:DavResourceReturns thelocatorobject for this webdav resource, which encapsulates the information for building the complete 'href'.- Specified by:
getLocatorin interfaceDavResource- Returns:
- the locator for this resource.
- See Also:
DavResource.getLocator()
-
getResourcePath
public String getResourcePath()
Description copied from interface:DavResourceReturns the path of the hierarchy element defined by thisDavResource. This method is a shortcut forDavResource.getLocator().getResourcePath().- Specified by:
getResourcePathin interfaceDavResource- Returns:
- path of the element defined by this
DavResource. - See Also:
DavResource.getResourcePath()
-
getHref
public String getHref()
Description copied from interface:DavResourceReturns the absolute href of this resource as returned in the multistatus response body.- Specified by:
getHrefin 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:
getDisplayNamein interfaceDavResource- Returns:
- display name.
- See Also:
DavResource.getDisplayName()
-
getModificationTime
public long getModificationTime()
Description copied from interface:DavResourceReturn the time of the last modification or -1 if the modification time could not be retrieved.- Specified by:
getModificationTimein 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 notnullthis implementation build a newExportContextbased on the specified context and forwards the export to itsIOManager. If theIOManager.exportContent(ExportContext, DavResource)fails, anIOExceptionis thrown.- Specified by:
spoolin 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:DavResourceReturn the webdav property with the specified name.- Specified by:
getPropertyin interfaceDavResource- Parameters:
name- name of the webdav property- Returns:
- the
DavPropertywith the given name ornullif the property does not exist. - See Also:
DavResource.getProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
-
getProperties
public DavPropertySet getProperties()
Description copied from interface:DavResourceReturns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROPrequest. The implementation may in addition expose other (protected or calculated) properties which should be marked accordingly (see alsoDavProperty.isInvisibleInAllprop().- Specified by:
getPropertiesin interfaceDavResource- Returns:
- a
DavPropertySetcontaining 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:DavResourceReturns an array of allproperty namesavailable on this resource.- Specified by:
getPropertyNamesin 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:DavResourceAdd/Set the specified property on this resource.- Specified by:
setPropertyin 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:DavResourceRemove the specified property from this resource.- Specified by:
removePropertyin 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:DavResourceSet/add and remove the specified properties from this resource.- Specified by:
alterPropertiesin interfaceDavResource- Parameters:
changeList- list containingDavPropertyNameobjects (for properties to be removed) andDavPropertyobjects (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:DavResourceRetrieve the resource this resource is internal member of.- Specified by:
getCollectionin interfaceDavResource- Returns:
- resource this resource is an internal member of. In case this resource
is the root
nullis returned. - See Also:
DavResource.getCollection()
-
getMembers
public DavResourceIterator getMembers()
Description copied from interface:DavResourceReturns an iterator over all internal members.- Specified by:
getMembersin interfaceDavResource- Returns:
- a
DavResourceIteratorover 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:
addMemberin interfaceDavResource- Parameters:
member-DavResourceto 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:DavResourceRemoves the specified member from this resource.- Specified by:
removeMemberin interfaceDavResource- Throws:
DavException- See Also:
DavResource.removeMember(DavResource)
-
move
public void move(DavResource destination) throws DavException
Description copied from interface:DavResourceMove this DavResource to the given destination resource- Specified by:
movein interfaceDavResource- Throws:
DavException- See Also:
DavResource.move(DavResource)
-
copy
public void copy(DavResource destination, boolean shallow) throws DavException
Description copied from interface:DavResourceCopy this DavResource to the given destination resource- Specified by:
copyin interfaceDavResource- Throws:
DavException- See Also:
DavResource.copy(DavResource, boolean)
-
isLockable
public boolean isLockable(Type type, Scope scope)
Description copied from interface:DavResourceReturns true, if the this resource allows locking. NOTE, that this method does not define, whether a lock/unlock can be successfully executed.- Specified by:
isLockablein interfaceDavResource- Parameters:
type-scope-- Returns:
- true if type is
Type.WRITEand 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:DavResourceReturns 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:
hasLockin 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:DavResourceReturn the lock present on this webdav resource ornullif 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:
getLockin interfaceDavResource- Returns:
- lock information of this resource or
nullif this resource has no lock applying it. If an error occurs while retrieving the lock informationnullis returned as well. - See Also:
DavResource.getLock(Type, Scope)
-
getLocks
public ActiveLock[] getLocks()
Description copied from interface:DavResourceReturns an array of all locks applied to the given resource.- Specified by:
getLocksin 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:DavResourceLock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.- Specified by:
lockin 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
DavExceptionis 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:DavResourceRefresh an existing lock by resetting the timeout.- Specified by:
refreshLockin 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
DavExceptionis 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:DavResourceRemove the lock identified by the included lock token from this resource. This method will return false if the unlocking did not succeed.- Specified by:
unlockin 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:DavResourceAdd an externalLockManagerto this resource. This method may throwUnsupportedOperationExceptionif the resource does handle locking itself.- Specified by:
addLockManagerin interfaceDavResource- See Also:
DavResource.addLockManager(org.apache.jackrabbit.webdav.lock.LockManager)
-
getFactory
public DavResourceFactory getFactory()
Description copied from interface:DavResourceReturn theDavResourceFactorythat created this resource.- Specified by:
getFactoryin interfaceDavResource- Returns:
- the factory that created this resource.
- See Also:
DavResource.getFactory()
-
getSession
public DavSession getSession()
Description copied from interface:DavResourceRetrieve theDavSessionassociated with this resource.- Specified by:
getSessionin 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:BindableResourceWill add a new binding to the given collection referencing this resource.- Specified by:
bindin 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:BindableResourceWill rebind the resource to the given collection. By definition, this is an atomic move operation.- Specified by:
rebindin 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:BindableResourceWill retrieve a collection of parent elements of the bindable resource representing the parent set.- Specified by:
getParentElementsin 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
-
-