org.apache.jackrabbit.webdav.simple
Class DavResourceImpl

java.lang.Object
  extended by 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
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
DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, boolean isCollection)
          Create a new DavResource.
DavResourceImpl(DavResourceLocator locator, DavResourceFactory factory, DavSession session, ResourceConfig config, Node node)
          Create a new DavResource.
 
Method Summary
 void addLockManager(LockManager lockMgr)
          Add an external LockManager 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 resource
 boolean 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 new ExportContext
 DavResourceFactory getFactory()
          Return the DavResourceFactory 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 new ImportContext
 DavResourceLocator getLocator()
          Returns the locator 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 or null 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.
 DavProperty<?> getProperty(DavPropertyName name)
          Return the webdav property with the specified name.
protected  PropertyExportContext getPropertyExportContext()
          Returns a new PropertyExportContext.
protected  PropertyImportContext getPropertyImportContext(List<? extends PropEntry> changeList)
          Returns a new PropertyImportContext.
 DavPropertyName[] getPropertyNames()
          Returns an array of all property names available on this resource.
 String getResourcePath()
          Returns the path of the hierarchy element defined by this DavResource.
 DavSession getSession()
          Retrieve the DavSession 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 properties
 boolean 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 resource
 void 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 not null this implementation build a new ExportContext based on the specified context and forwards the export to its IOManager.
 void unlock(String lockToken)
          Remove the lock identified by the included lock token from this resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 new DavResource.

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 new DavResource.

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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
Returns:
true if the resource represents a collection resource.
See Also:
DavResource.isCollection()

getLocator

public DavResourceLocator getLocator()
Description copied from interface: DavResource
Returns the locator object for this webdav resource, which encapsulates the information for building the complete 'href'.

Specified by:
getLocator in interface DavResource
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 this DavResource. This method is a shortcut for DavResource.getLocator().getResourcePath().

Specified by:
getResourcePath in interface DavResource
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 interface DavResource
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:

Using the item name as DAV:displayname caused problems with XP built-in client in case of resources representing SameNameSibling nodes.

Specified by:
getDisplayName in interface DavResource
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 interface DavResource
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 not null this implementation build a new ExportContext based on the specified context and forwards the export to its IOManager. If the IOManager.exportContent(ExportContext, DavResource) fails, an IOException is thrown.

Specified by:
spool in interface DavResource
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 interface DavResource
Parameters:
name - name of the webdav property
Returns:
the DavProperty with the given name or null 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.

Specified by:
getProperties in interface DavResource
Returns:
a DavPropertySet containing all webdav property of this resource.
See Also:
DavResource.getProperties()

getPropertyNames

public DavPropertyName[] getPropertyNames()
Description copied from interface: DavResource
Returns an array of all property names available on this resource.

Specified by:
getPropertyNames in interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
Parameters:
changeList - list containing DavPropertyName objects (for properties to be removed) and DavProperty 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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
Parameters:
type -
scope -
Returns:
true if type is Type.WRITE and scope is Scope.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 interface DavResource
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 or null 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 interface DavResource
Returns:
lock information of this resource or null if this resource has no lock applying it. If an error occurs while retrieving the lock information null 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 interface DavResource
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 interface DavResource
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 interface DavResource
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 interface DavResource
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 external LockManager to this resource. This method may throw UnsupportedOperationException if the resource does handle locking itself.

Specified by:
addLockManager in interface DavResource
See Also:
DavResource.addLockManager(org.apache.jackrabbit.webdav.lock.LockManager)

getFactory

public DavResourceFactory getFactory()
Description copied from interface: DavResource
Return the DavResourceFactory that created this resource.

Specified by:
getFactory in interface DavResource
Returns:
the factory that created this resource.
See Also:
DavResource.getFactory()

getSession

public DavSession getSession()
Description copied from interface: DavResource
Retrieve the DavSession associated with this resource.

Specified by:
getSession in interface DavResource
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 interface BindableResource
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 interface BindableResource
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 interface BindableResource
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 new ImportContext

Parameters:
inputCtx -
systemId -
Returns:
a new ImportContext
Throws:
IOException

getExportContext

protected ExportContext getExportContext(OutputContext outputCtx)
                                  throws IOException
Returns a new ExportContext

Parameters:
outputCtx -
Returns:
a new ExportContext
Throws:
IOException

getPropertyImportContext

protected PropertyImportContext getPropertyImportContext(List<? extends PropEntry> changeList)
Returns a new PropertyImportContext.

Parameters:
changeList -
Returns:
a new PropertyImportContext.

getPropertyExportContext

protected PropertyExportContext getPropertyExportContext()
Returns a new PropertyExportContext.

Returns:
a new PropertyExportContext


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.