be.re.webdav
Class Client

java.lang.Object
  extended by be.re.webdav.Client

public class Client
extends Object

A client API for accessing a WebDAV server.

Author:
Werner Donné

Nested Class Summary
static class Client.ACE
          Represents one Access Control Entry in an Access Control List.
static interface Client.AuditTrail
          An interface to handle a stream of audit trail events.
static class Client.Event
          Represents one event line in an audit trail.
static class Client.Lock
          Represents a lock.
static class Client.Options
          Contains the result of an options request.
static class Client.Response
          Contains the response of a WebDAV operation.
 
Constructor Summary
Client()
          Calls the full constructor with all parameters set to null.
Client(String username, Object context)
          This is the constructor for local WebDAV-calls from Pincette modules.
Client(String username, String password)
          Calls the full constructor with the other parameters set to null.
Client(String username, String password, String onBehalfOf)
          Calls the full constructor with the other parameters set to null.
Client(String username, String password, String onBehalfOf, Locale locale, String userAgent)
           
 
Method Summary
 void acl(URL url, Client.ACE[] aces)
          Sets the Access Control List for the resource.
 void addLabel(URL url, String label)
          Adds a label to the resource.
 Client.Response addLabel(URL url, String label, String selectionLabel, String depth)
          Adds a label to the resource.
 Client.Response addLabel(URL url, String label, String selectionLabel, String depth, String lockToken)
          Adds a label to the resource.
 void audit(URL url, String path, String[] operations, String username, long before, long after, String additionalInfo, Client.AuditTrail handler)
          Returns the audit trail for a given resource.
 void bind(URL url, URL newBinding, boolean overwrite)
          Creates an additional binding to an existing resource.
 void bind(URL url, URL newBinding, boolean overwrite, String lockToken)
          Creates an additional binding to an existing resource.
 String checkin(URL url)
          Checks in a resource.
 String checkin(URL url, boolean keepCheckedOut, boolean forkOK)
          Checks in a resource.
 String checkin(URL url, boolean keepCheckedOut, boolean forkOK, String lockToken)
          Checks in a resource.
 void checkout(URL url)
          Checks out a resource.
 void checkout(URL url, URL activity, boolean forkOK)
          Checks out a resource.
 void checkout(URL url, URL activity, boolean forkOK, String lockToken)
          Checks out a resource.
 void collapse(URL url, boolean noVersionControl, String depth)
           
 Client.Response copy(URL from, URL to, String label, boolean overwrite, String depth)
          Copies the resource denoted by from to the resource denoted by to.
 void delete(URL url)
          Deletes a resource.
 void delete(URL url, String lockToken)
          Deletes a resource.
 Client.Response get(URL url)
          Returns a resource.
 Client.Response get(URL url, String[] preferredMimeTypes, String[] preferredLanguages, String label)
          Returns a resource.
 Client.Response get(URL url, String[] preferredMimeTypes, String[] preferredLanguages, String label, long modifiedSince)
          Returns a resource.
 Client.Response get(URL url, String[] preferredMimeTypes, String[] preferredLanguages, String label, URL compareWith)
          Returns a resource.
 Client.ACE[] getAcl(URL url)
          Returns the Access Control List of a resource.
 URL[] getActivityCollections(URL url)
          Returns the resource collections in the repository denoted by url that contain activities.
 Locale getLocale()
          Returns the default locale that will be assigned to the Accept-Language header if it is not yet present.
 Client.Lock[] getLocks(URL url)
          Returns all the locks of a resource.
 String[] getLockTokens(URL url)
          Returns all the lock tokens of a resource.
 URL[] getMetaCollections(URL url)
          Returns the resource collections in the repository denoted by url that contain functional meta collections.
 String getOnBehalfOf()
          Returns the default value for the X-be.re.On-Behalf-Of header.
 String getPassword()
          Return the default password for basic HTTP authentication.
 URL[] getPrincipalCollections(URL url)
          Returns the resource collections in the repository denoted by url that contain principals.
 String getSimpleLiveProperty(URL url, ExpandedName property)
          Returns the value of a live property as a string if it has either one empty element as a value, in which case the local name of the element is the value, or only PCDATA, otherwise null is returned.
 String getSimpleLiveProperty(URL url, String property)
          Returns the value of a live property in the DAV: namespace as a string if it has one empty element as a value, in which case the local name of the element is the value, or only PCDATA, otherwise null is returned.
 ExpandedName[] getSupportedLiveProperties(URL url)
          Returns all the live properties supported by the resource.
 String getUserAgent()
          Returns the default value for the User-Agent header.
 String getUsername()
          Returns the default username for basic HTTP authentication.
 URL[] getVersionHistoryCollections(URL url)
          Returns the resource collections in the repository denoted by url that contain version histories.
 URL[] getViewCollections(URL url)
          Returns the resource collections in the repository denoted by url that contain views.
 Headers head(URL url)
          Returns the headers of a resource.
 void index(URL url, String depth, boolean withPreview)
          This is an administration method that reindexes a WebDAV-collection in Pincette.
 String lock(URL url, long timeoutSeconds)
          Locks a resource.
 String lock(URL url, long timeoutSeconds, String lockToken)
          Locks a resource.
 Client.Response merge(URL url, URL[] sources, String label, boolean autoMerge, boolean checkOut, URL checkOutActivity, boolean forkOK)
          Merges a number of resources into another one.
 void mkactivity(URL url)
          Creates an activity.
 void mkcol(URL url)
          Creates a resource collection.
 void mkview(URL url)
          Creates a view.
 void move(URL from, URL to, boolean overwrite)
          Moves one resource to another.
 void move(URL from, URL to, boolean overwrite, String lockToken)
          Moves one resource to another.
 Client.Response operation(String method, URL url, Headers headersIn, InputStream body)
          The low-level method that communicates with the server.
 Client.Options options(URL url, boolean activityCollections, boolean metaCollections, boolean versionHistoryCollections, boolean viewCollections)
          Returns the options for a resource.
 Client.Response propfindAll(URL url, String depth)
          Returns all the properties of a resource.
 ExpandedName[] propfindNames(URL url)
          Returns all the property names of a resource.
 Client.Response propfindNames(URL url, String depth)
          Returns all the property names of a resource.
 Client.Response propfindSpecific(URL url, ExpandedName[] properties, String depth)
          Returns the requested properties of a resource.
 Client.Response proppatch(URL url, Document document)
          Changes properties of the resource.
 Client.Response proppatch(URL url, Document document, String lockToken)
          Changes properties of the resource.
 Client.Response proppatch(URL url, InputStream in)
          Changes properties of the resource.
 Client.Response proppatch(URL url, InputStream in, String lockToken)
          Changes properties of the resource.
 Client.Response put(URL url, InputStream in, String mimeType, String language)
          Creates or updates a resource.
 Client.Response put(URL url, InputStream in, String mimeType, String language, String lockToken)
          Creates or updates a resource.
 void rebind(URL url, URL newBinding, boolean overwrite)
          Replaces a binding to an existing resource.
 void rebind(URL url, URL newBinding, boolean overwrite, String lockToken)
          Replaces a binding to an existing resource.
 void removeLabel(URL url, String label)
          Removes a label from the resource.
 Client.Response removeLabel(URL url, String label, String selectionLabel, String depth)
          Removes a label from the resource.
 Client.Response removeLabel(URL url, String label, String selectionLabel, String depth, String lockToken)
          Removes a label from the resource.
 Client.Response report(URL url, Document document, String label, String depth)
          This is a variant of the other report method.
 Client.Response report(URL url, InputStream in, String label, String depth)
          With this method more complex information can be retrieved about a resource.
 void setLabel(URL url, String label)
          Sets a label on the resource.
 Client.Response setLabel(URL url, String label, String selectionLabel, String depth)
          Sets a label on the resource.
 Client.Response setLabel(URL url, String label, String selectionLabel, String depth, String lockToken)
          Sets a label on the resource.
 void setLocale(Locale value)
          Sets the default locale that will be assigned to the Accept-Language header if it is not yet present.
 void setOnBehalfOf(String value)
          Sets the X-be.re.On-Behalf-Of header.
 void setPassword(String value)
          Sets the default password for basic HTTP authentication.
 void setSimpleLiveProperty(URL url, ExpandedName property, String value)
          Sets the value of a simple live property.
 void setSimpleLiveProperty(URL url, ExpandedName property, String value, String lockToken)
          Sets the value of a simple live property.
 void setSimpleLiveProperty(URL url, String property, String value)
          Sets the value of a simple live property.
 void setSimpleLiveProperty(URL url, String property, String value, String lockToken)
          Sets the value of a simple live property.
 void setUserAgent(String userAgent)
          Sets the default value for the User-Agent header.
 void setUsername(String value)
          Sets the default username for basic HTTP authentication.
 void unbind(URL url)
          Removes a binding to a resource.
 void unbind(URL url, String lockToken)
          Removes a binding to a resource.
 void uncheckout(URL url)
          Reverts the check-out of a resource.
 void uncheckout(URL url, String lockToken)
          Reverts the check-out of a resource.
 void unlock(URL url, String lockToken)
          Unlocks a resource.
 void versionControl(URL url)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client

public Client()
Calls the full constructor with all parameters set to null.


Client

public Client(String username,
              String password)
Calls the full constructor with the other parameters set to null.


Client

public Client(String username,
              String password,
              String onBehalfOf)
Calls the full constructor with the other parameters set to null.


Client

public Client(String username,
              String password,
              String onBehalfOf,
              Locale locale,
              String userAgent)
Parameters:
username - if set it will be used for basic HTTP authentication.
password - if set it will be used for basic HTTP authentication.
onBehalfOf - if set it will be used as the value for the X-be.re.On-Behalf-Of header. This feature is specific for Pincette, where the system user honours the header to perform an operation on behalf of another user. This makes it possible to use Pincette as a resource in an application, in the same way database systems can be used for example.
locale - the default locale that will be assigned to the Accept-Language header if it is not yet present.
userAgent - if set it will override the User-Agent header.

Client

public Client(String username,
              Object context)
This is the constructor for local WebDAV-calls from Pincette modules.

Parameters:
username - the user as who the call is performed.
context - the WebDAV-context.
Method Detail

acl

public void acl(URL url,
                Client.ACE[] aces)
         throws IOException,
                be.re.net.ProtocolException
Sets the Access Control List for the resource. The Access Control Entries are saved in the order they are provided.

Parameters:
url - the resource.
aces - the Access Control Entries.
Throws:
IOException
be.re.net.ProtocolException

addLabel

public void addLabel(URL url,
                     String label)
              throws IOException,
                     be.re.net.ProtocolException
Adds a label to the resource. The resource should be checked in. The same label on other versions of the resource will remain.

Parameters:
url - the resource.
label - the label that is to be added.
Throws:
IOException
be.re.net.ProtocolException

addLabel

public Client.Response addLabel(URL url,
                                String label,
                                String selectionLabel,
                                String depth)
                         throws IOException,
                                be.re.net.ProtocolException
Adds a label to the resource. The resource should be checked in. The same label on other versions of the resource will remain.

Parameters:
url - the resource.
label - the label that is to be added.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

addLabel

public Client.Response addLabel(URL url,
                                String label,
                                String selectionLabel,
                                String depth,
                                String lockToken)
                         throws IOException,
                                be.re.net.ProtocolException
Adds a label to the resource. The resource should be checked in.

Parameters:
url - the resource.
label - the label that is to be added.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

audit

public void audit(URL url,
                  String path,
                  String[] operations,
                  String username,
                  long before,
                  long after,
                  String additionalInfo,
                  Client.AuditTrail handler)
           throws IOException,
                  be.re.net.ProtocolException
Returns the audit trail for a given resource. This method is specific for Pincette.

Parameters:
url - the repository URL.
path - the absolute path of a resource within the repository. The wildcard * is allowed. It may be null.
operations - limits the audit trail to events with the given operations. Operations are defined in Constants.EVENT_*. It may be null.
username - limits the audit trail to events involving the given user. It may be null.
before - limits the audit trail to events before the given timestamp in milliseconds since 1 January 1970 UTC. It may be -1.
after - limits the audit trail to events after the given timestamp in milliseconds since 1 January 1970 UTC. It may be -1.
additionalInfo - limits the audit trail to events having the given additional information. The wildcard * is allowed. It may be null.
handler - an interface to which the events are passed one by one.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Constants

bind

public void bind(URL url,
                 URL newBinding,
                 boolean overwrite)
          throws IOException,
                 be.re.net.ProtocolException
Creates an additional binding to an existing resource. Afterwards both URLs denote the same resource.

Parameters:
url - the existing resource
newBinding - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by newBinding, then overwrite it.
Throws:
IOException
be.re.net.ProtocolException

bind

public void bind(URL url,
                 URL newBinding,
                 boolean overwrite,
                 String lockToken)
          throws IOException,
                 be.re.net.ProtocolException
Creates an additional binding to an existing resource. Afterwards both URLs denote the same resource.

Parameters:
url - the existing resource
newBinding - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by newBinding, then overwrite it.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

checkin

public String checkin(URL url)
               throws IOException,
                      be.re.net.ProtocolException
Checks in a resource. The parameters keepCheckedOut and forkOK are set to false and lockToken is set to null.

Parameters:
url - the resource.
Returns:
The newly created version.
Throws:
IOException
be.re.net.ProtocolException

checkin

public String checkin(URL url,
                      boolean keepCheckedOut,
                      boolean forkOK)
               throws IOException,
                      be.re.net.ProtocolException
Checks in a resource.

Parameters:
url - the resource.
keepCheckedOut - will automatically check out the resource after the check-in.
forkOK - when set to true forking a line of descent is allowed.
Returns:
The newly created version.
Throws:
IOException
be.re.net.ProtocolException

checkin

public String checkin(URL url,
                      boolean keepCheckedOut,
                      boolean forkOK,
                      String lockToken)
               throws IOException,
                      be.re.net.ProtocolException
Checks in a resource.

Parameters:
url - the resource.
keepCheckedOut - will automatically check out the resource after the check-in.
forkOK - when set to true forking a line of descent is allowed.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The newly created version.
Throws:
IOException
be.re.net.ProtocolException

checkout

public void checkout(URL url)
              throws IOException,
                     be.re.net.ProtocolException
Checks out a resource. The activity parameter is set to null, forkOK to false and lockToken to null.

Parameters:
url - the resource.
Throws:
IOException
be.re.net.ProtocolException

checkout

public void checkout(URL url,
                     URL activity,
                     boolean forkOK)
              throws IOException,
                     be.re.net.ProtocolException
Checks out a resource.

Parameters:
url - the resource.
activity - the activity in which the resource should be checked out.
forkOK - when set to true forking a line of descent is allowed.
Throws:
IOException
be.re.net.ProtocolException

checkout

public void checkout(URL url,
                     URL activity,
                     boolean forkOK,
                     String lockToken)
              throws IOException,
                     be.re.net.ProtocolException
Checks out a resource.

Parameters:
url - the resource.
activity - the activity in which the resource should be checked out.
forkOK - when set to true forking a line of descent is allowed.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

collapse

public void collapse(URL url,
                     boolean noVersionControl,
                     String depth)
              throws IOException,
                     be.re.net.ProtocolException
Throws:
IOException
be.re.net.ProtocolException

copy

public Client.Response copy(URL from,
                            URL to,
                            String label,
                            boolean overwrite,
                            String depth)
                     throws IOException,
                            be.re.net.ProtocolException
Copies the resource denoted by from to the resource denoted by to.

Parameters:
from - the resource that is to be copied.
to - the resource that is to be copied to.
label - an optional label that overrides the default version selection. The version carrying label will be the subject of the operation.
overwrite - if set the target will be overwritten if it already exists.
depth - the scope of the copy operation. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status codes 201 and 204 indicate success. See section 9.8.5 of RFC 4918 for the complete specification of the status codes.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

delete

public void delete(URL url)
            throws IOException,
                   be.re.net.ProtocolException
Deletes a resource.

Parameters:
url - the resource.
Throws:
IOException
be.re.net.ProtocolException

delete

public void delete(URL url,
                   String lockToken)
            throws IOException,
                   be.re.net.ProtocolException
Deletes a resource.

Parameters:
url - the resource.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

get

public Client.Response get(URL url)
                    throws IOException,
                           be.re.net.ProtocolException
Returns a resource.

Parameters:
url - the URL of the resource to get. It should be either a version controlled resource or a version resource.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

get

public Client.Response get(URL url,
                           String[] preferredMimeTypes,
                           String[] preferredLanguages,
                           String label)
                    throws IOException,
                           be.re.net.ProtocolException
Returns a resource.

Parameters:
url - the URL of the resource to get. It should be either a version controlled resource or a version resource.
preferredMimeTypes - the MIME types in which form the result is desired, ordered from most to least preferred. It may be null or empty.
preferredLanguages - the languages in which form the result is desired, ordered from most to least preferred. It may be null or empty.
label - an optional label that overrides the default version selection. The version carrying label will be the subject of the operation.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

get

public Client.Response get(URL url,
                           String[] preferredMimeTypes,
                           String[] preferredLanguages,
                           String label,
                           URL compareWith)
                    throws IOException,
                           be.re.net.ProtocolException
Returns a resource.

Parameters:
url - the URL of the resource to get. It should be either a version controlled resource or a version resource.
preferredMimeTypes - the MIME types in which form the result is desired, ordered from most to least preferred. It may be null or empty.
preferredLanguages - the languages in which form the result is desired, ordered from most to least preferred. It may be null or empty.
label - an optional label that overrides the default version selection. The version carrying label will be the subject of the operation.
compareWith - a version of the same version controlled resource. It may be null. This parameter is specific for Pincette.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

get

public Client.Response get(URL url,
                           String[] preferredMimeTypes,
                           String[] preferredLanguages,
                           String label,
                           long modifiedSince)
                    throws IOException,
                           be.re.net.ProtocolException
Returns a resource.

Parameters:
url - the URL of the resource to get. It should be either a version controlled resource or a version resource.
preferredMimeTypes - the MIME types in which form the result is desired, ordered from most to least preferred. It may be null or empty.
preferredLanguages - the languages in which form the result is desired, ordered from most to least preferred. It may be null or empty.
label - an optional label that overrides the default version selection. The version carrying label will be the subject of the operation.
modifiedSince - the timestamp in milliseconds since 1 January 1970 UTC. It may be -1 if an unconditional GET is desired. Otherwise the resource is only returned if it has changed since the given timestamp. If it hasn't, the status code is set to 304.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

getAcl

public Client.ACE[] getAcl(URL url)
                    throws IOException,
                           be.re.net.ProtocolException
Returns the Access Control List of a resource.

Throws:
IOException
be.re.net.ProtocolException

getActivityCollections

public URL[] getActivityCollections(URL url)
                             throws IOException,
                                    be.re.net.ProtocolException
Returns the resource collections in the repository denoted by url that contain activities.

Throws:
IOException
be.re.net.ProtocolException

getLocale

public Locale getLocale()
Returns the default locale that will be assigned to the Accept-Language header if it is not yet present.


getLockTokens

public String[] getLockTokens(URL url)
                       throws IOException,
                              be.re.net.ProtocolException
Returns all the lock tokens of a resource.

Throws:
IOException
be.re.net.ProtocolException

getLocks

public Client.Lock[] getLocks(URL url)
                       throws IOException,
                              be.re.net.ProtocolException
Returns all the locks of a resource.

Throws:
IOException
be.re.net.ProtocolException

getMetaCollections

public URL[] getMetaCollections(URL url)
                         throws IOException,
                                be.re.net.ProtocolException
Returns the resource collections in the repository denoted by url that contain functional meta collections. This method is specific to Pincette.

Throws:
IOException
be.re.net.ProtocolException

getOnBehalfOf

public String getOnBehalfOf()
Returns the default value for the X-be.re.On-Behalf-Of header. A system user can use this to perform requests on behalf of another user. This way a WebDAV server can be used as a resource by another service, much like a database system.


getPassword

public String getPassword()
Return the default password for basic HTTP authentication.


getPrincipalCollections

public URL[] getPrincipalCollections(URL url)
                              throws IOException,
                                     be.re.net.ProtocolException
Returns the resource collections in the repository denoted by url that contain principals.

Throws:
IOException
be.re.net.ProtocolException

getSimpleLiveProperty

public String getSimpleLiveProperty(URL url,
                                    ExpandedName property)
                             throws IOException,
                                    be.re.net.ProtocolException
Returns the value of a live property as a string if it has either one empty element as a value, in which case the local name of the element is the value, or only PCDATA, otherwise null is returned.

Throws:
IOException
be.re.net.ProtocolException

getSimpleLiveProperty

public String getSimpleLiveProperty(URL url,
                                    String property)
                             throws IOException,
                                    be.re.net.ProtocolException
Returns the value of a live property in the DAV: namespace as a string if it has one empty element as a value, in which case the local name of the element is the value, or only PCDATA, otherwise null is returned.

Throws:
IOException
be.re.net.ProtocolException

getSupportedLiveProperties

public ExpandedName[] getSupportedLiveProperties(URL url)
                                          throws IOException,
                                                 be.re.net.ProtocolException
Returns all the live properties supported by the resource.

Throws:
IOException
be.re.net.ProtocolException

getUserAgent

public String getUserAgent()
Returns the default value for the User-Agent header.


getUsername

public String getUsername()
Returns the default username for basic HTTP authentication.


getVersionHistoryCollections

public URL[] getVersionHistoryCollections(URL url)
                                   throws IOException,
                                          be.re.net.ProtocolException
Returns the resource collections in the repository denoted by url that contain version histories.

Throws:
IOException
be.re.net.ProtocolException

getViewCollections

public URL[] getViewCollections(URL url)
                         throws IOException,
                                be.re.net.ProtocolException
Returns the resource collections in the repository denoted by url that contain views. This method is specific to Pincette.

Throws:
IOException
be.re.net.ProtocolException

head

public Headers head(URL url)
             throws IOException,
                    be.re.net.ProtocolException
Returns the headers of a resource.

Throws:
IOException
be.re.net.ProtocolException

index

public void index(URL url,
                  String depth,
                  boolean withPreview)
           throws IOException,
                  be.re.net.ProtocolException
This is an administration method that reindexes a WebDAV-collection in Pincette.

Parameters:
url - the collection.
depth - the WebDAV Depth header.
withPreview - when set to true the previews are also re-extracted next to full-text indexing.
Throws:
IOException
be.re.net.ProtocolException

lock

public String lock(URL url,
                   long timeoutSeconds)
            throws IOException,
                   be.re.net.ProtocolException
Locks a resource.

Parameters:
url - the resource to be locked.
timeoutSeconds - the time in seconds the lock should last. If the lock hasn't been refreshed before this time has passed, it will be automatically released. The value -1 indicates an infinite timeout. Note that a server may impose restrictions of its own.
Returns:
The lock token.
Throws:
IOException
be.re.net.ProtocolException

lock

public String lock(URL url,
                   long timeoutSeconds,
                   String lockToken)
            throws IOException,
                   be.re.net.ProtocolException
Locks a resource.

Parameters:
url - the resource to be locked.
timeoutSeconds - the time in seconds the lock should last. If the lock hasn't been refreshed before this time has passed, it will be automatically released. The value -1 indicates an infinite timeout. Note that a server may impose restrictions of its own.
lockToken - a lock token. It may be null. If it isn't it denotes the lock to refresh.
Returns:
The lock token.
Throws:
IOException
be.re.net.ProtocolException

merge

public Client.Response merge(URL url,
                             URL[] sources,
                             String label,
                             boolean autoMerge,
                             boolean checkOut,
                             URL checkOutActivity,
                             boolean forkOK)
                      throws IOException,
                             be.re.net.ProtocolException
Merges a number of resources into another one. When collections are involved the merger will be recursive.

Parameters:
url - the resource to merge into.
sources - the resources that are to be merged.
label - and optional label that overrides the default version selection. For all the sources the version carrying label will be the subject of the operation. This parameter is specific to Pincette.
autoMerge - allow the server to perform an automatic merge if it can. Otherwise the merge is only registered and should be completed manually.
checkOut - allow the server to check out a resource if needed.
checkOutActivity - the activity in which the automatic check-out should occur.
forkOK - when set to true forking a line of descent is allowed.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() to process the response, where the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

mkactivity

public void mkactivity(URL url)
                throws IOException,
                       be.re.net.ProtocolException
Creates an activity.

Throws:
IOException
be.re.net.ProtocolException

mkcol

public void mkcol(URL url)
           throws IOException,
                  be.re.net.ProtocolException
Creates a resource collection.

Throws:
IOException
be.re.net.ProtocolException

mkview

public void mkview(URL url)
            throws IOException,
                   be.re.net.ProtocolException
Creates a view. This method is specific for Pincette.

Throws:
IOException
be.re.net.ProtocolException

move

public void move(URL from,
                 URL to,
                 boolean overwrite)
          throws IOException,
                 be.re.net.ProtocolException
Moves one resource to another. Within a server this corresponds to a rename.

Parameters:
from - the resource to be moved.
to - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by to, then overwrite it.
Throws:
IOException
be.re.net.ProtocolException

move

public void move(URL from,
                 URL to,
                 boolean overwrite,
                 String lockToken)
          throws IOException,
                 be.re.net.ProtocolException
Moves one resource to another. Within a server this corresponds to a rename.

Parameters:
from - the resource to be moved.
to - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by to, then overwrite it.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

operation

public Client.Response operation(String method,
                                 URL url,
                                 Headers headersIn,
                                 InputStream body)
                          throws IOException,
                                 be.re.net.ProtocolException
The low-level method that communicates with the server.

Parameters:
method - the method.
url - the URL of the resource.
headersIn - the header that will be set on the request.
body - the request body.
Returns:
The response from the server.
Throws:
IOException
be.re.net.ProtocolException

options

public Client.Options options(URL url,
                              boolean activityCollections,
                              boolean metaCollections,
                              boolean versionHistoryCollections,
                              boolean viewCollections)
                       throws IOException,
                              be.re.net.ProtocolException
Returns the options for a resource.

Parameters:
url - the resource.
activityCollections - if set to true the collections that contain activities will be requested.
metaCollections - if set to true the collections that contain functional meta collections will be requested. This is specific to Pincette.
versionHistoryCollections - if set to true the collections that contain version histories will be requested.
viewCollections - if set to true the collections that contain views will be requested. This is specific to Pincette.
Throws:
IOException
be.re.net.ProtocolException

propfindAll

public Client.Response propfindAll(URL url,
                                   String depth)
                            throws IOException,
                                   be.re.net.ProtocolException
Returns all the properties of a resource.

Parameters:
url - the resource.
depth - the scope of the operation. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response is defined in section 9.1 of RFC 4918. It should be closed after consumption.
Throws:
IOException
be.re.net.ProtocolException

propfindNames

public Client.Response propfindNames(URL url,
                                     String depth)
                              throws IOException,
                                     be.re.net.ProtocolException
Returns all the property names of a resource.

Parameters:
url - the resource.
depth - the scope of the operation. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response is defined in section 9.1 of RFC 4918. It should be closed after consumption.
Throws:
IOException
be.re.net.ProtocolException

propfindNames

public ExpandedName[] propfindNames(URL url)
                             throws IOException,
                                    be.re.net.ProtocolException
Returns all the property names of a resource.

Throws:
IOException
be.re.net.ProtocolException

propfindSpecific

public Client.Response propfindSpecific(URL url,
                                        ExpandedName[] properties,
                                        String depth)
                                 throws IOException,
                                        be.re.net.ProtocolException
Returns the requested properties of a resource.

Parameters:
url - the resource.
properties - the requested properties.
depth - the scope of the operation. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response is defined in section 9.1 of RFC 4918. It should be closed after consumption.
Throws:
IOException
be.re.net.ProtocolException

proppatch

public Client.Response proppatch(URL url,
                                 InputStream in)
                          throws IOException,
                                 be.re.net.ProtocolException
Changes properties of the resource.

Parameters:
url - the resource.
in - the request body. It is specified in section 9.2 of RFC 4918.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() to process the response. See section 9.2.1 of RFC 4918 for the specification of the status codes.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

proppatch

public Client.Response proppatch(URL url,
                                 InputStream in,
                                 String lockToken)
                          throws IOException,
                                 be.re.net.ProtocolException
Changes properties of the resource.

Parameters:
url - the resource.
in - the request body. It is specified in section 9.2 of RFC 4918.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() to process the response. See section 9.2.1 of RFC 4918 for the specification of the status codes.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

proppatch

public Client.Response proppatch(URL url,
                                 Document document)
                          throws IOException,
                                 be.re.net.ProtocolException
Changes properties of the resource.

Parameters:
url - the resource.
document - the request body. It is specified in section 9.2 of RFC 4918.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() to process the response. See section 9.2.1 of RFC 4918 for the specification of the status codes.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

proppatch

public Client.Response proppatch(URL url,
                                 Document document,
                                 String lockToken)
                          throws IOException,
                                 be.re.net.ProtocolException
Changes properties of the resource.

Parameters:
url - the resource.
document - the request body.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() to process the response. See section 9.2.1 of RFC 4918 for the specification of the status codes.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

put

public Client.Response put(URL url,
                           InputStream in,
                           String mimeType,
                           String language)
                    throws IOException,
                           be.re.net.ProtocolException
Creates or updates a resource.

Parameters:
url - the resource that will be updated. If it doesn't exist it will be created.
in - the request body. If it is null an empty request body will be sent.
mimeType - the MIME type of the request body. If it is null the MIME type application/octet-stream is used.
language - the natural language of the request body. It may be null.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

put

public Client.Response put(URL url,
                           InputStream in,
                           String mimeType,
                           String language,
                           String lockToken)
                    throws IOException,
                           be.re.net.ProtocolException
Creates or updates a resource.

Parameters:
url - the resource that will be updated. If it doesn't exist it will be created.
in - the request body. If it is null an empty request body will be sent.
mimeType - the MIME type of the request body. If it is null the MIME type application/octet-stream is used.
language - the natural language of the request body. It may be null.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed.
Throws:
IOException
be.re.net.ProtocolException

rebind

public void rebind(URL url,
                   URL newBinding,
                   boolean overwrite)
            throws IOException,
                   be.re.net.ProtocolException
Replaces a binding to an existing resource.

Parameters:
url - the existing resource
newBinding - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by newBinding, then overwrite it.
Throws:
IOException
be.re.net.ProtocolException

rebind

public void rebind(URL url,
                   URL newBinding,
                   boolean overwrite,
                   String lockToken)
            throws IOException,
                   be.re.net.ProtocolException
Replaces a binding to an existing resource.

Parameters:
url - the existing resource
newBinding - the new URL for the resource.
overwrite - if set to true and there already is a resource denoted by newBinding, then overwrite it.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

removeLabel

public void removeLabel(URL url,
                        String label)
                 throws IOException,
                        be.re.net.ProtocolException
Removes a label from the resource. The resource should be checked in.

Parameters:
url - the resource
label - the label that is to be removed.
Throws:
IOException
be.re.net.ProtocolException

removeLabel

public Client.Response removeLabel(URL url,
                                   String label,
                                   String selectionLabel,
                                   String depth)
                            throws IOException,
                                   be.re.net.ProtocolException
Removes a label from the resource. The resource should be checked in.

Parameters:
url - the resource.
label - the label that is to be removed.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

removeLabel

public Client.Response removeLabel(URL url,
                                   String label,
                                   String selectionLabel,
                                   String depth,
                                   String lockToken)
                            throws IOException,
                                   be.re.net.ProtocolException
Removes a label from the resource. The resource should be checked in.

Parameters:
url - the resource.
label - the label that is to be removed.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

report

public Client.Response report(URL url,
                              InputStream in,
                              String label,
                              String depth)
                       throws IOException,
                              be.re.net.ProtocolException

With this method more complex information can be retrieved about a resource. The following WebDAV reports exist:

The reports that are supported by a resource can be discovered through the supported-report-set property.

Pincette has the extension report simple-search in the namespace urn:be-re:dav. This is a report for general purpose queries. It returns the list of resources that matches the query, accompanied by properties if requested. The syntax is as follows:

 <!ELEMENT simple-search ((and|or|not|expr|(field,op,value)),(prop)?)>
 <!ELEMENT prop ANY>
 <!ELEMENT and (expr)+>
 <!ELEMENT or (expr)+>
 <!ELEMENT expr (and|or|not|expr|(field,op,value))>
 <!ELEMENT not (and|or|not|expr|(field,op,value))>
 <!ELEMENT field (#PCDATA)>
 <!ELEMENT op (#PCDATA)>
 <!ELEMENT value (#PCDATA)>

The prop element should contain empty property name elements. The following table lists the supported fields, their operators and possible values:

FieldOperatorsValues
activity-setcontainsactivity URL
auto-merged=true or false
contains = Lucene text query
displayname =, != string (wildcard "*")
checked-out=true or false
creation-date =, !=, <, >, <=, >= ISO 8601 timestamp
creator-displayname =, != string (wildcard "*")
getcontentlanguage =, != string (wildcard "*")
getcontentlength =, !=, <, >, <=, >= natural number
getcontenttype =, != string (wildcard "*")
getlastmodified =, !=, <, >, <=, >= ISO 8601 timestamp
label-name-setcontainsstring
not-label=string
merge-incomplete=true or false
meta.<property name> =, != string (wildcard "*")
owner=, !=string (wildcard "*")

Parameters:
url - the resource for which the report is requested.
in - the request document.
label - an optional label that overrides the default version selection. The version carrying label will be the subject of the operation. This parameter is specific to Pincette.
depth - the scope of the report. It can have the following values:
  • 0: apply the report only to the resource itself;
  • 1: apply the report to the resource itself and its immediate descendants;
  • infinity: apply the report to the resource itself and any of its descendants no matter the level.
Throws:
IOException
be.re.net.ProtocolException

report

public Client.Response report(URL url,
                              Document document,
                              String label,
                              String depth)
                       throws IOException,
                              be.re.net.ProtocolException
This is a variant of the other report method.

Throws:
IOException
be.re.net.ProtocolException

setLabel

public void setLabel(URL url,
                     String label)
              throws IOException,
                     be.re.net.ProtocolException
Sets a label on the resource. The resource should be checked in.

Parameters:
url - the resource.
label - the label that is to be set.
Throws:
IOException
be.re.net.ProtocolException

setLabel

public Client.Response setLabel(URL url,
                                String label,
                                String selectionLabel,
                                String depth)
                         throws IOException,
                                be.re.net.ProtocolException
Sets a label on the resource. The resource should be checked in. If another version of the resource already has the label, the label will be moved.

Parameters:
url - the resource.
label - the label that is to be set.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

setLabel

public Client.Response setLabel(URL url,
                                String label,
                                String selectionLabel,
                                String depth,
                                String lockToken)
                         throws IOException,
                                be.re.net.ProtocolException
Sets a label on the resource. The resource should be checked in. If another version of the resource already has the label, the label will be moved.

Parameters:
url - the resource.
label - the label that is to be set.
selectionLabel - an optional label that overrides the default version selection. The version carrying selectionLabel will be the subject of the operation.
depth - the scope of application of the label. It can have the following values:
  • 0: apply the operation only to the resource itself;
  • 1: apply the operation to the resource itself and its immediate descendants;
  • infinity: apply the operation to the resource itself and any of its descendants no matter the level.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Returns:
The response should be closed after consumption. Use be.re.webdav.Util.reportMultistatus() if the status code is 207. Otherwise the status code 200 indicates success.
Throws:
IOException
be.re.net.ProtocolException
See Also:
Util.reportMultistatus(Client.Response, Util.ReportMultistatus)

setLocale

public void setLocale(Locale value)
Sets the default locale that will be assigned to the Accept-Language header if it is not yet present. It may be null.


setOnBehalfOf

public void setOnBehalfOf(String value)
Sets the X-be.re.On-Behalf-Of header. A system user can use this to perform requests on behalf of another user. This way a WebDAV server can be used as a resource by another service, much like a database system. It may be null.


setPassword

public void setPassword(String value)
Sets the default password for basic HTTP authentication. It may be null.


setSimpleLiveProperty

public void setSimpleLiveProperty(URL url,
                                  ExpandedName property,
                                  String value)
                           throws IOException,
                                  be.re.net.ProtocolException
Sets the value of a simple live property.

Parameters:
url - the resource that will be updated.
property - the name of the simple property.
value - the value.
Throws:
IOException
be.re.net.ProtocolException
See Also:
getSimpleLiveProperty(URL, ExpandedName)

setSimpleLiveProperty

public void setSimpleLiveProperty(URL url,
                                  ExpandedName property,
                                  String value,
                                  String lockToken)
                           throws IOException,
                                  be.re.net.ProtocolException
Sets the value of a simple live property.

Parameters:
url - the resource that will be updated.
property - the name of the simple property.
value - the value.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException
See Also:
getSimpleLiveProperty(URL, ExpandedName)

setSimpleLiveProperty

public void setSimpleLiveProperty(URL url,
                                  String property,
                                  String value)
                           throws IOException,
                                  be.re.net.ProtocolException
Sets the value of a simple live property.

Parameters:
url - the resource that will be updated.
property - the local name of the simple property. The property is assumed to be in the DAV: namespace.
value - the value.
Throws:
IOException
be.re.net.ProtocolException
See Also:
getSimpleLiveProperty(URL, ExpandedName)

setSimpleLiveProperty

public void setSimpleLiveProperty(URL url,
                                  String property,
                                  String value,
                                  String lockToken)
                           throws IOException,
                                  be.re.net.ProtocolException
Sets the value of a simple live property.

Parameters:
url - the resource that will be updated.
property - the local name of the simple property. The property is assumed to be in the DAV: namespace.
value - the value.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException
See Also:
getSimpleLiveProperty(URL, ExpandedName)

setUserAgent

public void setUserAgent(String userAgent)
Sets the default value for the User-Agent header. It may be null.


setUsername

public void setUsername(String value)
Sets the default username for basic HTTP authentication. It may be null.


unbind

public void unbind(URL url)
            throws IOException,
                   be.re.net.ProtocolException
Removes a binding to a resource. The resource will be deleted when there no other bindings left.

Parameters:
url - the resource.
Throws:
IOException
be.re.net.ProtocolException

unbind

public void unbind(URL url,
                   String lockToken)
            throws IOException,
                   be.re.net.ProtocolException
Removes a binding to a resource. The resource will be deleted when there no other bindings left.

Parameters:
url - the resource.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

uncheckout

public void uncheckout(URL url)
                throws IOException,
                       be.re.net.ProtocolException
Reverts the check-out of a resource.

Throws:
IOException
be.re.net.ProtocolException

uncheckout

public void uncheckout(URL url,
                       String lockToken)
                throws IOException,
                       be.re.net.ProtocolException
Reverts the check-out of a resource.

Parameters:
url - the resource.
lockToken - a lock token. It may be null. If the resource is locked, the lock token should correspond to the lock.
Throws:
IOException
be.re.net.ProtocolException

unlock

public void unlock(URL url,
                   String lockToken)
            throws IOException,
                   be.re.net.ProtocolException
Unlocks a resource.

Parameters:
url - the resource.
lockToken - a lock token. It must not be null.
Throws:
IOException
be.re.net.ProtocolException

versionControl

public void versionControl(URL url)
                    throws IOException,
                           be.re.net.ProtocolException
Throws:
IOException
be.re.net.ProtocolException