org.eclipse.webdav.client.ResourceHandle Maven / Gradle / Ivy
Show all versions of org.guvnor.eclipse.webdav
package org.eclipse.webdav.client;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.webdav.ILocator;
import org.eclipse.webdav.internal.kernel.*;
/**
* The ResourceHandle
class represents an
* ordinary resource in the system. It subclasses AbstractResourceHandle
* and overrides some of its methods in order to provide specific behaviour for
* this resource type.
*
* Note: This class/interface is part of an interim API that is still under
* development and expected to change significantly before reaching stability.
* It is being made available at this early stage to solicit feedback from pioneering
* adopters on the understanding that any code that uses this API will almost
* certainly be broken (repeatedly) as the API evolves.
*
*/
public class ResourceHandle extends AbstractResourceHandle {
/**
* Creates a new ResourceHandle
from the given
* DAVClient
and Locator
.
*
* @param davClient
* @param locator
*/
public ResourceHandle(DAVClient davClient, ILocator locator) {
super(davClient, locator);
}
/**
* Check out this resource. Returns a resource handle on the checked out
* version selector, or the working resource if a version is checked out.
*/
public AbstractResourceHandle checkOut() throws DAVException {
ILocator locator = protectedCheckOut();
return new ResourceHandle(davClient, locator);
}
/**
* Persistently create this resource instance in the repository.
*
* Note that the usual method for creating an instance of a non-collection
* resource would be setContent(InputStream).
*
* @exception DAVException if there was a problem creating this resource
* @see AbstractResourceHandle#setContent(InputStream)
*/
public void create() throws DAVException {
setContent(new ByteArrayInputStream(new byte[0]));
}
/**
* Check to see if the resource is an activity resource.
*
* The resource is an activity resource if it has
* <DAV:subactivity-set> in the
* <DAV:supported-live-properties-set>.
*
* @return true
if the resource is an activity
* and false
otherwise.
* @throws DAVException if a problem occurs determining the state
* of the resource.
*/
public boolean isActivity() throws DAVException {
return supportsLiveProperty(DAV_SUBACTIVITY_SET);
}
/**
* Check to see if the resource is a baseline resource.
*
* The resource is a baseline resource if it has
* <DAV:baseline-collection> in the
* <DAV:supported-live-properties-set>.
*
* @return true
if the resource is a baseline
* and false
otherwise.
* @throws DAVException if a problem occurs determining the state
* of the resource.
*/
public boolean isBaseline() throws DAVException {
return supportsLiveProperty(DAV_BASELINE_COLLECTION);
}
/**
* Check to see if the resource is a version-controlled configuration
* resource.
*
* The resource is a version-controlled configuration resource if it has
* <DAV:baseline-controlled-collection> in the
* <DAV:supported-live-properties-set>.
*
* @return true
if the resource is a version-controlled
* configuration and false
otherwise.
* @throws DAVException if a problem occurs determining the state
* of the resource.
*/
public boolean isVersionControlledConfiguration() throws DAVException {
return supportsLiveProperty(DAV_BASELINE_CONTROLLED_COLLECTION);
}
/**
* Check to see if the resource is a version history resource.
*
* The resource is a version history resource if it has
* <DAV:root-version> in the
* <DAV:supported-live-properties-set>.
*
* @return true
if the resource is a version history
* and false
otherwise.
* @throws DAVException if a problem occurs determining the state
* of the resource.
*/
public boolean isVersionHistory() throws DAVException {
return supportsLiveProperty(DAV_ROOT_VERSION);
}
}