Package org.apache.jackrabbit.webdav.jcr
Class EventJournalResourceImpl
- java.lang.Object
-
- org.apache.jackrabbit.webdav.jcr.EventJournalResourceImpl
-
- All Implemented Interfaces:
DavResource,SearchResource,TransactionResource,DeltaVResource
public class EventJournalResourceImpl extends Object
Implements a JCREventJournalin terms of an RFC 4287 Atom feed.Each feed entry represents either a single event, or, if the repository supports the
Event.PERSISTevent, an event bundle. The actual event data is sent in the Atom <content> element and uses the same XML serialization as the one used for subscriptions.Skipping is implemented by specifying the desired time offset (represented as hexadecimal long in ms since the epoch) disguised as ETag in the HTTP "If-None-Match" header field.
The generated feed may not be complete; the total number of events is limited in order not to overload the client.
Furthermore, the number of events is limited by going up to 2000 ms into the future (based on the request time). This is supposed to limit the wait time for the client).
-
-
Field Summary
Fields Modifier and Type Field Description static StringEVENTMEDIATYPEprotected booleaninitedPropsprotected DavPropertyNameSetnamesprotected DavPropertySetpropertiesstatic StringRELURIFROMWORKSPACEprotected SupportedLocksupportedLockprotected SupportedReportSetPropertysupportedReports-
Fields inherited from interface org.apache.jackrabbit.webdav.DavResource
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
-
Fields inherited from interface org.apache.jackrabbit.webdav.transaction.TransactionResource
METHODS
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLockManager(LockManager lockMgr)Add an externalLockManagerto this resource.voidaddMember(DavResource resource, InputContext inputContext)Add the given resource as an internal member to this resource.voidaddWorkspace(DavResource workspace)The JCR api does not provide methods to create new workspaces.MultiStatusResponsealterProperties(List<? extends PropEntry> changeList)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDvoidcopy(DavResource destination, boolean shallow)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDprotected DavResourcecreateResourceFromLocator(DavResourceLocator loc)Create a newDavResourcefrom the given locator.booleanexists()Returns true if this webdav resource represents an existing repository item.DavResourcegetCollection()Retrieve the resource this resource is internal member of.StringgetComplianceClass()Returns a string listing the compliance classes for this resource as it is required for the DAV response header.protected StringgetCreationDate()Returns the creation date which is used for theDavPropertyName.CREATIONDATEproperty.protected StringgetCreatorDisplayName()Returns the display name of the creator which is used for the protectedDeltaVConstants.CREATOR_DISPLAYNAMEproperty.StringgetDisplayName()Returns the display name of this resource.DavResourceFactorygetFactory()Return theDavResourceFactorythat created this resource.StringgetHref()Returns the absolute href of this resource as returned in the multistatus response body.DavResourceLocatorgetLocator()Returns thelocatorobject for this webdav resource, which encapsulates the information for building the complete 'href'.protected DavResourceLocatorgetLocatorFromItem(Item repositoryItem)Build a newDavResourceLocatorfrom the given repository item.protected DavResourceLocatorgetLocatorFromItemPath(String itemPath)Build aDavResourceLocatorfrom the given itemPath path.ActiveLockgetLock(Type type, Scope scope)Return the lock present on this webdav resource ornullif the resource is either not locked or not lockable at all.ActiveLock[]getLocks()Returns an array of all locks applied to the given resource.DavResourceIteratorgetMembers()Returns an iterator over all internal members.longgetModificationTime()Return the time of the last modification or -1 if the modification time could not be retrieved.OptionsResponsegetOptionResponse(OptionsInfo optionsInfo)Retrieves the information requested in the OPTIONS request body and returns the corresponding values.DavPropertySetgetProperties()Returns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROPrequest.DavProperty<?>getProperty(DavPropertyName name)Return the webdav property with the specified name.DavPropertyName[]getPropertyNames()Returns an array of allproperty namesavailable on this resource.QueryGrammerSetgetQueryGrammerSet()Returns the protected DAV:supported-method-set property which is defined mandatory by RTF 3253.DavResource[]getReferenceResources(DavPropertyName hrefPropertyName)Return an array ofDavResourceobjects that are referenced by the property with the specified name.ReportgetReport(ReportInfo reportInfo)Runs the report specified by the givenReportInfo.protected SessiongetRepositorySession()Shortcut forgetSession().getRepositorySession()StringgetResourcePath()Returns the path of the underlying repository item or the item to be created (PUT/MKCOL).DavSessiongetSession()Retrieve theDavSessionassociated with this resource.StringgetSupportedMethods()Returns a comma separated list of all METHODS supported by the given resource.StringgetTransactionId()The TransactionId ornullaccording to the value of the corresponding requestheaderfield.protected StringgetWorkspaceHref()Retrieve the href of the workspace the current session belongs to.booleanhasLock(Type type, Scope scope)Returns true if this resource has a lock applied with the given type and scope.voidinit(TxLockManager txMgr, String transactionId)Initializes theTransactionResource.protected voidinitLockSupport()Define the set of locks supported by this resource.protected voidinitProperties()Fill the set of default propertiesprotected voidinitPropertyNames()Property names common to all resources.protected voidinitSupportedReports()Define the set of reports supported by this resource.booleanisCollection()Returns true if this webdav resource has the resourcetype 'collection'.booleanisLockable(Type type, Scope scope)Returns true, if theSupportedLockproperty contains an entry with the given type and scope.ActiveLocklock(LockInfo reqLockInfo)Lock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.voidmove(DavResource destination)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDprotected StringnormalizeResourceHref(String href)Normalize the resourcehref.ActiveLockrefreshLock(LockInfo info, String lockToken)Only transaction lock may be available on this resource.voidremoveMember(DavResource member)Removes the specified member from this resource.voidremoveProperty(DavPropertyName propertyName)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDMultiStatussearch(SearchInfo sInfo)Runs a search with the language and query defined in theSearchInfoobject specified and returns aMultiStatusobject listing the results.voidsetProperty(DavProperty<?> property)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDvoidspool(OutputContext outputContext)Spools the resource properties and ev.voidunlock(String lockToken)ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDsince only transaction locks may be present on this resource, that need to be released by callingTransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo).voidunlock(String lockToken, TransactionInfo tInfo)Overloads theunlockmethod of theDavResourceinterface.
-
-
-
Field Detail
-
RELURIFROMWORKSPACE
public static final String RELURIFROMWORKSPACE
- See Also:
- Constant Field Values
-
EVENTMEDIATYPE
public static final String EVENTMEDIATYPE
- See Also:
- Constant Field Values
-
initedProps
protected boolean initedProps
-
properties
protected DavPropertySet properties
-
names
protected DavPropertyNameSet names
-
supportedLock
protected SupportedLock supportedLock
-
supportedReports
protected SupportedReportSetProperty supportedReports
-
-
Method Detail
-
getSupportedMethods
public String getSupportedMethods()
Description copied from interface:DavResourceReturns a comma separated list of all METHODS supported by the given resource.- Returns:
- METHODS supported by this resource.
-
exists
public boolean exists()
Description copied from interface:DavResourceReturns true if this webdav resource represents an existing repository item.- Returns:
- true, if the resource represents an existing repository item.
-
isCollection
public boolean isCollection()
Description copied from interface:DavResourceReturns true if this webdav resource has the resourcetype 'collection'.- Returns:
- true if the resource represents a collection resource.
-
getDisplayName
public String getDisplayName()
Description copied from interface:DavResourceReturns the display name of this resource.- Returns:
- display name.
-
getModificationTime
public long getModificationTime()
Description copied from interface:DavResourceReturn the time of the last modification or -1 if the modification time could not be retrieved.- Returns:
- time of last modification or -1.
-
spool
public void spool(OutputContext outputContext) throws IOException
Description copied from interface:DavResourceSpools the resource properties and ev. content to the specified context (e.g. to respond to a 'GET' or 'HEAD' request). The context could e.g. wrap the servlet response.- Parameters:
outputContext- The output context.- Throws:
IOException- If an error occurs.
-
getCollection
public DavResource getCollection()
Description copied from interface:DavResourceRetrieve the resource this resource is internal member of.- Returns:
- resource this resource is an internal member of. In case this resource
is the root
nullis returned.
-
addMember
public void addMember(DavResource resource, InputContext inputContext) throws DavException
Description copied from interface:DavResourceAdd the given resource as an internal member to this resource.- Parameters:
resource-DavResourceto be added as internal member.inputContext- Context providing the properties and content for the internal member to be created or replaced.- Throws:
DavException
-
getMembers
public DavResourceIterator getMembers()
Description copied from interface:DavResourceReturns an iterator over all internal members.- Returns:
- a
DavResourceIteratorover all internal members.
-
removeMember
public void removeMember(DavResource member) throws DavException
Description copied from interface:DavResourceRemoves the specified member from this resource.- Throws:
DavException
-
initLockSupport
protected void initLockSupport()
Define the set of locks supported by this resource.- See Also:
SupportedLock
-
getWorkspaceHref
protected String getWorkspaceHref()
Retrieve the href of the workspace the current session belongs to.- Returns:
- href of the workspace
-
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:
getComplianceClassin interfaceDavResource- Returns:
- string listing the compliance classes.
- See Also:
DavResource.getComplianceClass()
-
getLocator
public DavResourceLocator getLocator()
Description copied from interface:DavResourceReturns thelocatorobject for this webdav resource, which encapsulates the information for building the complete 'href'.- Specified by:
getLocatorin interfaceDavResource- Returns:
- the locator for this resource.
- See Also:
DavResource.getLocator()
-
getResourcePath
public String getResourcePath()
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 itemnullis returned.- Specified by:
getResourcePathin interfaceDavResource- Returns:
- path of the underlying repository item.
- See Also:
DavResource.getResourcePath(),DavResourceLocator.getResourcePath()
-
getHref
public String getHref()
Description copied from interface:DavResourceReturns the absolute href of this resource as returned in the multistatus response body.- Specified by:
getHrefin interfaceDavResource- Returns:
- href
- See Also:
DavResource.getHref(),DavResourceLocator.getHref(boolean)
-
getPropertyNames
public DavPropertyName[] getPropertyNames()
Description copied from interface:DavResourceReturns an array of allproperty namesavailable on this resource.- Specified by:
getPropertyNamesin interfaceDavResource- Returns:
- an array of property names.
- See Also:
DavResource.getPropertyNames()
-
getProperty
public DavProperty<?> getProperty(DavPropertyName name)
Description copied from interface:DavResourceReturn the webdav property with the specified name.- Specified by:
getPropertyin interfaceDavResource- Parameters:
name- name of the webdav property- Returns:
- the
DavPropertywith the given name ornullif the property does not exist. - See Also:
DavResource.getProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
-
getProperties
public DavPropertySet getProperties()
Description copied from interface:DavResourceReturns all webdav properties present on this resource that will be return upon aDavConstants.PROPFIND_ALL_PROPrequest. The implementation may in addition expose other (protected or calculated) properties which should be marked accordingly (see alsoDavProperty.isInvisibleInAllprop().- Specified by:
getPropertiesin interfaceDavResource- Returns:
- a
DavPropertySetcontaining at least all properties of this resource that are exposed in 'allprop' PROPFIND request. - See Also:
DavResource.getProperties()
-
setProperty
public void setProperty(DavProperty<?> property) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWED- Specified by:
setPropertyin interfaceDavResource- Parameters:
property-- Throws:
DavException- Always throwsHttpServletResponse.SC_METHOD_NOT_ALLOWED- See Also:
DavResource.setProperty(org.apache.jackrabbit.webdav.property.DavProperty)
-
removeProperty
public void removeProperty(DavPropertyName propertyName) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWED- Specified by:
removePropertyin interfaceDavResource- Parameters:
propertyName-- Throws:
DavException- Always throwsHttpServletResponse.SC_METHOD_NOT_ALLOWED- See Also:
DavResource.removeProperty(org.apache.jackrabbit.webdav.property.DavPropertyName)
-
alterProperties
public MultiStatusResponse alterProperties(List<? extends PropEntry> changeList) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWED- Specified by:
alterPropertiesin interfaceDavResource- Parameters:
changeList- list containingDavPropertyNameobjects (for properties to be removed) andDavPropertyobjects (for properties to be added/set).- Returns:
- multistatus response listing the status resulting from setting and/or removing the specified properties, in order to allow a detailed multistatus response.
- Throws:
DavException- if an error occurred. This may be the case if the general state of the resource prevents any properties to be set or removed (e.g. due to a lock).- See Also:
DavResource.alterProperties(List)
-
move
public void move(DavResource destination) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWED- Specified by:
movein interfaceDavResource- Parameters:
destination-- Throws:
DavException- Always throwsHttpServletResponse.SC_METHOD_NOT_ALLOWED- See Also:
DavResource.move(org.apache.jackrabbit.webdav.DavResource)
-
copy
public void copy(DavResource destination, boolean shallow) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWED- Specified by:
copyin interfaceDavResource- Parameters:
destination-shallow-- Throws:
DavException- Always throwsHttpServletResponse.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 theSupportedLockproperty contains an entry with the given type and scope. By default resources allow fortransactionlock only.- Specified by:
isLockablein interfaceDavResource- 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:
hasLockin interfaceDavResource- 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:DavResourceReturn the lock present on this webdav resource ornullif the resource is either not locked or not lockable at all. Note, that a resource may have a lock that is inherited by a deep lock enforced on one of its 'parent' resources.- Specified by:
getLockin interfaceDavResource- Returns:
- lock information of this resource or
nullif this resource has no lock applying it. If an error occurs while retrieving the lock informationnullis returned as well. - See Also:
DavResource.getLock(Type, Scope)
-
getLocks
public ActiveLock[] getLocks()
Description copied from interface:DavResourceReturns an array of all locks applied to the given resource.- Specified by:
getLocksin interfaceDavResource- Returns:
- array of locks. The array is empty if there are no locks applied to this resource.
- See Also:
todo improve....
-
lock
public ActiveLock lock(LockInfo reqLockInfo) throws DavException
Description copied from interface:DavResourceLock this webdav resource with the information retrieve from the request and return the resulting lockdiscovery object.- Specified by:
lockin interfaceDavResource- Parameters:
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
DavExceptionis 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:
refreshLockin interfaceDavResource- Parameters:
info-lockToken-- Returns:
- lockdiscovery object to be returned in the response body. If the lock
could not be refreshed a
DavExceptionis thrown. - Throws:
DavException- See Also:
DavResource.refreshLock(org.apache.jackrabbit.webdav.lock.LockInfo, String)
-
unlock
public void unlock(String lockToken) throws DavException
ThrowsHttpServletResponse.SC_METHOD_NOT_ALLOWEDsince only transaction locks may be present on this resource, that need to be released by callingTransactionResource.unlock(String, org.apache.jackrabbit.webdav.transaction.TransactionInfo).- Specified by:
unlockin interfaceDavResource- Parameters:
lockToken-- Throws:
DavException- Always throwsHttpServletResponse.SC_METHOD_NOT_ALLOWED
-
addLockManager
public void addLockManager(LockManager lockMgr)
Description copied from interface:DavResourceAdd an externalLockManagerto this resource. This method may throwUnsupportedOperationExceptionif the resource does handle locking itself.- Specified by:
addLockManagerin interfaceDavResource- See Also:
DavResource.addLockManager(org.apache.jackrabbit.webdav.lock.LockManager)
-
getFactory
public DavResourceFactory getFactory()
Description copied from interface:DavResourceReturn theDavResourceFactorythat created this resource.- Specified by:
getFactoryin interfaceDavResource- Returns:
- the factory that created this resource.
- See Also:
DavResource.getFactory()
-
getSession
public DavSession getSession()
Description copied from interface:DavResourceRetrieve theDavSessionassociated with this resource.- Specified by:
getSessionin interfaceDavResource- Returns:
- session object associated with this resource.
- See Also:
DavResource.getSession(),DavResource.getSession()
-
init
public void init(TxLockManager txMgr, String transactionId)
Description copied from interface:TransactionResourceInitializes theTransactionResource.- Specified by:
initin interfaceTransactionResource- See Also:
TransactionResource.init(TxLockManager, String)
-
unlock
public void unlock(String lockToken, TransactionInfo tInfo) throws DavException
Description copied from interface:TransactionResourceOverloads theunlockmethod of theDavResourceinterface.- Specified by:
unlockin interfaceTransactionResource- 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:TransactionResourceThe TransactionId ornullaccording to the value of the corresponding requestheaderfield.- Specified by:
getTransactionIdin interfaceTransactionResource- Returns:
- TransactionId header or
null - See Also:
TransactionResource.getTransactionId()
-
getOptionResponse
public OptionsResponse getOptionResponse(OptionsInfo optionsInfo)
Description copied from interface:DeltaVResourceRetrieves the information requested in the OPTIONS request body and returns the corresponding values.- Specified by:
getOptionResponsein interfaceDeltaVResource- 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:DeltaVResourceRuns the report specified by the givenReportInfo.- Specified by:
getReportin interfaceDeltaVResource- 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. CallingaddWorkspaceon this resource will always fail.- Specified by:
addWorkspacein interfaceDeltaVResource- 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 ofDavResourceobjects that are referenced by the property with the specified name.- Specified by:
getReferenceResourcesin interfaceDeltaVResource- 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:SearchResourceReturns the protected DAV:supported-method-set property which is defined mandatory by RTF 3253. This method call is a shortcut forDavResource.getProperty(SearchConstants.QUERY_GRAMMER_SET).- Specified by:
getQueryGrammerSetin interfaceSearchResource- Returns:
- See Also:
SearchResource.getQueryGrammerSet()
-
search
public MultiStatus search(SearchInfo sInfo) throws DavException
Description copied from interface:SearchResourceRuns a search with the language and query defined in theSearchInfoobject specified and returns aMultiStatusobject listing the results.- Specified by:
searchin interfaceSearchResource- Parameters:
sInfo-- Returns:
- Throws:
DavException- See Also:
SearchResource.search(org.apache.jackrabbit.webdav.search.SearchInfo)
-
initPropertyNames
protected void initPropertyNames()
Property names common to all resources.
-
initProperties
protected void initProperties()
Fill the set of default properties
-
createResourceFromLocator
protected DavResource createResourceFromLocator(DavResourceLocator loc) throws DavException
Create a newDavResourcefrom the given locator.- Parameters:
loc-- Returns:
- new
DavResource - Throws:
DavException
-
getLocatorFromItemPath
protected DavResourceLocator getLocatorFromItemPath(String itemPath)
Build aDavResourceLocatorfrom 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 newDavResourceLocatorfrom the given repository item.- Parameters:
repositoryItem-- Returns:
- a new locator for the specified item.
- See Also:
getLocatorFromItemPath(String)
-
getRepositorySession
protected Session getRepositorySession()
Shortcut forgetSession().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()
-
getCreatorDisplayName
protected String getCreatorDisplayName()
Returns the display name of the creator which is used for the protectedDeltaVConstants.CREATOR_DISPLAYNAMEproperty.- Returns:
- always
null; subclasses may provide a regular value.
-
getCreationDate
protected String getCreationDate()
Returns the creation date which is used for theDavPropertyName.CREATIONDATEproperty.- Returns:
- a dummy date; subclasses may provide a reasonable value.
-
-