org.eclipse.webdav.client
Class AbstractResourceHandle

java.lang.Object
  extended by org.eclipse.webdav.client.AbstractResourceHandle
All Implemented Interfaces:
WebDAVConstants, WebDAVPropertyNames, WebDAVPropertyValues
Direct Known Subclasses:
CollectionHandle, ResourceHandle

public abstract class AbstractResourceHandle
extends Object
implements WebDAVPropertyNames, WebDAVPropertyValues

The AbstractResourceHandle class is the abstract superclass for all types of resource references. A resource handle is a client-side 'proxy' for the server resource. Instances of handle classes understand the methods appropriate for the corresponding server resource and provide a convenient high-level API for sending WebDAV methods to the server to manipulate the resource.

It is certainly posible to create a stale or invalid handle in numerous ways. For example, the existance of a handle does not imply the existance of a corresponding server resource (indeed resource can be created by sending create() to a handle, or deleted using delete() -- so the life cycles are not coupled. It is also possible to create, say, a collection handle on a regular resource and invoke invalid WebDAV methods. These will typically result in an exception.

The API on these classes are intended to convenience methods for the most common operations on server resources. They make some assumptions about the way you want to receive the results. To get finer (but possibly less convenient) control over the WebDAV methods use the Server interface of DAVClient directly.


Field Summary
protected  DAVClient davClient
           
protected  ILocator locator
           
 
Fields inherited from interface org.eclipse.webdav.internal.kernel.WebDAVPropertyNames
DAV_ACTIVITY_CHECKOUT_SET, DAV_ACTIVITY_VERSION_SET, DAV_AUTO_CHECKIN, DAV_AUTO_CHECKOUT, DAV_AUTO_MERGE_SET, DAV_BASELINE_COLLECTION, DAV_BASELINE_CONTROLLED_COLLECTION, DAV_BASELINE_CONTROLLED_COLLECTION_SET, DAV_BASELINE_SELECTOR, DAV_CHECKED_IN, DAV_CHECKED_OUT, DAV_CHECKIN_DATE, DAV_CHECKIN_FORK, DAV_CHECKOUT_FORK, DAV_CHECKOUT_SET, DAV_COMMENT, DAV_CREATION_DATE, DAV_CREATOR_DISPLAYNAME, DAV_CURRENT_ACTIVITY_SET, DAV_CURRENT_WORKSPACE_SET, DAV_DISPLAY_NAME, DAV_GET_CONTENT_LANGUAGE, DAV_GET_CONTENT_LENGTH, DAV_GET_CONTENT_TYPE, DAV_GET_E_TAG, DAV_GET_LAST_MODIFIED, DAV_HREF, DAV_LABEL_NAME_SET, DAV_LATEST_VERSION, DAV_LOCK_DISCOVERY, DAV_MERGE_SET, DAV_MUTABLE, DAV_PRECURSOR_SET, DAV_PREDECESSOR_SET, DAV_RESOURCE_ID, DAV_RESOURCE_TYPE, DAV_ROOT_VERSION, DAV_SOURCE, DAV_SUBACTIVITY_SET, DAV_SUBBASELINE_SET, DAV_SUCCESSOR_SET, DAV_SUPPORTED_LIVE_PROPERTY_SET, DAV_SUPPORTED_LOCK, DAV_SUPPORTED_METHOD_SET, DAV_SUPPORTED_REPORT_SET, DAV_UNRESERVED, DAV_VERSION_CONTROLLED_CONFIGURATION, DAV_VERSION_HISTORY, DAV_VERSION_NAME, DAV_VERSION_SET, DAV_WORKING_RESOURCE, DAV_WORKSPACE, DAV_WORKSPACE_CHECKOUT_SET, DAV_WORKSPACE_COLLECTION_SET
 
Fields inherited from interface org.eclipse.webdav.internal.kernel.WebDAVPropertyValues
DAV_ACTIVITY_RESOURCE_TYPE, DAV_BASELINE_RESOURCE_TYPE, DAV_COLLECTION_RESOURCE_TYPE, DAV_DISCOURAGED, DAV_FORBIDDEN, DAV_HISTORY_RESOURCE_TYPE, DAV_KEEP_CHECKED_OUT, DAV_LOCKED_UPDATE, DAV_NEW_VERSION, DAV_OK, DAV_OVERWRITE, DAV_UNLOCKED_UPDATE, DAV_VERSION_HISTORY_RESOURCE_TYPE, DAV_WORKSPACE_RESOURCE_TYPE
 
Fields inherited from interface org.eclipse.webdav.internal.kernel.WebDAVConstants
DAV_URI
 
Constructor Summary
AbstractResourceHandle(DAVClient davClient, ILocator locator)
          Creates a new AbstractResourceHandle with the given DAV client and Locator.
 
Method Summary
 CollectionHandle asCollectionHandle()
          Answer a new collection handle on the same underlying server resource.
 ResourceHandle asResourceHandle()
          Answer a new resource handle on the same underlying server resource.
 boolean canTalkDAV()
          Return a boolean value indicating whether or not the server for this resource is DAV compliant.
 ResourceHandle checkIn()
          Check-in this resource.
abstract  AbstractResourceHandle checkOut()
          Check out this resource.
protected  void closeResponse(IResponse response)
          Helper method to close a response from the server.
 void copy(ILocator destination)
          Make a copy of this resource and place it at the location defined by the given locator.
 void copy(ILocator destination, String depth, boolean overwrite, Collection propertyNames)
          Make a copy of this resource and place it at the location specified by the given destination locator.
abstract  void create()
          Create this resource in the repository.
 void delete()
          Delete this resource from the repository.
 void delete(boolean mustExist)
          Delete this resource from the repository, optionally succeeding in the delete if the resource was not found on the server.
 boolean equals(Object obj)
          Answers true iff the receiver and the argument are considered equal, otherwise answers false.
protected  void examineMultiStatusResponse(IResponse response)
          If the given response contains a multistatus body, the bodies status' are checked for errors.
protected  void examineResponse(IResponse response)
          Check the status code of the given response and throw a WebDAV exception if the code indicates failure.
protected  void examineStatusCode(int code, String message)
          Check the given status code and throw a WebDAV exception if the code indicates failure.
 boolean exists()
          Return a boolean value indicating whether or not this resource exists on the server.
protected  URLTable extractPropStats(MultiStatus multiStatus)
          Helper method to extract the property status response from a multi status reponse, and populate a URLTable with the results.
 ResponseInputStream getContent()
          Return the content of this resource as an input stream.
 DAVClient getDAVClient()
          Answer the DAVClient being used by this resource handle for accessing the resource.
 ILocator getLocator()
          Return the locator for this resource.
 Enumeration getLocks()
          Return an Enumeration over ActiveLocks which lists the locks currently held on this resource.
 CollectionHandle getParent()
          Returns a collection handle for the parent of this resource.
 URLTable getProperties(Collection propertyNames, String depth)
          Fetches and returns the specified properties for this resource and its children to the given depth.
 URLTable getProperties(String depth)
          Return a URLTable which contains all of this resources properties to the given depth.
 PropertyStatus getProperty(QualifiedName propertyName)
          Return the property status for the property with the given name.
 URLTable getPropertyNames(String depth)
          Fetch and return the property names for the resource, and the children resources to the specified depth.
 URLTable getVersionTree()
          Retrieve the version tree infomration for the receiver, assuming that the receiver is a version or a version-controlled resource.
 CollectionHandle[] getWorkspaceCollections()
           
 int hashCode()
          Answers the hashcode of the receiver as defined by Object#hashCode().
 IContext head()
          Return the header from a message send to the server.
 boolean isCheckedIn()
          Check to see if the resource is checked in (i.e., is an immutable resource).
 boolean isCheckedOut()
          Check to see if the resource is checked-out.
 boolean isCollection()
          Return a boolean value indicating whether or not this resource is a collection.
 boolean isLocked()
          Return a boolean value indicating whether or not this resource is currently locked.
 boolean isVersion()
          Check to see if the resource is a version.
 boolean isVersionControlled()
          Check to see if the resource is under version control.
 boolean isWorkingResource()
          Check to see if the resource is a working resource.
 LockToken lock()
          Lock this resource with default values.
 LockToken lock(boolean isShared, String depth, int timeout, String owner)
          Lock this resource using the specified parameters.
 void move(ILocator destination)
          Move this resource to the destination specified by the given locator.
 void move(ILocator destination, boolean overwrite, Enumeration names)
          Move this resource to the location specified by the given locator.
protected  IContext newContext()
          Answer a new empty context for requests sent to the receivers server.
protected  Document newDocument()
          Answer a new empty DOM Document suitable for creating requests to the receiver's server.
protected  boolean propertyHasChild(QualifiedName propertyName, QualifiedName childName)
          This is a helper method to check to see if the resource has a property with the given name that in turn has a child with a given name.
protected  ILocator protectedCheckIn()
          Check in the receiver and answer a new Locator on the resulting version resource.
protected  ILocator protectedCheckOut()
          Check out the receiver and answer a new Locator on the resulting checked out resource.
 void refreshLock(LockToken lockToken, int timeout)
          Refresh the lock on this resource with the given lock token.
 void removeProperties(Collection propertyNames)
          Remove the properties with the given names, from this resource.
 void removeProperty(QualifiedName propertyName)
          Remove the property with the given name from this resource.
 void setContent(InputStream input)
          Set the content of this resource to be the untyped data stored in the given input stream.
 void setContent(String contentType, InputStream input)
          Set the content of this resource to be the data stored in the given input stream.
 void setProperties(Collection properties)
          Set the given properties on this resource.
 void setProperty(Element property)
          Set the given property on this resource.
 boolean supportsLiveProperty(QualifiedName propertyName)
          Check to see if the resource supports the named live property.
 String toString()
          Return a string representation of this resource.
 ResponseInputStream trace()
          Send a message to the server.
 void unlock(LockToken token)
          Unlock this resource with the given lock token.
 void update(ILocator version)
          Perform an UPDATE on the receiver to set the version it is based upon.
 void versionControl()
          Bring the receiver under version control.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

davClient

protected DAVClient davClient

locator

protected ILocator locator
Constructor Detail

AbstractResourceHandle

public AbstractResourceHandle(DAVClient davClient,
                              ILocator locator)
Creates a new AbstractResourceHandle with the given DAV client and Locator.

Parameters:
davClient - the DAVClient that contains the server reference and proxy/authentication information.
locator - the Locator identity of the resource.
Method Detail

asCollectionHandle

public CollectionHandle asCollectionHandle()
Answer a new collection handle on the same underlying server resource. Since the handle represents a means of accessing the resource, it is valid to consider a collection resource as a collection or regular resource depending upon how it is being accessed. Note that not all resources have collection semantics.

Returns:
an equivalent collection handle on the resource.

asResourceHandle

public ResourceHandle asResourceHandle()
Answer a new resource handle on the same underlying server resource. Since the handle represents a means of accessing the resource, it is valid to consider a collection resource as a collection or regular resource depending upon how it is being accessed.

Returns:
an equivalent handle on the resource.

canTalkDAV

public boolean canTalkDAV()
                   throws DAVException
Return a boolean value indicating whether or not the server for this resource is DAV compliant.

Returns:
boolean true if the server can respond to DAV requests, or false otherwise.
Throws:
DAVException - if there was a problem checking for DAV compliance

checkIn

public ResourceHandle checkIn()
                       throws DAVException
Check-in this resource. Returns a handle on the new version.

Note that versioned collections do not have internal members so they are represented by ResourceHandle handles.

If the receiver is a working resource it becomes invalid after the check in (because the server deletes the working resource), however, if the receiver is a version-controlled resource the receiver can be used as a checked-in resource.

Returns:
a handle to the newly created version.
Throws:
DAVException - if a problem occurs with the check in on the WebDAV server.

checkOut

public abstract AbstractResourceHandle checkOut()
                                         throws DAVException
Check out this resource. Returns a resource handle on the checked out version-controlled resource, or the working resource if a version is checked out.

Note that a checked-out version-controlled collection has members that are themselves version-controlled resources, or unversioned resources; however, working collection members are always version history resources.

Throws:
DAVException - if a problem occurs checking out the resource.

closeResponse

protected void closeResponse(IResponse response)
                      throws SystemException
Helper method to close a response from the server.

Note that the argument MAY be null in which case the call has no effect.

Parameters:
response - the response from the server, or null denoting a no-op.
Throws:
SystemException - if a problem occurred closing the response.

copy

public void copy(ILocator destination)
          throws DAVException
Make a copy of this resource and place it at the location defined by the given locator.

Uses default values of depth: infinity and overwrite: false for the copy.

Parameters:
destination - the Locator to the destination of the copy.
Throws:
DAVException - if there was a problem copying this resource.
See Also:
IServer.copy(ILocator, ILocator, IContext, Document)

copy

public void copy(ILocator destination,
                 String depth,
                 boolean overwrite,
                 Collection propertyNames)
          throws DAVException
Make a copy of this resource and place it at the location specified by the given destination locator.

Parameters:
destination - the location to put the copy.
depth - how deep to make the copy.
overwrite - how to react if a resource already exists at the destination.
propertyNames - Collection of QualifiedNames of properties that MUST be copied as live properties. Specifying null mean that all properties must be kept alive; specifying an empty collection allows for no properties to be kept live. (ref http://andrew2.andrew.cmu.edu/rfc/rfc2518.html#sec-12.12.1)
Throws:
DAVException - if there was a problem copying this resource.
See Also:
IServer.copy(ILocator, ILocator, IContext, Document)

create

public abstract void create()
                     throws DAVException
Create this resource in the repository.

Subclasses should override this method with the correct behavior for their type.

Throws:
DAVException - if there was a problem creating this resource.

delete

public void delete()
            throws DAVException
Delete this resource from the repository.

As a convenience, if the resource does not exist this method will do nothing (rather than throw an exception). If the caller needs to know if a resource was deleted they can use delete(boolean).

Throws:
DAVException - if there was a problem deleting this resource.
See Also:
delete(boolean), IServer#delete(Locator, Context)

equals

public boolean equals(Object obj)
Answers true iff the receiver and the argument are considered equal, otherwise answers false.

Note that this is a handle equivalence test, and does not imply that the resources are the same resource on the server. Indeed, the method does not contact the server.

Overrides:
equals in class Object
Parameters:
obj - the target of the comparison.
Returns:
whether the two objects are equal.

hashCode

public int hashCode()
Answers the hashcode of the receiver as defined by Object#hashCode().

Overrides:
hashCode in class Object
Returns:
the receiver's hash code.

examineMultiStatusResponse

protected void examineMultiStatusResponse(IResponse response)
                                   throws DAVException
If the given response contains a multistatus body, the bodies status' are checked for errors. If an error is found, an exception is thrown.

Parameters:
response - the response from the server to examine.
Throws:
DAVException - if the given response contains a multistatus body that contains a status code signalling an error.

examineResponse

protected void examineResponse(IResponse response)
                        throws WebDAVException
Check the status code of the given response and throw a WebDAV exception if the code indicates failure.

Parameters:
response - the response to check
Throws:
WebDAVException - if the server returned an HTTP/WebDAV error code (i.e., anything outside the 200-series codes).

extractPropStats

protected URLTable extractPropStats(MultiStatus multiStatus)
                             throws IOException,
                                    MalformedElementException
Helper method to extract the property status response from a multi status reponse, and populate a URLTable with the results.

Parameters:
multiStatus - an editor on the response from the server.
Returns:
all the property status in a URLTable.
Throws:
IOException - if there is a problem parsing the resource URLs.
MalformedElementException - if the XML is badly formed.

getContent

public ResponseInputStream getContent()
                               throws DAVException
Return the content of this resource as an input stream. The input stream should be closed by the user.

Returns:
the input stream
Throws:
DAVException - if there was a problem getting the contents
See Also:
IServer#get(Locator, Context)

getDAVClient

public DAVClient getDAVClient()
Answer the DAVClient being used by this resource handle for accessing the resource.

Returns:
the receiver's DAVClient.

getLocator

public ILocator getLocator()
Return the locator for this resource.

Returns:
the locator for this resource

getLocks

public Enumeration getLocks()
                     throws DAVException
Return an Enumeration over ActiveLocks which lists the locks currently held on this resource. Return an empty enumeration if the lock discovery property is not found on the resource.

Returns:
the enumeration of active locks
Throws:
DAVException - if there was a problem getting the locks
See Also:
getProperty(QualifiedName)

getParent

public CollectionHandle getParent()
                           throws DAVException
Returns a collection handle for the parent of this resource.

Note that this method does NOT perform a method call to the server to ensure that the collection exists.

Returns null if this resource is the root. NOTE The parent of a resource is, in general, ambiguous and may not be immediately discernable from a resource locator. For example, a locator with a 'label' qualifier will identify a version of a version- controlled resource, and the parent will not be found by a simple URL operation. Where a handle is created on a stable URL (i.e. a version URL) there is no concept of a 'parent' resource. Clients require further contextual information to determine the 'parent' of a resource in these cases.

Returns:
the handle for the parent of this resource, or null.
Throws:
DAVException

getProperties

public URLTable getProperties(String depth)
                       throws DAVException
Return a URLTable which contains all of this resources properties to the given depth. The returned URLTable maps resource URLs to Hashtables which in turn maps property QualifiedNames to PropertyStatus.

Parameters:
depth - the depth of the request; for example, Context.DEPTH_ZERO.
Returns:
a URLTable containing properties.
Throws:
DAVException - if there was a problem retrieving the properties.
See Also:
getProperties(Collection, String)

getProperties

public URLTable getProperties(Collection propertyNames,
                              String depth)
                       throws DAVException
Fetches and returns the specified properties for this resource and its children to the given depth. The returned table is a URLTable of hashtables. The keys in the first table are the URLs of the resources. The nested table is a table where the keys are the names (QualifiedName) of the properties and the values are the properties' values (PropertyStatus).

Parameters:
propertyNames - collection of property names to search for (QualifiedName), or null to retrieve all properties.
depth - the depth of the search (eg. Context.DEPTH_INFINITY)
Returns:
URLTable of hashtables keyed by resource URLKey then by property name.
Throws:
DAVException - if there was a problem fetching the properties.
See Also:
IServer#propfind(Locator, Context, Document)

getProperty

public PropertyStatus getProperty(QualifiedName propertyName)
                           throws DAVException
Return the property status for the property with the given name.

Parameters:
propertyName - the name of the property
Returns:
the property status
Throws:
DAVException - if there was a problem getting the property
See Also:
getProperties(Collection, String)

getPropertyNames

public URLTable getPropertyNames(String depth)
                          throws DAVException
Fetch and return the property names for the resource, and the children resources to the specified depth. Returns URLTable mapping resource URLs to enumerations over the property names for that resource.

Parameters:
depth - eg. Context.DEPTH_ZERO
Returns:
a URLTable of Enumerations over QualfiedNames
Throws:
DAVException - if there was a problem getting the property names
See Also:
IServer#propfind(Locator, Context, Document)

getVersionTree

public URLTable getVersionTree()
                        throws DAVException
Retrieve the version tree infomration for the receiver, assuming that the receiver is a version or a version-controlled resource.

The version tree info comprises a URLTable whose keys are the URLs of each version in the version history, and whose values are Vectors of the resource's immediate predecessor URLs. Note that the root version is (uniquely) identified by an empty set of predecessors.

Returns:
the map from resource URL to predecessor set.
Throws:
DAVException

getWorkspaceCollections

public CollectionHandle[] getWorkspaceCollections()
                                           throws DAVException
Throws:
DAVException

head

public IContext head()
              throws DAVException
Return the header from a message send to the server.

Returns:
a context with the message header contents
Throws:
DAVException - if there was a problem sending the message
See Also:
IServer#head(Locator, Context)

isCollection

public boolean isCollection()
                     throws DAVException
Return a boolean value indicating whether or not this resource is a collection.

A resource is a collection (i.e., implements collection semantics) if it's resource type includes a <DAV:collection> element.

Returns:
boolean true if the resource implements collection semantics, and false otherwise.
Throws:
DAVException

isLocked

public boolean isLocked()
                 throws DAVException
Return a boolean value indicating whether or not this resource is currently locked.

Returns:
boolean indicator
Throws:
DAVException - if there was a problem getting the locks
See Also:
getLocks()

lock

public LockToken lock()
               throws DAVException
Lock this resource with default values.

Note: default values of DEPTH_ZERO for depth and -1 for timeout are used.

Returns:
the lock token
Throws:
DAVException - if there was a problem locking this resource
See Also:
lock(boolean, String, int, String)

lock

public LockToken lock(boolean isShared,
                      String depth,
                      int timeout,
                      String owner)
               throws DAVException
Lock this resource using the specified parameters.

Parameters:
isShared - true if the lock is shared, false if the lock is exclusive
depth - eg. Context.DEPTH_ZERO
timeout - the timeout value for the lock
owner - the owner of the lock
Returns:
the lock token
Throws:
DAVException - if there was a problem locking this resource
See Also:
IServer#lock(Locator, Context, Document)

move

public void move(ILocator destination)
          throws DAVException
Move this resource to the destination specified by the given locator. Use default values for overwrite and properties to move.

Parameters:
destination - the location to move this resource to
Throws:
DAVException - if there was a problem moving this resource
See Also:
#move(Locator, boolean, Enumeration)

move

public void move(ILocator destination,
                 boolean overwrite,
                 Enumeration names)
          throws DAVException
Move this resource to the location specified by the given locator. If a resource already exists at the destination and the overwrite boolean is true, then write over top of the existing resource. Otherwise do not. The enumeration is over qualified names which are the names of the properties to move.

Parameters:
destination - the location to move to
overwrite - how to react if a resource already exists at the destination
names - Enumeration over QualifiedNames
Throws:
DAVException - if there was a problem moving this resource
See Also:
IServer#move(Locator, Locator, Context, Document)

newContext

protected IContext newContext()
Answer a new empty context for requests sent to the receivers server.

Returns:
a new request Context.

newDocument

protected Document newDocument()
Answer a new empty DOM Document suitable for creating requests to the receiver's server.

Returns:
a new DOM Document.

protectedCheckIn

protected ILocator protectedCheckIn()
                             throws DAVException
Check in the receiver and answer a new Locator on the resulting version resource.

Returns:
the Locator to the receiver's version.
Throws:
DAVException - if a problem occurs with the check in request.

protectedCheckOut

protected ILocator protectedCheckOut()
                              throws DAVException
Check out the receiver and answer a new Locator on the resulting checked out resource. The result MAY be the same as the receiver's Locator if the server did not create a new resource as a consequence of the check out (i.e. if it was checking out a vesion-controlled resource rather than a version).

Returns:
the Locator to the receiver's version.
Throws:
DAVException - if a problem occurs with the check in request.

refreshLock

public void refreshLock(LockToken lockToken,
                        int timeout)
                 throws DAVException
Refresh the lock on this resource with the given lock token. Use the specified timeout value.

Parameters:
lockToken - the lock token to refresh
timeout - the new timeout value to use
Throws:
DAVException - if there was a problem refreshing the lock

removeProperties

public void removeProperties(Collection propertyNames)
                      throws DAVException
Remove the properties with the given names, from this resource.

Parameters:
propertyNames - Enumeration over QualifiedNames
Throws:
DAVException - if there was a problem removing the properties
See Also:
IServer#proppatch(Locator, Context, Document)

removeProperty

public void removeProperty(QualifiedName propertyName)
                    throws DAVException
Remove the property with the given name from this resource.

Parameters:
propertyName - the name of the property to remove
Throws:
DAVException - if there was a problem removing the property
See Also:
removeProperties(Collection)

setContent

public void setContent(InputStream input)
                throws DAVException
Set the content of this resource to be the untyped data stored in the given input stream. The stream will automatically be closed after the data is consumed. If the resource does not exist it is created with the given content.

Parameters:
input - the inputstream containing the resource contents.
Throws:
DAVException - if there was a problem setting the contents.
See Also:
setContent(String, InputStream), IServer#put(Locator, Context, InputStream)

setContent

public void setContent(String contentType,
                       InputStream input)
                throws DAVException
Set the content of this resource to be the data stored in the given input stream. The type encoding is given in the content type argument, and should be in the media format described by RFC2616 Sec 3.7. The stream will automatically be closed after the data is consumed. If the resource does not exist it is created with the given content.

Parameters:
contentType - the media type for the data on the input stream.
input - the inputstream containing the resource contents.
Throws:
DAVException - if there was a problem setting the contents.
See Also:
IServer#put(Locator, Context, InputStream)

setProperties

public void setProperties(Collection properties)
                   throws DAVException
Set the given properties on this resource.

Parameters:
properties - a Collection of property Elements.
Throws:
DAVException - if there was a problem setting the properties.
See Also:
IServer#proppatch(Locator, Context, Document)

setProperty

public void setProperty(Element property)
                 throws DAVException
Set the given property on this resource.

Parameters:
property - the property to set
Throws:
DAVException - if there was a problem setting the property
See Also:
setProperties(Collection)

toString

public String toString()
Return a string representation of this resource. Used for debugging purposes only.

Overrides:
toString in class Object
Returns:
this resource, as a string

trace

public ResponseInputStream trace()
                          throws DAVException
Send a message to the server. The contents of the resulting input stream should be the message that was sent, echoed back to the client.

The input stream should be closed by the user.

Returns:
an input stream on the request as received.
Throws:
DAVException - if there was a problem sending the request to the server.
See Also:
IServer#trace(Locator, Context)

unlock

public void unlock(LockToken token)
            throws DAVException
Unlock this resource with the given lock token.

Parameters:
token - the lock token to remove from this resource
Throws:
DAVException - if there was a problem unlocking this resource
See Also:
IServer#unlock(Locator, Context)

update

public void update(ILocator version)
            throws DAVException
Perform an UPDATE on the receiver to set the version it is based upon.

Parameters:
version - the Locator of the version that is the target of the update request.
Throws:
DAVException - if a problem occurs executing the update on the WebDAV server.

versionControl

public void versionControl()
                    throws DAVException
Bring the receiver under version control. This means that the receiver is replaced by a version-controlled resource. Note that the client may send version control to a resource that is already under version control with no adverse effects.

Throws:
DAVException - if a problem occurs bringing the resource under version control.

delete

public void delete(boolean mustExist)
            throws DAVException
Delete this resource from the repository, optionally succeeding in the delete if the resource was not found on the server.

Parameters:
mustExist - if true then the delete will fail if the resource was not on the server at the time of the delete request. If false the delete will succeed if there was no such resource to delete.
Throws:
DAVException - if there was a problem deleting this resource.
See Also:
IServer#delete(Locator, Context)

examineStatusCode

protected void examineStatusCode(int code,
                                 String message)
                          throws WebDAVException
Check the given status code and throw a WebDAV exception if the code indicates failure. If the code is success, this method does nothing.

Parameters:
code - the status code to check.
message - the status message accompanying the code.
Throws:
WebDAVException - if the server returned an HTTP/WebDAV error code (i.e., anything outside the 200-series codes).

exists

public boolean exists()
               throws DAVException
Return a boolean value indicating whether or not this resource exists on the server.

This implementation uses the HTTP HEAD method so the URL may or may not exist in the DAV namespace. The DAV RESOURCE_TYPE property is NOT checked.

Returns:
boolean true if the resource exists on the server or false otherwise.
Throws:
DAVException - if there was a problem checking for existence.

isCheckedIn

public boolean isCheckedIn()
                    throws DAVException
Check to see if the resource is checked in (i.e., is an immutable resource).

The resource is checked in if it has a <DAV:checked-in> property.

Returns:
true if the resource is checked in and false otherwise.
Throws:
DAVException - if a problem occurs determining the state of the resource.

isCheckedOut

public boolean isCheckedOut()
                     throws DAVException
Check to see if the resource is checked-out.

The resource is checked out if it has a <DAV:checked-out> property.

Returns:
true if the resource is checked out and false otherwise.
Throws:
DAVException - if a problem occurs determining the state of the resource.

isVersion

public boolean isVersion()
                  throws DAVException
Check to see if the resource is a version.

The resource is a version if it has <DAV:version-name> in the <DAV:supported-live-properties-set>.

Returns:
true if the resource is a version and false otherwise.
Throws:
DAVException - if a problem occurs determining the state of the resource.

isVersionControlled

public boolean isVersionControlled()
                            throws DAVException
Check to see if the resource is under version control.

The resource is version controlled if it has <DAV:auto-checkout> in the <DAV:supported-live-properties-set>.

Returns:
true if the resource is under version control and false otherwise.
Throws:
DAVException - if a problem occurs determining the state of the resource.

isWorkingResource

public boolean isWorkingResource()
                          throws DAVException
Check to see if the resource is a working resource.

The resource is a working resource if it has <DAV:checked-out> and does not have <DAV:auto-checkout> in the <DAV:supported-live-properties-set>.

Returns:
true if the resource is a working resource and false otherwise.
Throws:
DAVException - if a problem occurs determining the state of the resource.

propertyHasChild

protected boolean propertyHasChild(QualifiedName propertyName,
                                   QualifiedName childName)
                            throws DAVException
This is a helper method to check to see if the resource has a property with the given name that in turn has a child with a given name.

Returns:
true if the resource does have such a property with a named child and false if it does not have such a property or does not have such a child of the property.
Throws:
DAVException - if a problem occurs determining result from the server.

supportsLiveProperty

public boolean supportsLiveProperty(QualifiedName propertyName)
                             throws DAVException
Check to see if the resource supports the named live property.

Returns:
true if the resource does support the live property and false otherwise.
Throws:
DAVException - if a problem occurs determining result from the server.


Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.