*** This class provides Binary Compatibility only, not Source Compatibility ***

Class DAVResource

java.lang.Object
com.sas.services.webdav.DAVResource
All Implemented Interfaces:
DAVResourceInterface, Remote

@SASScope("ALL") @BinaryCompatibilityOnly public class DAVResource extends Object implements DAVResourceInterface
A DAVResource represents a WebDAV (Web-based Distributed Authoring and Versioning) resource as specified in IETF RFC 2518. To create a DAVResource, use a ConnectionInfo object passed to the constructor. ConnectionInfo includes the URL of the resource (containing the host, port and path), user ID, password, proxy host, proxy port, proxy user ID, proxy password. The DAVResource object can then be manipulated using the various methods defined in the Resource interface. After any operation on a resource, check the status on the object using getStatusCode() and getStatusMessage(). For example,
 try
 {
     ConnectionInfo connectionInfo = new ConnectionInfo("http://http-server/path-to-resource",
                                                        "user",
                                                        "pwd");
     // proxy information, if required
     connectionInfo.setProxyHost("myproxy.com");
     connectionInfo.setProxyPort(3100);

     DAVResource davResource1 = new DAVResource(connectionInfo);
     int httpStatusCode = davResource1.getStatusCode();
     if (HttpStatus.SC_NOT_FOUND == httpStatusCode)
     {
         // DAV resource was not found
     }

     davResource1.setProperty(...);
     if (HttpStatus.SC_OK != davResource1.getStatusCode())
     {
         out.println(davResource1.getStatusMessage());
     }
 }
 catch (DAVException e)
 {
     // handle the exception
 }
 
In order to create a collection use the longer form of the constructor. For example,
 DAVResource davResource2 = new DAVResource(connectionInfo, true);
 int httpStatusCode = davResource2.getStatusCode();
 if (HttpStatus.SC_NOT_FOUND == httpStatusCode)
 {
     // DAV resource was not found
 }
 
This will ensure that davResource2 is a collection resource (it may contain other resources). Alternatively, do this in two steps
 DAVResource davResource2 = new DAVResource(connectionInfo);
 int httpStatusCode = davResource2.getStatusCode();
 if (HttpStatus.SC_NOT_FOUND == httpStatusCode)
 {
     // DAV resource was not found
 }
 davResource2.makeCollection();
 
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ConnectionInfo
    Connection information.
    static final int
     
    static final int
    The default port for HTTP is 80.
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a DAVResource using the connection information.
    DAVResource(ConnectionInfo cInfo, boolean createCollection)
     
    DAVResource(String url)
    Creates a DAVResource using a string URL.
    DAVResource(String url, boolean createCollection)
    Creates a DAVResource using a string URL and boolean flag to indicate whether a collection should be created.
    DAVResource(String url, String userName, String password)
    Creates a DAVResource using a string URL, userName and password.
    DAVResource(URL url)
    Creates a DAVResource using a Java URL.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the socket used for this connection.
    org.apache.http.entity.ContentType
    Gets the Apache HTTP entity content type of the content for this DAV resource.
    copy(String targetPath)
    Copies resource to the target destination.
    void
    Deletes this DAV resource.
    void
    Check in this DAV resource.
    void
    Checks out this DAV resource.
    void
    Puts the resource under version control.
    void
    doLabel(int labelAction, String label)
    Modifies the version label on the resource (if this is supported by the server).
    void
    doLabel(int labelAction, String label, int depth)
    Modifies the label on the version resource (if this is supported by the server).
    Properties
    Gets the options as Properties representing the header name/value pairs.
    doReport(org.apache.jackrabbit.webdav.version.report.ReportInfo reportInfo)
    Gets a report on the current DAV resource.
    doSearch(org.apache.jackrabbit.webdav.search.SearchInfo searchInfo)
    The SEARCH method invokes one of the implemented search grammars on the server to evaluate the query.
    void
    Uncheckout this DAV resource, canceling a previous checkout.
    boolean
    Returns whether the resource exists.
    static String
    extractPath(String url)
    Extract the path (query and fragment identifier from a URL).
    Acl
    Gets the access control list for this DAV resource.
    String
    Gets the access control list (ACL) for this DAV resource.
    String[]
    Returns a list of methods allowed on this resource.
    Version
    Retrieves the currently checked in resource.
    Version
    Retrieves the currently checked out resource.
    List<String>
    getChildrenList(String path)
    Gets the list of children.
    Map<String,PropertyMap>
    Get all the properties of a collection's members (depth=1) in as single server request.
    byte[]
    Gets the contents of this DAV resource as a byte array.
    void
    getContents(File fileData)
    Gets the content of this DAV resource into a file specified as the parameter.
    String
    Gets the contents of this DAV resource as a String.
    InputStream
    Gets the content of this DAV resource as a stream.
    String
    Gets the content type of the content for this DAV resource.
    String[]
    Returns a list of DAV capabilities.
    Gets all of the DAV resource's properties using the resource's depth.
    getDavProperties(int depth)
    Gets all of the DAV resource's properties for the specified depth.
    getDavProperties(PropertyName[] propertyNames)
    Gets all the properties for the specified property names on the DAV resource.
    getDavProperties(PropertyName[] propertyNames, int depth)
    Gets all the properties for the specified property names on the DAV resource.
    getDavProperties(org.apache.jackrabbit.webdav.property.DavPropertyNameSet davPropertyNameSet, int depth)
    Gets the properties for the specified DAV property names and search depth.
    Gets DAV properties for all of a DAV resource's property names.
    Gets DAV properties for all of a DAV resource's property names for the specified depth.
    int
    Gets the value for depth.
    int
    Gets the existence requirement.
    String
    getLock(String userName)
    Gets this DAV resource's lock token for the specified user.
    Map
    Returns the multiple status information for the last operation.
    boolean
    Gets the overwrite flag which specifies whether this DAV resource can be overwritten.
    String
    Gets the path for the WebDAV resource that is currently represented by this DAVResource.
    List
    Gets a list of previous version names for this DAV resource.
    Returns a property map of the resources properties.
    int
    Gets the HTTP status code for the last operation/method.
    String
    Gets the message associated with the status code for the last operation/method.
    String
    Returns the current setting for the directory for temporary files.
    URL
    Gets the URL that this DAV resource represents.
    Version
    getVersion(String versionName)
    Gets a particular version of this DAV resource.
    protected boolean
    Returns whether a password is required to connect to this server
    boolean
    Is this DAV resource a collection?
    boolean
    Is this DAV resource locked?
    String
    Locks this DAV resource.
    boolean
    Makes a collection.
    move(String targetPath)
    Moves this DAV resource to the location given in the parameter.
    void
    removeProperties(PropertyName[] propertyNames)
    Removes the properties specified in the parameter.
    void
    removeProperties(Element[] propNames)
    Removes the properties specified in the parameter.
    void
    Removes the property specified in the parameter.
    void
    removeProperty(String propName)
    Removes the property specified in the parameter.
    void
    removeProperty(Element propName)
    Removes the property specified in the parameter.
    String
    setAcl(Acl acl)
    Sets the access control list for this DAV resource.
    String
    setACL(String acl)
    Set/Update the Access Control List for this DAV resource.
    void
    setContents(byte[] contents)
    Sets the contents of the resource, passing in a byte array.
    void
    setContents(InputStream is)
    Sets the contents of the resource from an input stream.
    void
    setContents(String content)
    Sets the contents of the resource, passing in a URL.
    void
    setContents(URL url)
    Sets the contents of the resource, passing in a URL.
    void
    setContentType(String contentType)
    Sets the contents type for the content of the resource.
    void
    setCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
    Sets a credentials provider.
    void
    setDebug(int debug)
    Set the value for debug.
    void
    setDepth(int depth)
    Set the value for depth.
    void
    setExistsRequirement(int requirement)
    Sets the existence requirement.
    void
    setOverwrite(boolean overwrite)
    Sets the overwrite flag which specifies whether this DAV resource can be overwritten.
    void
    setPassword(String password)
    Set the value for password.
    void
    setPath(String path)
    Sets the path for this DAV resource.
    void
    setProperties(PropertyName[] propNames, String[] propValues)
    Sets the values of properties, as given in the parameter.
    void
    setProperties(DocumentFragment props)
    Sets the values of properties, as given in the parameter.
    void
    setProperties(Element[] elems)
    Sets the values of properties, as given in the parameter.
    void
    setProperty(PropertyName propName, String propValue)
    Sets the value of a property, as given in the parameter.
    void
    setProperty(Element prop)
    Sets the value of a property, as given in the parameter.
    void
    setTempDir(String tempDir)
    Provides a way to set a directory for temporary files.
    void
    setUserName(String userName)
    Set the value for userName.
    boolean
    Returns whether the last method was successful or not.
    protected static boolean
    SUCCEEDED(int statusCode)
    static String
    unencodePath(String path)
    Unencode the path.
    void
    Unlocks the resource, if previously locked by the same principal.
    void
    unlock(String lockToken)
    Unlocks the resource, with the correct locktoken.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DAVResource

      public DAVResource(String url) throws DAVException
      Creates a DAVResource using a string URL.

      Note that one should check the HTTP status code (e.g. HttpStatus.SC_NOT_FOUND) after invoking this constructor since a DAVException is not thrown for all exceptions.

      Parameters:
      url - URL for the resource.
      Throws:
      DAVException - if a DAV Server error occurs.
    • DAVResource

      public DAVResource(String url, String userName, String password) throws DAVException
      Creates a DAVResource using a string URL, userName and password.

      Note that one should check the HTTP status code (e.g. HttpStatus.SC_NOT_FOUND) after invoking this constructor since a DAVException is not thrown for all exceptions.

      Parameters:
      url - URL for the resource
      userName - authentication user name
      password - password for authentication
      Throws:
      DAVException - if a DAV Server error occurs.
    • DAVResource

      public DAVResource(URL url) throws DAVException
      Creates a DAVResource using a Java URL.

      Note that one should check the HTTP status code (e.g. HttpStatus.SC_NOT_FOUND) after invoking this constructor since a DAVException is not thrown for all exceptions.

      Parameters:
      url - URL for the resource
      Throws:
      DAVException - if a DAV Server error occurs.
    • DAVResource

      public DAVResource(String url, boolean createCollection) throws DAVException
      Creates a DAVResource using a string URL and boolean flag to indicate whether a collection should be created.

      Note that one should check the HTTP status code (e.g. HttpStatus.SC_NOT_FOUND) after invoking this constructor since a DAVException is not thrown for all exceptions.

      Parameters:
      url - URL for the resource
      createCollection - The URL indicates a collection resource
      Throws:
      DAVException - if a DAV Server error occurs.
    • DAVResource

      public DAVResource(ConnectionInfo cInfo) throws DAVException
      Creates a DAVResource using the connection information. For internal use only.

      Note that one should check the HTTP status code (e.g. HttpStatus.SC_NOT_FOUND) after invoking this constructor since a DAVException is not thrown for all exceptions.

      Parameters:
      cInfo - The connection information for the resource
      Throws:
      DAVException - if a DAV Server error occurs.
    • DAVResource

      public DAVResource(ConnectionInfo cInfo, boolean createCollection) throws DAVException
      Throws:
      DAVException
  • Method Details

    • setCredentialsProvider

      public void setCredentialsProvider(org.apache.http.client.CredentialsProvider credentialsProvider)
      Description copied from interface: DAVResourceInterface
      Sets a credentials provider. When authentication has failed, the credentials provider is called to provide a set of credentials for authentication. This allows an external agent to provide credentials when original credentials no longer work e.g. one-time passwords.
      Specified by:
      setCredentialsProvider in interface DAVResourceInterface
    • makeCollection

      public boolean makeCollection() throws DAVException
      Makes a collection. This method only works on a null resource (one that doesn't exist yet). One would normally call this method immediately after creating this DAVResource.
      Specified by:
      makeCollection in interface DAVResourceInterface
      Returns:
      boolean True is make collection successful, false otherwise.
      Throws:
      DAVException - in the case of a WebDAV error.
    • copy

      public DAVResource copy(String targetPath) throws DAVException, RemoteException
      Copies resource to the target destination.
      Specified by:
      copy in interface DAVResourceInterface
      Parameters:
      targetPath - location to which current resource is to be copied.
      Returns:
      If successful, then a new DAVResource representing the new destination is created and returned.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • delete

      public void delete() throws DAVException, RemoteException
      Deletes this DAV resource.
      Specified by:
      delete in interface DAVResourceInterface
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getLock

      public String getLock(String userName) throws DAVException
      Gets this DAV resource's lock token for the specified user.
      Parameters:
      userName - Name of the user whose lock token is desired for this DAV resource.
      Returns:
      Lock token or null if the specified user does not own the lock for this DAV resource.
      Throws:
      DAVException - if an error is encountered.
    • getContents

      public byte[] getContents() throws DAVException, RemoteException
      Gets the contents of this DAV resource as a byte array.
      Specified by:
      getContents in interface DAVResourceInterface
      Returns:
      byte[] The contents of the resource as a byte array
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getContentsAsString

      public String getContentsAsString() throws DAVException, RemoteException
      Gets the contents of this DAV resource as a String.
      Specified by:
      getContentsAsString in interface DAVResourceInterface
      Returns:
      String representation of the contents of this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getContents

      public void getContents(File fileData) throws DAVException, RemoteException
      Gets the content of this DAV resource into a file specified as the parameter.
      Specified by:
      getContents in interface DAVResourceInterface
      Parameters:
      fileData - The file into which the contents of the resource should be written.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getContentsInputStream

      public InputStream getContentsInputStream() throws DAVException, RemoteException
      Gets the content of this DAV resource as a stream.
      Specified by:
      getContentsInputStream in interface DAVResourceInterface
      Returns:
      InputStream The stream representing the content of the resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getContentType

      public String getContentType()
      Gets the content type of the content for this DAV resource.
      Specified by:
      getContentType in interface DAVResourceInterface
      Returns:
      String The content type for this DAV resource
      See Also:
    • contentType

      public org.apache.http.entity.ContentType contentType()
      Gets the Apache HTTP entity content type of the content for this DAV resource.
      Specified by:
      contentType in interface DAVResourceInterface
      Returns:
      Apache HTTP entity content type of the content for this DAV resource or null if no MIME type has been specified.
      See Also:
    • getDavProperties

      public DavPropertyResult getDavProperties() throws DAVException, RemoteException
      Gets all of the DAV resource's properties using the resource's depth.
      Specified by:
      getDavProperties in interface DAVResourceInterface
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
      See Also:
    • getDavProperties

      public DavPropertyResult getDavProperties(int depth) throws DAVException, RemoteException
      Gets all of the DAV resource's properties for the specified depth.
      Specified by:
      getDavProperties in interface DAVResourceInterface
      Parameters:
      depth - The depth on which DAV operations will be based. Specify one of DavConstants.DEPTH_0 or DavConstants.DEPTH_1 or DavConstants.DEPTH_INFINITY.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
      See Also:
    • getDavProperties

      public DavPropertyResult getDavProperties(PropertyName[] propertyNames) throws DAVException, RemoteException
      Gets all the properties for the specified property names on the DAV resource.
      Specified by:
      getDavProperties in interface DAVResourceInterface
      Parameters:
      propertyNames - Array of property names, specifying which properties should be returned.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
    • getDavProperties

      public DavPropertyResult getDavProperties(PropertyName[] propertyNames, int depth) throws DAVException, RemoteException
      Gets all the properties for the specified property names on the DAV resource.
      Specified by:
      getDavProperties in interface DAVResourceInterface
      Parameters:
      propertyNames - Array of property names, specifying which properties should be returned.
      depth - The depth on which DAV operations will be based. Specify one of DavConstants.DEPTH_0 or DavConstants.DEPTH_1 or DavConstants.DEPTH_INFINITY.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
    • getDavProperties

      public DavPropertyResult getDavProperties(org.apache.jackrabbit.webdav.property.DavPropertyNameSet davPropertyNameSet, int depth) throws DAVException, RemoteException
      Gets the properties for the specified DAV property names and search depth.
      Specified by:
      getDavProperties in interface DAVResourceInterface
      Parameters:
      davPropertyNameSet - Set of the names of the DAV properties which should be returned.
      depth - The depth on which DAV operations will be based. Specify one of DavConstants.DEPTH_0 or DavConstants.DEPTH_1 or DavConstants.DEPTH_INFINITY.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
    • getDavPropertyNames

      public DavPropertyResult getDavPropertyNames() throws DAVException, RemoteException
      Gets DAV properties for all of a DAV resource's property names.
      Specified by:
      getDavPropertyNames in interface DAVResourceInterface
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
      See Also:
    • getDavPropertyNames

      public DavPropertyResult getDavPropertyNames(int depth) throws DAVException, RemoteException
      Gets DAV properties for all of a DAV resource's property names for the specified depth.
      Specified by:
      getDavPropertyNames in interface DAVResourceInterface
      Parameters:
      depth -
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
      See Also:
    • getStatusCode

      public int getStatusCode() throws DAVException, RemoteException
      Gets the HTTP status code for the last operation/method.
      Specified by:
      getStatusCode in interface DAVResourceInterface
      Returns:
      The HTTP status code for the last request on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getStatusMessage

      public String getStatusMessage()
      Gets the message associated with the status code for the last operation/method.
      Specified by:
      getStatusMessage in interface DAVResourceInterface
      Returns:
      The status message for the last request on this DAV resource.
    • getURL

      public URL getURL() throws DAVException, RemoteException
      Gets the URL that this DAV resource represents.
      Specified by:
      getURL in interface DAVResourceInterface
      Returns:
      The URL for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • isCollection

      public boolean isCollection() throws DAVException, RemoteException
      Is this DAV resource a collection?
      Specified by:
      isCollection in interface DAVResourceInterface
      Returns:
      true if it is a collection, false otherwise.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • isLocked

      public boolean isLocked() throws DAVException, RemoteException
      Is this DAV resource locked?
      Specified by:
      isLocked in interface DAVResourceInterface
      Returns:
      true if it is locked, false otherwise.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • lock

      public String lock() throws DAVException, RemoteException
      Locks this DAV resource.
      Specified by:
      lock in interface DAVResourceInterface
      Returns:
      The lock token if the resource is successfully locked.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • move

      public DAVResource move(String targetPath) throws DAVException, RemoteException
      Moves this DAV resource to the location given in the parameter.
      Specified by:
      move in interface DAVResourceInterface
      Parameters:
      targetPath - The destination URL for this copy.
      Returns:
      A DAVResource that represents the new resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • removeProperties

      public void removeProperties(PropertyName[] propertyNames) throws DAVException, RemoteException
      Removes the properties specified in the parameter.
      Specified by:
      removeProperties in interface DAVResourceInterface
      Parameters:
      propertyNames - An array of property names that should be removed.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • removeProperties

      public void removeProperties(Element[] propNames) throws DAVException, RemoteException
      Removes the properties specified in the parameter.
      Specified by:
      removeProperties in interface DAVResourceInterface
      Parameters:
      propNames - An array of property names that should be removed.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • removeProperty

      public void removeProperty(Element propName) throws DAVException, RemoteException
      Removes the property specified in the parameter.
      Specified by:
      removeProperty in interface DAVResourceInterface
      Parameters:
      propName - The name of a property that should be removed from this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • removeProperty

      public void removeProperty(String propName) throws DAVException, RemoteException
      Removes the property specified in the parameter.
      Specified by:
      removeProperty in interface DAVResourceInterface
      Parameters:
      propName - The name of a property that should be removed from this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • removeProperty

      public void removeProperty(PropertyName propName) throws DAVException, RemoteException
      Removes the property specified in the parameter.
      Specified by:
      removeProperty in interface DAVResourceInterface
      Parameters:
      propName - The name of a property that should be removed from this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • doSearch

      public DavPropertyResult doSearch(org.apache.jackrabbit.webdav.search.SearchInfo searchInfo) throws DAVException, RemoteException
      The SEARCH method invokes one of the implemented search grammars on the server to evaluate the query.
      Specified by:
      doSearch in interface DAVResourceInterface
      Parameters:
      searchInfo - The search criteria.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property find method.
      Throws:
      DAVException - in the case of server failures.
      RemoteException - in the case of network failures.
    • setContents

      public void setContents(byte[] contents) throws DAVException, RemoteException
      Sets the contents of the resource, passing in a byte array.
      Specified by:
      setContents in interface DAVResourceInterface
      Parameters:
      contents - The byte array containing the content for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setContents

      public void setContents(URL url) throws DAVException, RemoteException
      Sets the contents of the resource, passing in a URL.
      Specified by:
      setContents in interface DAVResourceInterface
      Parameters:
      url - A URL that represents the content for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setContents

      public void setContents(String content) throws DAVException, RemoteException
      Sets the contents of the resource, passing in a URL.
      Specified by:
      setContents in interface DAVResourceInterface
      Parameters:
      content - The string containing the content for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setContents

      public void setContents(InputStream is) throws DAVException, RemoteException
      Sets the contents of the resource from an input stream. For remote deployment the InputStream should be wrapped in an InputStreamAdapter.
      Specified by:
      setContents in interface DAVResourceInterface
      Parameters:
      is - An input stream representing the content for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setContentType

      public void setContentType(String contentType) throws DAVException, RemoteException
      Sets the contents type for the content of the resource.
      Specified by:
      setContentType in interface DAVResourceInterface
      Parameters:
      contentType - The content type for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
      See Also:
    • setProperties

      public void setProperties(Element[] elems) throws DAVException, RemoteException
      Sets the values of properties, as given in the parameter.
      Specified by:
      setProperties in interface DAVResourceInterface
      Parameters:
      elems - An array of properties to be set on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setProperties

      public void setProperties(PropertyName[] propNames, String[] propValues) throws DAVException, RemoteException
      Sets the values of properties, as given in the parameter.
      Specified by:
      setProperties in interface DAVResourceInterface
      Parameters:
      propNames - An array of property names to be set on this DAV resource.
      propValues - An array of property values to be set on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setProperties

      public void setProperties(DocumentFragment props) throws DAVException, RemoteException
      Sets the values of properties, as given in the parameter.
      Specified by:
      setProperties in interface DAVResourceInterface
      Parameters:
      props - An XML document fragment that defines the properties to be set on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setProperty

      public void setProperty(PropertyName propName, String propValue) throws DAVException, RemoteException
      Sets the value of a property, as given in the parameter.
      Specified by:
      setProperty in interface DAVResourceInterface
      Parameters:
      propName - An property name to be set on this DAV resource.
      propValue - A property value to be set on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • setProperty

      public void setProperty(Element prop) throws DAVException, RemoteException
      Sets the value of a property, as given in the parameter.
      Specified by:
      setProperty in interface DAVResourceInterface
      Parameters:
      prop - An XML element that represents a property to be set on this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • unlock

      public void unlock() throws DAVException, RemoteException
      Unlocks the resource, if previously locked by the same principal.
      Specified by:
      unlock in interface DAVResourceInterface
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • unlock

      public void unlock(String lockToken) throws DAVException, RemoteException
      Unlocks the resource, with the correct locktoken.
      Specified by:
      unlock in interface DAVResourceInterface
      Parameters:
      lockToken - The lock token for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getOverwrite

      public boolean getOverwrite()
      Gets the overwrite flag which specifies whether this DAV resource can be overwritten.
      Specified by:
      getOverwrite in interface DAVResourceInterface
      Returns:
      true if the overwrite flag is set, false otherwise
    • setOverwrite

      public void setOverwrite(boolean overwrite)
      Sets the overwrite flag which specifies whether this DAV resource can be overwritten.
      Specified by:
      setOverwrite in interface DAVResourceInterface
      Parameters:
      overwrite - The value of the overwrite flag to set on the resource.
    • setUserName

      public void setUserName(String userName)
      Set the value for userName. Used in authentication requests to the server
      Parameters:
      userName - user name
    • setPassword

      public void setPassword(String password)
      Set the value for password. Used in authentication requests to the server
      Parameters:
      password - password
    • setDebug

      public void setDebug(int debug)
      Set the value for debug.
      Parameters:
      debug - The debug setting
    • setDepth

      public void setDepth(int depth) throws DAVException, RemoteException
      Set the value for depth. This is the depth on which DAV operations will be based. They can be one of three values:
      • DavConstants.DEPTH_0
      • DavConstants.DEPTH_1
      • DavConstants.DEPTH_INFINITY
      Specified by:
      setDepth in interface DAVResourceInterface
      Parameters:
      depth - The depth on which DAV operations will be based. Specify one of DavConstants.DEPTH_0 or DavConstants.DEPTH_1 or DavConstants.DEPTH_INFINITY.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
    • getDepth

      public int getDepth()
      Gets the value for depth. This is the depth on which DAV operations will be based. They can be one of three values:
      • DavConstants.DEPTH_0
      • DavConstants.DEPTH_1
      • DavConstants.DEPTH_INFINITY
      Specified by:
      getDepth in interface DAVResourceInterface
      Returns:
      The depth on which DAV operations will be based.
    • doOptions

      public Properties doOptions() throws DAVException, RemoteException
      Gets the options as Properties representing the header name/value pairs. The DAV status, allowedMethods and davCapabilities are also updated.
      Returns:
      Properties keyed by a header name to its value.
      Throws:
      DAVException - if unable to get the DAV options.
      RemoteException - if a communications-related exception occurs.
    • getAllowedMethods

      public String[] getAllowedMethods()
      Returns a list of methods allowed on this resource.
      Returns:
      String[] - list of methods allowed on this resource
    • getDavCapabilities

      public String[] getDavCapabilities()
      Returns a list of DAV capabilities. The DAV header provides information on what DAV functions are supported by the server. Basic DAV support requires the DAV header and a value of "1", but support for locking features would have a value "1,2" for the DAV header. Further capabilities will be added in the future (e.g. access-control). The DAV header is a comma delimited list of capabilities, returned as items in a string array.
      Returns:
      String[] - DAV capabilities supported by the server
    • isAuthReqd

      protected boolean isAuthReqd()
      Returns whether a password is required to connect to this server
      Returns:
      boolean - true if authentication credentials are required for a connection, false otherwise
    • SUCCEEDED

      public boolean SUCCEEDED() throws RemoteException
      Returns whether the last method was successful or not. The HTTP status codes in the range 200-299 are successful. All others indicate some sort of unsuccessful attempt.
      Specified by:
      SUCCEEDED in interface DAVResourceInterface
      Returns:
      true if last method was successful, false otherwise.
      Throws:
      RemoteException - in the case of network failures.
    • SUCCEEDED

      protected static boolean SUCCEEDED(int statusCode)
    • getMultiStatus

      public Map getMultiStatus()
      Returns the multiple status information for the last operation.
      Returns:
      Map (href to propstat) Multistatus response from the last DAV method.
    • close

      public void close() throws RemoteException
      Closes the socket used for this connection. This can be useful for servers that have a limit on the number of connections (e.g. IIS), and provides a way to control network resources.
      Specified by:
      close in interface DAVResourceInterface
      Throws:
      RemoteException - in the event of network failure.
    • setTempDir

      public void setTempDir(String tempDir) throws RemoteException
      Provides a way to set a directory for temporary files. The java.io.tmp system property can be used to set this value at JVM invocation. If the system property is not set "/temp/" is the default, but can be overridden with this method.
      Specified by:
      setTempDir in interface DAVResourceInterface
      Parameters:
      tempDir - Temporary directory for temporary files.
      Throws:
      RemoteException - in the event of network failure.
    • getTempDir

      public String getTempDir() throws RemoteException
      Returns the current setting for the directory for temporary files.
      Specified by:
      getTempDir in interface DAVResourceInterface
      Returns:
      The temporary directory for temporary files.
      Throws:
      RemoteException - in the event of network failure.
    • exists

      public boolean exists() throws RemoteException
      Returns whether the resource exists.
      Specified by:
      exists in interface DAVResourceInterface
      Returns:
      true if resource exists, false otherwise.
      Throws:
      RemoteException - in the event of network failure.
    • doReport

      public DavPropertyResult doReport(org.apache.jackrabbit.webdav.version.report.ReportInfo reportInfo) throws DAVException
      Gets a report on the current DAV resource. The ReportInfo parameter specifies the following information.
      • report type
      • depth
      • property names
      Specified by:
      doReport in interface DAVResourceInterface
      Parameters:
      reportInfo - Information which specifies the desired report.
      Returns:
      DavPropertyResult which has the DAV properties which were returned by the property report method.
      Throws:
      DAVException - in the case of server failures.
    • getACL

      public String getACL() throws DAVException, RemoteException
      Gets the access control list (ACL) for this DAV resource.
      Specified by:
      getACL in interface DAVResourceInterface
      Returns:
      String An XML serialized document describing the ACL for this DAV resource.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
      See Also:
    • getAcl

      public Acl getAcl() throws DAVException, RemoteException
      Gets the access control list for this DAV resource.
      Specified by:
      getAcl in interface DAVResourceInterface
      Returns:
      The access control list for this DAV resource.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
      See Also:
    • setACL

      public String setACL(String acl) throws DAVException, RemoteException
      Set/Update the Access Control List for this DAV resource.
      Specified by:
      setACL in interface DAVResourceInterface
      Parameters:
      acl - An XML serialized document describing the ACL for this DAV resource.
      Returns:
      Document The result document from the ACL method or null if there was no response document.
      Throws:
      DAVException - in the event of a WebDAV failure.
      RemoteException - in the event of network failure.
      See Also:
    • setAcl

      public String setAcl(Acl acl) throws DAVException, RemoteException
      Sets the access control list for this DAV resource.
      Specified by:
      setAcl in interface DAVResourceInterface
      Parameters:
      acl - The access control list to set for this DAV resource.
      Returns:
      The string representation of the access control list or null if there was no response document.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
      See Also:
    • setPath

      public void setPath(String path)
      Sets the path for this DAV resource. If the resource was originally created as http://server/origpath, then calling this method will change the resource path to http://server/path. This allows the same DAVResource object to be used for any WebDAV resource.
      Specified by:
      setPath in interface DAVResourceInterface
      Parameters:
      path - The new path for the WebDAV resource.
    • getPath

      public String getPath()
      Gets the path for the WebDAV resource that is currently represented by this DAVResource.
      Specified by:
      getPath in interface DAVResourceInterface
      Returns:
      The current path for this DAV resource.
    • doControl

      public void doControl() throws DAVException, RemoteException
      Puts the resource under version control.
      Specified by:
      doControl in interface DAVResourceInterface
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • getPreviousVersionNames

      public List getPreviousVersionNames() throws DAVException, RemoteException
      Gets a list of previous version names for this DAV resource.
      Specified by:
      getPreviousVersionNames in interface DAVResourceInterface
      Returns:
      List(String) The version names for this DAV resource.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • doCheckout

      public void doCheckout() throws DAVException, RemoteException
      Checks out this DAV resource.
      Specified by:
      doCheckout in interface DAVResourceInterface
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • doLabel

      public void doLabel(int labelAction, String label) throws DAVException, RemoteException
      Modifies the version label on the resource (if this is supported by the server).
      Specified by:
      doLabel in interface DAVResourceInterface
      Parameters:
      labelAction - Specifies the action which is to be executed.
      • LabelInfo#TYPE_SET
      • LabelInfo#TYPE_REMOVE
      • LabelInfo#TYPE_ADD
      label - The value of the label.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
      See Also:
    • doLabel

      public void doLabel(int labelAction, String label, int depth) throws DAVException, RemoteException
      Modifies the label on the version resource (if this is supported by the server).
      Specified by:
      doLabel in interface DAVResourceInterface
      Parameters:
      labelAction - Specifies the action which is to be executed.
      • LabelInfo#TYPE_SET
      • LabelInfo#TYPE_REMOVE
      • LabelInfo#TYPE_ADD
      label - The value of the label.
      depth - The depth.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
      See Also:
    • doCheckin

      public void doCheckin() throws DAVException, RemoteException
      Check in this DAV resource.
      Specified by:
      doCheckin in interface DAVResourceInterface
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • doUncheckout

      public void doUncheckout() throws DAVException, RemoteException
      Uncheckout this DAV resource, canceling a previous checkout.
      Specified by:
      doUncheckout in interface DAVResourceInterface
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • getCheckedIn

      public Version getCheckedIn() throws DAVException, RemoteException
      Retrieves the currently checked in resource.
      Specified by:
      getCheckedIn in interface DAVResourceInterface
      Returns:
      Version An object describing the version that is checked in.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • getCheckedOut

      public Version getCheckedOut() throws DAVException, RemoteException
      Retrieves the currently checked out resource.
      Specified by:
      getCheckedOut in interface DAVResourceInterface
      Returns:
      Version An object describing the version that is checked out.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of network failures.
    • getVersion

      public Version getVersion(String versionName) throws DAVException
      Gets a particular version of this DAV resource.
      Specified by:
      getVersion in interface DAVResourceInterface
      Parameters:
      versionName - Which version to retrieve for this DAV resource.
      Returns:
      Version An object describing the version of this DAV resource.
      Throws:
      DAVException - in the case of a WebDAV error.
    • setExistsRequirement

      public void setExistsRequirement(int requirement)
      Sets the existence requirement.
      Specified by:
      setExistsRequirement in interface DAVResourceInterface
      Parameters:
      requirement - 0 if we don't care or 1 if it must exist or 2 if it must not exist.
    • getExistsRequirement

      public int getExistsRequirement()
      Gets the existence requirement.
      Specified by:
      getExistsRequirement in interface DAVResourceInterface
      Returns:
      0 if we don't care or 1 if it must exist or 2 if it must not exist.
    • getChildrenList

      public List<String> getChildrenList(String path)
      Gets the list of children. If this is not a collection, or is an empty collection the returned list will be empty. Otherwise, it will contain the path for each child in the collection.
      Specified by:
      getChildrenList in interface DAVResourceInterface
      Parameters:
      path - The path of this DAV resource.
      Returns:
      List (of String) The paths for the children.
    • getChildrenProperties

      public Map<String,PropertyMap> getChildrenProperties(PropertyName[] properties) throws DAVException, RemoteException
      Get all the properties of a collection's members (depth=1) in as single server request. This does not bind to each one of the items in the collection and is a quick way to find out what items are in the collection without fetching each one.
      Returns:
      Map (maps String representation of a URL to (Map of String property name to its String value)) which is the property map for all the items in this collection.
      Throws:
      DAVException - in the case of a WebDAV error.
      RemoteException - in the case of a network error.
    • extractPath

      public static String extractPath(String url)
      Extract the path (query and fragment identifier from a URL). This method does not use the URL/URI classes and simply scans for the right location of the beginning of the path.
      Parameters:
      url - The URL from which the path should be extracted
      Returns:
      String Everything after the beginning of the path in the supplied URL.
    • unencodePath

      public static String unencodePath(String path)
      Unencode the path.
      Parameters:
      path - The URL from which the path should be extracted.
      Returns:
      String Everything after the beginning of the path in the supplied URL.
    • getPropertyMap

      public PropertyMap getPropertyMap() throws RemoteException, DAVException
      Returns a property map of the resources properties.
      Returns:
      PropertyMap A map containing the properties for this resource
      Throws:
      DAVException - in the event of WebDAV errors
      RemoteException - in the case of network errors