org.apache.jackrabbit.webdav.jcr
Class WorkspaceResourceImpl

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

public class WorkspaceResourceImpl
extends Object
implements WorkspaceResource, VersionControlledResource

WorkspaceResourceImpl...


Field Summary
protected  boolean initedProps
           
protected  DavPropertySet properties
           
protected  SupportedLock supportedLock
           
protected  SupportedReportSetProperty supportedReports
           
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.WorkspaceResource
BASELINE_CONTROLLED_COLLECTION_SET, CUURENT_ACTIVITY_SET, WORKSPACE_CHECKOUT_SET
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.VersionControlledResource
ACTIVITY_SET, AUTO_MERGE_SET, AUTO_VERSION, BASELINE_CONTROLLED_COLLECTION, ECLIPSED_SET, CHECKED_IN, CHECKED_OUT, CHECKIN_FORK, CHECKOUT_FORK, MERGE_SET, methods_checkedIn, methods_checkedOut, PREDECESSOR_SET, SUBBASELINE_SET, UNRESERVED, VERSION_HISTORY
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.VersionableResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.DeltaVResource
METHODS_INCL_MKWORKSPACE
 
Fields inherited from interface org.apache.jackrabbit.webdav.transaction.TransactionResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.search.SearchResource
METHODS
 
Method Summary
 void addLockManager(LockManager lockMgr)
           
 void addMember(DavResource resource, InputContext inputContext)
          Throws 403 exception (Forbidden)
 void addVersionControl()
           
 void addWorkspace(DavResource workspace)
          The JCR api does not provide methods to create new workspaces.
 MultiStatusResponse alterProperties(DavPropertySet setProperties, DavPropertyNameSet removePropertyNames)
          Builds a single List from the properties to set and the properties to remove and delegates the list to AbstractResource.alterProperties(List);
 MultiStatusResponse alterProperties(List changeList)
          Handles an attempt to set ItemResourceConstants.JCR_NAMESPACES and forwards any other set or remove requests to the super class.
 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()
           
 DavResource getCollection()
          Retrieve the collection that has all workspace collections as internal members.
 String getComplianceClass()
          Returns a string listing the compliance classes for this resource as it is required for the DAV response header.
 String getDisplayName()
          Returns the name of the workspace.
 DavResourceFactory getFactory()
           
 String getHref()
           
 DavResourceLocator getLocator()
           
protected  DavResourceLocator getLocatorFromItem(javax.jcr.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)
           
 ActiveLock[] getLocks()
           
 DavResourceIterator getMembers()
          Returns the resource representing the JCR root node.
 long getModificationTime()
          Always returns 'now'
 OptionsResponse getOptionResponse(OptionsInfo optionsInfo)
           
 DavPropertySet getProperties()
           
 DavProperty getProperty(DavPropertyName name)
           
 DavPropertyName[] getPropertyNames()
           
 QueryGrammerSet getQueryGrammerSet()
           
 DavResource[] getReferenceResources(DavPropertyName hrefPropertyName)
          Return an array of DavResource objects that are referenced by the property with the specified name.
 Report getReport(ReportInfo reportInfo)
           
protected  javax.jcr.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()
           
 String getSupportedMethods()
           
 String getTransactionId()
           
 VersionHistoryResource getVersionHistory()
           
protected  String getWorkspaceHref()
          Retrieve the href of the workspace the current session belongs to.
 boolean hasLock(Type type, Scope scope)
          Returns true if this resource has a lock applied with the given type and scope.
 String checkin()
           
 void checkout()
           
 void init(TxLockManager txMgr, String transactionId)
           
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()
           
 boolean isLockable(Type type, Scope scope)
          Returns true, if the SupportedLock property contains an entry with the given type and scope.
 void label(LabelInfo labelInfo)
           
 ActiveLock lock(LockInfo reqLockInfo)
           
 MultiStatus merge(MergeInfo mergeInfo)
           
 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 403 exception (Forbidden)
 void removeProperty(DavPropertyName propertyName)
          Throws HttpServletResponse.SC_METHOD_NOT_ALLOWED
 MultiStatus search(SearchInfo sInfo)
           
 void setProperty(DavProperty property)
          Allows to alter the registered namespaces (ItemResourceConstants.JCR_NAMESPACES) and forwards any other property to the super class.
 void spool(OutputContext outputContext)
          Sets content lengths to '0' and retrieves the modification time.
 void uncheckout()
           
 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)
           
 MultiStatus update(UpdateInfo updateInfo)
          While RFC 3253 does not define any version-related operations for the workspace resource, this implementation uses VersionControlledResource.update(UpdateInfo) to map Workspace.restore(javax.jcr.version.Version[], boolean) to a WebDAV call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.jackrabbit.webdav.version.DeltaVResource
addWorkspace, getOptionResponse, getReferenceResources, getReport
 
Methods inherited from interface org.apache.jackrabbit.webdav.DavResource
addLockManager, alterProperties, copy, getComplianceClass, getFactory, getHref, getLocator, getLock, getLocks, getProperties, getProperty, getPropertyNames, getResourcePath, getSession, hasLock, isLockable, lock, move, refreshLock, removeProperty, unlock
 

Field Detail

initedProps

protected boolean initedProps

properties

protected DavPropertySet properties

supportedLock

protected SupportedLock supportedLock

supportedReports

protected SupportedReportSetProperty supportedReports
Method Detail

getSupportedMethods

public String getSupportedMethods()
Specified by:
getSupportedMethods in interface DavResource

exists

public boolean exists()
Specified by:
exists in interface DavResource
Returns:
true

isCollection

public boolean isCollection()
Specified by:
isCollection in interface DavResource
Returns:
true

getDisplayName

public String getDisplayName()
Returns the name of the workspace.

Specified by:
getDisplayName in interface DavResource
Returns:
The workspace name
See Also:
DavResource.getDisplayName(), Workspace.getName()

getModificationTime

public long getModificationTime()
Always returns 'now'

Specified by:
getModificationTime in interface DavResource
Returns:

spool

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

Specified by:
spool in interface DavResource
Parameters:
outputContext -
Throws:
IOException

getCollection

public DavResource getCollection()
Retrieve the collection that has all workspace collections as internal members.

Specified by:
getCollection in interface DavResource
See Also:
DavResource.getCollection()

addMember

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

Specified by:
addMember in interface DavResource
Parameters:
resource -
inputContext -
Throws:
DavException

getMembers

public DavResourceIterator getMembers()
Returns the resource representing the JCR root node.

Specified by:
getMembers in interface DavResource
Returns:

removeMember

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

Specified by:
removeMember in interface DavResource
Parameters:
member -
Throws:
DavException

setProperty

public void setProperty(DavProperty property)
                 throws DavException
Allows to alter the registered namespaces (ItemResourceConstants.JCR_NAMESPACES) and forwards any other property to the super class.

Note that again no property status is set. Any failure while setting a property results in an exception (violating RFC 2518).

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

alterProperties

public MultiStatusResponse alterProperties(List changeList)
                                    throws DavException
Handles an attempt to set ItemResourceConstants.JCR_NAMESPACES and forwards any other set or remove requests to the super class.

Specified by:
alterProperties in interface DavResource
Throws:
DavException
See Also:
setProperty(DavProperty), AbstractResource.alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

addVersionControl

public void addVersionControl()
                       throws DavException
Specified by:
addVersionControl in interface VersionableResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

checkin

public String checkin()
               throws DavException
Specified by:
checkin in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

checkout

public void checkout()
              throws DavException
Specified by:
checkout in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

uncheckout

public void uncheckout()
                throws DavException
Specified by:
uncheckout in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

update

public MultiStatus update(UpdateInfo updateInfo)
                   throws DavException
While RFC 3253 does not define any version-related operations for the workspace resource, this implementation uses VersionControlledResource.update(UpdateInfo) to map Workspace.restore(javax.jcr.version.Version[], boolean) to a WebDAV call.

Limitation: note that the MultiStatus returned by this method will not list any nodes that have been removed due to an Uuid conflict.

Specified by:
update in interface VersionControlledResource
Parameters:
updateInfo -
Returns:
Throws:
DavException
See Also:
VersionControlledResource.update(org.apache.jackrabbit.webdav.version.UpdateInfo)

merge

public MultiStatus merge(MergeInfo mergeInfo)
                  throws DavException
Specified by:
merge in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

label

public void label(LabelInfo labelInfo)
           throws DavException
Specified by:
label in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

getVersionHistory

public VersionHistoryResource getVersionHistory()
                                         throws DavException
Specified by:
getVersionHistory in interface VersionControlledResource
Throws:
DavException - (403) since workspace is not versionable. implementing VersionControlledResource only for 'update'.

initLockSupport

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

See Also:
SupportedLock

initSupportedReports

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

See Also:
SupportedReportSetProperty, AbstractResource.initSupportedReports()

getWorkspaceHref

protected String getWorkspaceHref()
Retrieve the href of the workspace the current session belongs to.

Returns:
href of the workspace

initProperties

protected void initProperties()
Fill the set of default properties


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()
Specified by:
getLocator in interface DavResource
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()
Specified by:
getHref in interface DavResource
See Also:
DavResource.getHref(), DavResourceLocator.getHref(boolean)

getPropertyNames

public DavPropertyName[] getPropertyNames()
Specified by:
getPropertyNames in interface DavResource
See Also:
DavResource.getPropertyNames()

getProperty

public DavProperty getProperty(DavPropertyName name)
Specified by:
getProperty in interface DavResource
See Also:
DavResource.getProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)

getProperties

public DavPropertySet getProperties()
Specified by:
getProperties in interface DavResource
See Also:
DavResource.getProperties()

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(DavPropertySet setProperties,
                                           DavPropertyNameSet removePropertyNames)
                                    throws DavException
Builds a single List from the properties to set and the properties to remove and delegates the list to AbstractResource.alterProperties(List);

Specified by:
alterProperties in interface DavResource
Throws:
DavException
See Also:
DavResource.alterProperties(org.apache.jackrabbit.webdav.property.DavPropertySet, org.apache.jackrabbit.webdav.property.DavPropertyNameSet)

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)
Specified by:
getLock in interface DavResource
See Also:
DavResource.getLock(Type, Scope)

getLocks

public ActiveLock[] getLocks()
Specified by:
getLocks in interface DavResource
See Also:
todo improve....

lock

public ActiveLock lock(LockInfo reqLockInfo)
                throws DavException
Specified by:
lock in interface DavResource
Throws:
DavException
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 -
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)
Specified by:
addLockManager in interface DavResource
See Also:
DavResource.addLockManager(org.apache.jackrabbit.webdav.lock.LockManager)

getFactory

public DavResourceFactory getFactory()
Specified by:
getFactory in interface DavResource
See Also:
DavResource.getFactory()

getSession

public DavSession getSession()
Specified by:
getSession in interface DavResource
See Also:
DavResource.getSession(), DavResource.getSession()

init

public void init(TxLockManager txMgr,
                 String transactionId)
Specified by:
init in interface TransactionResource
See Also:
TransactionResource.init(TxLockManager, String)

unlock

public void unlock(String lockToken,
                   TransactionInfo tInfo)
            throws DavException
Specified by:
unlock in interface TransactionResource
Throws:
DavException
See Also:
TransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo)

getTransactionId

public String getTransactionId()
Specified by:
getTransactionId in interface TransactionResource
See Also:
TransactionResource.getTransactionId()

getOptionResponse

public OptionsResponse getOptionResponse(OptionsInfo optionsInfo)
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
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()
Specified by:
getQueryGrammerSet in interface SearchResource
Returns:
See Also:
SearchResource.getQueryGrammerSet()

search

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

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(javax.jcr.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 javax.jcr.Session getRepositorySession()
Shortcut for getSession().getRepositorySession()

Returns:
repository session present in the AbstractResource.session.


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