org.apache.jackrabbit.webdav.jcr
Class RootCollection

java.lang.Object
  extended by org.apache.jackrabbit.webdav.jcr.RootCollection
All Implemented Interfaces:
DavResource, SearchResource, TransactionResource, DeltaVResource

public class RootCollection
extends Object

RootCollection represent the WebDAV root resource that does not represent any repository item. A call to getMembers() returns a DavResourceIterator containing only workspace resources resources, thus revealing the names of the accessable JCR workspaces.


Field Summary
protected  boolean initedProps
           
protected  DavPropertySet properties
           
protected  SupportedLock supportedLock
           
protected  SupportedReportSetProperty supportedReports
           
 
Fields inherited from interface org.apache.jackrabbit.webdav.transaction.TransactionResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.DeltaVResource
METHODS, METHODS_INCL_MKWORKSPACE
 
Fields inherited from interface org.apache.jackrabbit.webdav.search.SearchResource
METHODS
 
Constructor Summary
protected RootCollection(DavResourceLocator locator, JcrDavSession session, DavResourceFactory factory)
          Create a new RootCollection.
 
Method Summary
 void addLockManager(LockManager lockMgr)
          Add an external LockManager to this resource.
 void addMember(DavResource resource, InputContext inputContext)
          Throws exception: 403 Forbidden.
 void addWorkspace(DavResource workspace)
          The JCR api does not provide methods to create new workspaces.
 MultiStatusResponse alterProperties(List<? extends PropEntry> changeList)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
 void copy(DavResource destination, boolean shallow)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
protected  DavResource createResourceFromLocator(DavResourceLocator loc)
          Create a new DavResource from the given locator.
 boolean exists()
          Returns true
 DavResource getCollection()
          Always returns null
 String getComplianceClass()
          Returns a string listing the compliance classes for this resource as it is required for the DAV response header.
 String getDisplayName()
          Returns an empty string.
 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.
 DavResourceLocator getLocator()
          Returns the locator object for this webdav resource, which encapsulates the information for building the complete 'href'.
protected  DavResourceLocator getLocatorFromItem(Item repositoryItem)
          Build a new DavResourceLocator from the given repository item.
protected  DavResourceLocator getLocatorFromItemPath(String itemPath)
          Build a DavResourceLocator from the given itemPath path.
 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 the member resources, which are all workspace resources available.
 long getModificationTime()
          Always returns 'now'
 OptionsResponse getOptionResponse(OptionsInfo optionsInfo)
          Retrieves the information requested in the OPTIONS request body and returns the corresponding values.
 DavPropertySet getProperties()
          Returns all webdav properties present on this resource.
 DavProperty<?> getProperty(DavPropertyName name)
          Return the webdav property with the specified name.
 DavPropertyName[] getPropertyNames()
          Returns an array of all property names available on this resource.
 QueryGrammerSet getQueryGrammerSet()
          Returns the protected DAV:supported-method-set property which is defined mandatory by RTF 3253.
 DavResource[] getReferenceResources(DavPropertyName hrefPropertyName)
          Return an array of DavResource objects that are referenced by the property with the specified name.
 Report getReport(ReportInfo reportInfo)
          Runs the report specified by the given ReportInfo.
protected  Session getRepositorySession()
          Shortcut for getSession().getRepositorySession()
 String getResourcePath()
          Returns the path of the underlying repository item or the item to be created (PUT/MKCOL).
 DavSession getSession()
          Retrieve the DavSession associated with this resource.
 String getSupportedMethods()
          Returns a string listing the METHODS for this resource as it is required for the "Allow" response header.
 String getTransactionId()
          The TransactionId or null according to the value of the corresponding request header field.
protected  String getWorkspaceHref()
          Since the root resource does not represent a repository item and therefore is not member of a workspace resource, this method always returns null.
 boolean hasLock(Type type, Scope scope)
          Returns true if this resource has a lock applied with the given type and scope.
 void init(TxLockManager txMgr, String transactionId)
          Initializes the TransactionResource.
protected  void initLockSupport()
          Define the set of locks supported by this resource.
protected  void initProperties()
          Fill the set of default properties
protected  void initSupportedReports()
          Define the set of reports supported by this resource.
 boolean isCollection()
          Returns true
 boolean isLockable(Type type, Scope scope)
          Returns true, if the SupportedLock property contains an entry with the given type and scope.
 ActiveLock lock(LockInfo reqLockInfo)
          Lock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.
 void move(DavResource destination)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
 ActiveLock refreshLock(LockInfo info, String lockToken)
          Only transaction lock may be available on this resource.
 void removeMember(DavResource member)
          Throws exception: 403 Forbidden.
 void removeProperty(DavPropertyName propertyName)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
 MultiStatus search(SearchInfo sInfo)
          Runs a search with the language and query defined in the SearchInfo object specified and returns a MultiStatus object listing the results.
 void setProperty(DavProperty<?> property)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
 void spool(OutputContext outputContext)
          Sets content lengths to '0' and retrieves the modification time.
 void unlock(String lockToken)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED since only transaction locks may be present on this resource, that need to be released by calling TransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo).
 void unlock(String lockToken, TransactionInfo tInfo)
          Overloads the unlock method of the DavResource interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initedProps

protected boolean initedProps

properties

protected DavPropertySet properties

supportedLock

protected SupportedLock supportedLock

supportedReports

protected SupportedReportSetProperty supportedReports
Constructor Detail

RootCollection

protected RootCollection(DavResourceLocator locator,
                         JcrDavSession session,
                         DavResourceFactory factory)
Create a new RootCollection.

Parameters:
locator -
session -
Method Detail

getSupportedMethods

public String getSupportedMethods()
Returns a string listing the METHODS for this resource as it is required for the "Allow" response header.

Returns:
string listing the METHODS allowed
See Also:
DavResource.getSupportedMethods()

exists

public boolean exists()
Returns true

Returns:
true
See Also:
DavResource.exists()

isCollection

public boolean isCollection()
Returns true

Returns:
true
See Also:
DavResource.isCollection()

getDisplayName

public String getDisplayName()
Returns an empty string.

Returns:
empty string
See Also:
DavResource.getDisplayName()

getModificationTime

public long getModificationTime()
Always returns 'now'

Returns:

spool

public void spool(OutputContext outputContext)
           throws IOException
Sets content lengths to '0' and retrieves the modification time.

Parameters:
outputContext -
Throws:
IOException

getCollection

public DavResource getCollection()
Always returns null

Returns:
null for the root resource is not internal member of any resource.
See Also:
DavResource.getCollection()

addMember

public void addMember(DavResource resource,
                      InputContext inputContext)
               throws DavException
Throws exception: 403 Forbidden.

Parameters:
resource - 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, InputContext)

getMembers

public DavResourceIterator getMembers()
Returns an iterator over the member resources, which are all workspace resources available.

Returns:
members of this collection
See Also:
DavResource.getMembers()

removeMember

public void removeMember(DavResource member)
                  throws DavException
Throws exception: 403 Forbidden.

Throws:
DavException
See Also:
DavResource.removeMember(org.apache.jackrabbit.webdav.DavResource)

initLockSupport

protected void initLockSupport()
Define the set of locks supported by this resource.

See Also:
AbstractResource.initLockSupport()

getWorkspaceHref

protected String getWorkspaceHref()
Since the root resource does not represent a repository item and therefore is not member of a workspace resource, this method always returns null.

Returns:
null
See Also:
AbstractResource.getWorkspaceHref()

getComplianceClass

public String getComplianceClass()
Returns a string listing the compliance classes for this resource as it is required for the DAV response header. This includes DAV 1, 2 which is supported by all derived classes as well as a subset of the classes defined by DeltaV: version-control, version-history, checkout-in-place, label, merge, update and workspace.
Those compliance classes are added as required by RFC3253 since all all resources in the jcr-server support at least the reporting and some basic versioning functionality.

Specified by:
getComplianceClass in interface DavResource
Returns:
string listing the compliance classes.
See Also:
DavResource.getComplianceClass()

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()
Returns the path of the underlying repository item or the item to be created (PUT/MKCOL). If the resource exists but does not represent a repository item null is returned.

Specified by:
getResourcePath in interface DavResource
Returns:
path of the underlying repository item.
See Also:
DavResource.getResourcePath(), DavResourceLocator.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(), DavResourceLocator.getHref(boolean)

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()

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()

setProperty

public void setProperty(DavProperty<?> property)
                 throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

Specified by:
setProperty in interface DavResource
Parameters:
property -
Throws:
DavException - Always throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
See Also:
DavResource.setProperty(org.apache.jackrabbit.webdav.property.DavProperty)

removeProperty

public void removeProperty(DavPropertyName propertyName)
                    throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

Specified by:
removeProperty in interface DavResource
Parameters:
propertyName -
Throws:
DavException - Always throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
See Also:
DavResource.removeProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)

alterProperties

public MultiStatusResponse alterProperties(List<? extends PropEntry> changeList)
                                    throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

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).
See Also:
DavResource.alterProperties(List)

move

public void move(DavResource destination)
          throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

Specified by:
move in interface DavResource
Parameters:
destination -
Throws:
DavException - Always throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
See Also:
DavResource.move(org.apache.jackrabbit.webdav.DavResource)

copy

public void copy(DavResource destination,
                 boolean shallow)
          throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

Specified by:
copy in interface DavResource
Parameters:
destination -
shallow -
Throws:
DavException - Always throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
See Also:
DavResource.copy(org.apache.jackrabbit.webdav.DavResource, boolean)

isLockable

public boolean isLockable(Type type,
                          Scope scope)
Returns true, if the SupportedLock property contains an entry with the given type and scope. By default resources allow for transaction lock only.

Specified by:
isLockable in interface DavResource
Parameters:
type -
scope -
Returns:
true if this resource may be locked by the given type and scope.
See Also:
DavResource.isLockable(org.apache.jackrabbit.webdav.lock.Type, org.apache.jackrabbit.webdav.lock.Scope)

hasLock

public boolean hasLock(Type type,
                       Scope scope)
Returns true if this resource has a lock applied with the given type and scope.

Specified by:
hasLock in interface DavResource
Parameters:
type -
scope -
Returns:
true if this resource has a lock applied with the given type and scope.
See Also:
DavResource.hasLock(Type, 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:
todo improve....

lock

public ActiveLock lock(LockInfo reqLockInfo)
                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:
reqLockInfo - 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(org.apache.jackrabbit.webdav.lock.LockInfo)

refreshLock

public ActiveLock refreshLock(LockInfo info,
                              String lockToken)
                       throws DavException
Only transaction lock may be available on this resource.

Specified by:
refreshLock in interface DavResource
Parameters:
info -
lockToken -
Returns:
lockdiscovery object to be returned in the response body. If the lock could not be refreshed a DavException is thrown.
Throws:
DavException
See Also:
DavResource.refreshLock(org.apache.jackrabbit.webdav.lock.LockInfo, String)

unlock

public void unlock(String lockToken)
            throws DavException
Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED since only transaction locks may be present on this resource, that need to be released by calling TransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo).

Specified by:
unlock in interface DavResource
Parameters:
lockToken -
Throws:
DavException - Always throws HttpServletResponse.SC_METHOD_NOT_ALLOWED

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(), DavResource.getSession()

init

public void init(TxLockManager txMgr,
                 String transactionId)
Description copied from interface: TransactionResource
Initializes the TransactionResource.

Specified by:
init in interface TransactionResource
See Also:
TransactionResource.init(TxLockManager, String)

unlock

public void unlock(String lockToken,
                   TransactionInfo tInfo)
            throws DavException
Description copied from interface: TransactionResource
Overloads the unlock method of the DavResource interface.

Specified by:
unlock in interface TransactionResource
Parameters:
lockToken - lock token as present in the request header.
tInfo - transaction info object as present in the UNLOCK request body.
Throws:
DavException - if an error occurs
See Also:
TransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo)

getTransactionId

public String getTransactionId()
Description copied from interface: TransactionResource
The TransactionId or null according to the value of the corresponding request header field.

Specified by:
getTransactionId in interface TransactionResource
Returns:
TransactionId header or null
See Also:
TransactionResource.getTransactionId()

getOptionResponse

public OptionsResponse getOptionResponse(OptionsInfo optionsInfo)
Description copied from interface: DeltaVResource
Retrieves the information requested in the OPTIONS request body and returns the corresponding values.

Specified by:
getOptionResponse in interface DeltaVResource
Parameters:
optionsInfo -
Returns:
object to be used in the OPTIONS response body or null
See Also:
DeltaVResource.getOptionResponse(org.apache.jackrabbit.webdav.version.OptionsInfo)

getReport

public Report getReport(ReportInfo reportInfo)
                 throws DavException
Description copied from interface: DeltaVResource
Runs the report specified by the given ReportInfo.

Specified by:
getReport in interface DeltaVResource
Parameters:
reportInfo -
Returns:
the requested report
Throws:
DavException
See Also:
DeltaVResource.getReport(org.apache.jackrabbit.webdav.version.report.ReportInfo)

addWorkspace

public void addWorkspace(DavResource workspace)
                  throws DavException
The JCR api does not provide methods to create new workspaces. Calling addWorkspace on this resource will always fail.

Specified by:
addWorkspace in interface DeltaVResource
Parameters:
workspace -
Throws:
DavException - Always throws.
See Also:
DeltaVResource.addWorkspace(org.apache.jackrabbit.webdav.DavResource)

getReferenceResources

public DavResource[] getReferenceResources(DavPropertyName hrefPropertyName)
                                    throws DavException
Return an array of DavResource objects that are referenced by the property with the specified name.

Specified by:
getReferenceResources in interface DeltaVResource
Parameters:
hrefPropertyName -
Returns:
array of DavResources
Throws:
DavException
See Also:
DeltaVResource.getReferenceResources(org.apache.jackrabbit.webdav.property.DavPropertyName)

getQueryGrammerSet

public QueryGrammerSet getQueryGrammerSet()
Description copied from interface: SearchResource
Returns the protected DAV:supported-method-set property which is defined mandatory by RTF 3253. This method call is a shortcut for DavResource.getProperty(SearchConstants.QUERY_GRAMMER_SET).

Specified by:
getQueryGrammerSet in interface SearchResource
Returns:
See Also:
SearchResource.getQueryGrammerSet()

search

public MultiStatus search(SearchInfo sInfo)
                   throws DavException
Description copied from interface: SearchResource
Runs a search with the language and query defined in the SearchInfo object specified and returns a MultiStatus object listing the results.

Specified by:
search in interface SearchResource
Parameters:
sInfo -
Returns:
Throws:
DavException
See Also:
SearchResource.search(org.apache.jackrabbit.webdav.search.SearchInfo)

initProperties

protected void initProperties()
Fill the set of default properties


createResourceFromLocator

protected DavResource createResourceFromLocator(DavResourceLocator loc)
                                         throws DavException
Create a new DavResource from the given locator.

Parameters:
loc -
Returns:
new DavResource
Throws:
DavException

getLocatorFromItemPath

protected DavResourceLocator getLocatorFromItemPath(String itemPath)
Build a DavResourceLocator from the given itemPath path.

Parameters:
itemPath -
Returns:
a new DavResourceLocator
See Also:
DavLocatorFactory.createResourceLocator(String, String, String)

getLocatorFromItem

protected DavResourceLocator getLocatorFromItem(Item repositoryItem)
Build a new DavResourceLocator from the given repository item.

Parameters:
repositoryItem -
Returns:
a new locator for the specified item.
See Also:
getLocatorFromItemPath(String)

getRepositorySession

protected Session getRepositorySession()
Shortcut for getSession().getRepositorySession()

Returns:
repository session present in the AbstractResource.session.

initSupportedReports

protected void initSupportedReports()
Define the set of reports supported by this resource.

See Also:
SupportedReportSetProperty, AbstractResource.initSupportedReports()


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