org.apache.jackrabbit.webdav.jcr.version
Class VersionHistoryItemCollection

java.lang.Object
  extended by org.apache.jackrabbit.webdav.jcr.DefaultItemCollection
      extended by org.apache.jackrabbit.webdav.jcr.version.VersionHistoryItemCollection
All Implemented Interfaces:
DavResource, ItemResourceConstants, ObservationResource, OrderingResource, SearchResource, TransactionResource, DeltaVResource, VersionHistoryResource

public class VersionHistoryItemCollection
extends DefaultItemCollection
implements VersionHistoryResource

VersionHistoryItemCollection represents a JCR version history.

See Also:
VersionHistory

Field Summary
protected  boolean initedProps
           
protected  javax.jcr.Item item
           
protected  DavPropertySet properties
           
protected  SupportedLock supportedLock
           
protected  SupportedReportSetProperty supportedReports
           
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.VersionHistoryResource
METHODS, ROOT_VERSION, VERSION_SET
 
Fields inherited from interface org.apache.jackrabbit.webdav.version.DeltaVResource
METHODS_INCL_MKWORKSPACE
 
Fields inherited from interface org.apache.jackrabbit.webdav.ordering.OrderingResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.observation.ObservationResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.jcr.ItemResourceConstants
ATTR_VALUE_TYPE, EXCLUSIVE_SESSION, IMPORT_UUID_BEHAVIOR, JCR_DEFINITION, JCR_DEPTH, JCR_INDEX, JCR_ISMODIFIED, JCR_ISNEW, JCR_LENGTH, JCR_LENGTHS, JCR_MIXINNODETYPES, JCR_NAME, JCR_NAMESPACES, JCR_PARENT, JCR_PATH, JCR_PRIMARYITEM, JCR_PRIMARYNODETYPE, JCR_REFERENCES, JCR_TYPE, JCR_UUID, JCR_VALUE, JCR_VALUES, JCR_VERSIONABLEUUID, JCR_WORKSPACE_NAME, METHODS, NAMESPACE, PRIVILEGE_JCR_ADD_NODE, PRIVILEGE_JCR_READ, PRIVILEGE_JCR_REMOVE, PRIVILEGE_JCR_SET_PROPERTY, ROOT_ITEM_PATH, ROOT_ITEM_RESOURCEPATH, VERSIONSTORAGE_PATH, XML_DESCRIPTOR, XML_DESCRIPTORKEY, XML_DESCRIPTORVALUE, XML_EXCLUSIVE_SESSION_SCOPED, XML_LENGTH, XML_NAMESPACE, XML_PREFIX, XML_PRIMARYNODETYPE, XML_RELPATH, XML_REMOVEEXISTING, XML_URI, XML_VALUE
 
Fields inherited from interface org.apache.jackrabbit.webdav.transaction.TransactionResource
METHODS
 
Fields inherited from interface org.apache.jackrabbit.webdav.search.SearchResource
METHODS
 
Constructor Summary
VersionHistoryItemCollection(DavResourceLocator resourcePath, JcrDavSession session, DavResourceFactory factory, javax.jcr.Item item)
          Create a new VersionHistoryItemCollection resource.
 
Method Summary
 void addLockManager(LockManager lockMgr)
           
 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);
 void copy(DavResource destination, boolean shallow)
          Copies the underlying repository item to the indicated destination.
protected  DavResource createResourceFromLocator(DavResourceLocator loc)
          Create a new DavResource from the given locator.
 boolean exists()
          Returns true if there exists a repository item with the given resource path, false otherwise.
 DavResource getCollection()
          Returns the resource representing the parent item of the repository item represented by this resource.
 String getDisplayName()
          Retrieves the last segment of the item path (or the resource path if this resource does not exist).
 DavResourceFactory getFactory()
           
 String getHref()
           
protected static String getItemName(String itemPath)
          Retrieves the last segment of the given path and removes the index if present.
 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[] getLocks()
           
 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()
           
 VersionResource[] getVersions()
          Return an array of VersionResources representing all versions present in the underlying JCR version history.
protected  String getWorkspaceHref()
          Retrieve the href of the workspace the current session belongs to.
 void init(SubscriptionManager subsMgr)
           
 void init(TxLockManager txMgr, String transactionId)
           
protected  void initProperties()
          Fill the property set for this resource.
 boolean isLockable(Type type, Scope scope)
          Returns true, if the SupportedLock property contains an entry with the given type and scope.
 void move(DavResource destination)
          Moves the underlying repository item to the indicated destination.
 EventDiscovery poll(String subscriptionId, long timeout)
           
 void removeMember(DavResource member)
          Removing a version resource is achieved by calling removeVersion on the versionhistory item this version belongs to.
 MultiStatus search(SearchInfo sInfo)
           
 Subscription subscribe(SubscriptionInfo info, String subscriptionId)
           
 void unlock(String lockToken, TransactionInfo tInfo)
           
 void unsubscribe(String subscriptionId)
           
 
Methods inherited from class org.apache.jackrabbit.webdav.jcr.DefaultItemCollection
addHrefProperty, addHrefProperty, addMember, alterProperties, getComplianceClass, getLock, getMembers, getModificationTime, hasLock, initLockSupport, initSupportedReports, isCollection, isOrderable, lock, orderMembers, refreshLock, removeProperty, setProperty, spool, unlock
 
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, addMember, alterProperties, alterProperties, copy, exists, getCollection, getComplianceClass, getDisplayName, getFactory, getHref, getLocator, getLock, getLocks, getMembers, getModificationTime, getProperties, getProperty, getPropertyNames, getResourcePath, getSession, hasLock, isCollection, isLockable, lock, move, refreshLock, removeProperty, setProperty, spool, unlock
 

Field Detail

item

protected final javax.jcr.Item item

initedProps

protected boolean initedProps

properties

protected DavPropertySet properties

supportedLock

protected SupportedLock supportedLock

supportedReports

protected SupportedReportSetProperty supportedReports
Constructor Detail

VersionHistoryItemCollection

public VersionHistoryItemCollection(DavResourceLocator resourcePath,
                                    JcrDavSession session,
                                    DavResourceFactory factory,
                                    javax.jcr.Item item)
Create a new VersionHistoryItemCollection resource.

Parameters:
resourcePath -
session -
factory -
Method Detail

getSupportedMethods

public String getSupportedMethods()
Specified by:
getSupportedMethods in interface DavResource
Overrides:
getSupportedMethods in class DefaultItemCollection
See Also:
DavResource.getSupportedMethods()

removeMember

public void removeMember(DavResource member)
                  throws DavException
Removing a version resource is achieved by calling removeVersion on the versionhistory item this version belongs to.

Specified by:
removeMember in interface DavResource
Overrides:
removeMember in class DefaultItemCollection
Throws:
DavException - if the version does not exist or if an error occurs while deleting.
See Also:
DavResource.removeMember(org.apache.jackrabbit.webdav.DavResource)

getVersions

public VersionResource[] getVersions()
                              throws DavException
Return an array of VersionResources representing all versions present in the underlying JCR version history.

Specified by:
getVersions in interface VersionHistoryResource
Returns:
array of VersionResources representing all versions present in the underlying JCR version history.
Throws:
DavException
See Also:
VersionHistoryResource.getVersions()

initProperties

protected void initProperties()
Fill the property set for this resource.

Overrides:
initProperties in class DefaultItemCollection

exists

public boolean exists()
Returns true if there exists a repository item with the given resource path, false otherwise.

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

getDisplayName

public String getDisplayName()
Retrieves the last segment of the item path (or the resource path if this resource does not exist). An item path is in addition first translated to the corresponding resource path.
NOTE: the displayname is not equivalent to item name which is exposed with the {http://www.day.com/jcr/webdav/1.0}name property.

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

getCollection

public DavResource getCollection()
Returns the resource representing the parent item of the repository item represented by this resource. If this resoure represents the root item a RootCollection is returned.

Specified by:
getCollection in interface DavResource
Returns:
the collection this resource is internal member of. Except for the repository root, the returned collection always represent the parent repository node.
See Also:
DavResource.getCollection()

move

public void move(DavResource destination)
          throws DavException
Moves the underlying repository item to the indicated destination.

Specified by:
move in interface DavResource
Parameters:
destination -
Throws:
DavException
See Also:
DavResource.move(DavResource), Session.move(String, String)

copy

public void copy(DavResource destination,
                 boolean shallow)
          throws DavException
Copies the underlying repository item to the indicated destination. If the locator of the specified destination resource indicates a different workspace, Workspace.copy(String, String, String) is used to perform the copy operation, Workspace.copy(String, String) otherwise.

Note, that this implementation does not support shallow copy.

Specified by:
copy in interface DavResource
Parameters:
destination -
shallow -
Throws:
DavException
See Also:
DavResource.copy(DavResource, boolean), Workspace.copy(String, String), Workspace.copy(String, String, String)

init

public void init(SubscriptionManager subsMgr)
Specified by:
init in interface ObservationResource
See Also:
ObservationResource.init(SubscriptionManager)

subscribe

public Subscription subscribe(SubscriptionInfo info,
                              String subscriptionId)
                       throws DavException
Specified by:
subscribe in interface ObservationResource
Throws:
DavException
See Also:
ObservationResource.subscribe(org.apache.jackrabbit.webdav.observation.SubscriptionInfo, String), SubscriptionManager.subscribe(org.apache.jackrabbit.webdav.observation.SubscriptionInfo, String, org.apache.jackrabbit.webdav.observation.ObservationResource)

unsubscribe

public void unsubscribe(String subscriptionId)
                 throws DavException
Specified by:
unsubscribe in interface ObservationResource
Throws:
DavException
See Also:
ObservationResource.unsubscribe(String), SubscriptionManager.unsubscribe(String, org.apache.jackrabbit.webdav.observation.ObservationResource)

poll

public EventDiscovery poll(String subscriptionId,
                           long timeout)
                    throws DavException
Specified by:
poll in interface ObservationResource
Throws:
DavException
See Also:
ObservationResource.poll(String, long), SubscriptionManager.poll(String, long, org.apache.jackrabbit.webdav.observation.ObservationResource)

getWorkspaceHref

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

Returns:
href of the workspace or null if this resource does not represent a repository item.
See Also:
AbstractResource.getWorkspaceHref()

getItemName

protected static String getItemName(String itemPath)
Retrieves the last segment of the given path and removes the index if present.

Parameters:
itemPath -
Returns:
valid jcr item name

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

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)

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)

getLocks

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

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.