Interface Sardine
- All Known Implementing Classes:
SardineImpl
public interface Sardine
The main interface for Sardine operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCopy a url from source to destination using WebDAVCOPY.voidCopy a url from source to destination using WebDAVCOPY.voidCopy a url from source to destination using WebDAVCOPY.voidcreateDirectory(String url) Uses WebDAVMKCOLto create a directory at the specified urlvoidDelete a resource using HTTPDELETEat the specified urlvoidDelete a resource using HTTPDELETEat the specified urlvoidDisables support for HTTP compression.voidDisable preemptive authentication.voidEnables HTTP GZIP compression.voidenablePreemptiveAuthentication(String hostname) Send aBasicauthentication header with each request even before 401 is returned.voidenablePreemptiveAuthentication(String hostname, int httpPort, int httpsPort) Send aBasicauthentication header with each request even before 401 is returned.voidSend aBasicauthentication header with each request even before 401 is returned.booleanPerforms a HTTPHEADrequest to see if a resource exists or not.Uses HTTPGETto download data from a server.Uses HTTPGETto download data from a server.Read access control list for resourceThe principals that are available on the server that implements this resource.getPrincipals(String url) List the principals that can be used to set ACLs on given urlRead quota properties for resourcegetResources(String url) Deprecated.voidIgnores cookies.Gets a directory listing using WebDAVPROPFIND.Gets a directory listing using WebDAVPROPFIND.Gets a directory listing using WebDAVPROPFIND.Gets a directory listing using WebDAVPROPFIND.Put an exclusive write lock on this resource.voidMove a url to from source to destination using WebDAVMOVE.voidMove a url to from source to destination using WebDAVMOVE.voidMove a url to from source to destination using WebDAVMOVE.Add or remove custom properties for a url using WebDAVPROPPATCH.Add or remove custom properties for a url using WebDAVPROPPATCH.Add custom properties for a url WebDAVPROPPATCH.Add or remove custom properties for a url using WebDAVPROPPATCH.Fetches a resource using WebDAVPROPFIND.voidUses HTTPPUTto send data to a server.voidUsesPUTto send data to a server with a specific content type header.voidUsesPUTto upload file to a server with specific contentType.voidUsesPUTto upload file to a server with specific contentType.voidput(String url, InputStream dataStream) UsesPUTto send data to a server.voidput(String url, InputStream dataStream, String contentType) UsesPUTto send data to a server with a specific content type header.voidput(String url, InputStream dataStream, String contentType, boolean expectContinue) UsesPUTto send data to a server with a specific content type header.voidput(String url, InputStream dataStream, String contentType, boolean expectContinue, long contentLength) UsesPUTto send data to a server with a specific content type header.voidUsesPUTto send data to a server with specific headers.refreshLock(String url, String token, String file) A LOCK request with no request body is a "LOCK refresh" request.<T> Treport(String url, int depth, SardineReport<T> report) Runs a report on the given resource using WebDAVREPORT.Perform a search of the Webdav repository.voidWrite access control list for resourcevoidsetCredentials(String username, String password) Add credentials to any scope.voidsetCredentials(String username, String password, String domain, String workstation) voidDeprecated.voidshutdown()Releasing any resources that might be held open.voidUnlock the resource.
-
Method Details
-
setCredentials
-
setCredentials
-
getResources
Deprecated.- Throws:
IOException- See Also:
-
list
Gets a directory listing using WebDAVPROPFIND.- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- List of resources for this URI including the parent resource itself
- Throws:
IOException- I/O error or HTTP response validation failure
-
list
Gets a directory listing using WebDAVPROPFIND.- Parameters:
url- Path to the resource including protocol and hostnamedepth- The depth to look at (use 0 for single resource, 1 for directory listing, -1 for infinite recursion)- Returns:
- List of resources for this URI including the parent resource itself
- Throws:
IOException- I/O error or HTTP response validation failure
-
list
Gets a directory listing using WebDAVPROPFIND.- Parameters:
url- Path to the resource including protocol and hostnamedepth- The depth to look at (use 0 for single resource, 1 for directory listing, -1 for infinite recursion)props- Additional properties which should be requested.- Returns:
- List of resources for this URI including the parent resource itself
- Throws:
IOException- I/O error or HTTP response validation failure
-
list
Gets a directory listing using WebDAVPROPFIND.- Parameters:
url- Path to the resource including protocol and hostnamedepth- The depth to look at (use 0 for single resource, 1 for directory listing, -1 for infinite recursion)allProp- If allprop should be used, which can be inefficient sometimes; warning: no allprop does not retrieve custom props, just the basic ones- Returns:
- List of resources for this URI including the parent resource itself
- Throws:
IOException- I/O error or HTTP response validation failure
-
propfind
Fetches a resource using WebDAVPROPFIND. Only the specified properties are retrieved.- Parameters:
url- Path to the resource including protocol and hostnamedepth- The depth to look at (use 0 for single resource, 1 for directory listing, -1 for infinite recursion)props- Set of properties to be requested- Returns:
- List of resources for this URI including the parent resource itself
- Throws:
IOException- I/O error or HTTP response validation failure
-
report
Runs a report on the given resource using WebDAVREPORT.- Parameters:
url- Path to the resource including protocol and hostnamedepth- The depth to look at (use 0 for single resource, 1 for directory listing, -1 for infinite recursion)report- The report to run- Returns:
- Result of the report, packaged in a report-specific result object
- Throws:
IOException- I/O error or HTTP response validation failure
-
search
Perform a search of the Webdav repository.- Parameters:
url- The base resource to search from.language- The language the query is formed in.query- The query string to be processed by the webdav server.- Returns:
- A list of matching resources.
- Throws:
IOException- I/O error or HTTP response validation failure.
-
setCustomProps
@Deprecated void setCustomProps(String url, Map<String, String> addProps, List<String> removeProps) throws IOExceptionDeprecated.- Throws:
IOException- See Also:
-
patch
Add custom properties for a url WebDAVPROPPATCH.- Parameters:
url- Path to the resource including protocol and hostnameaddProps- Properties to add to resource. If a property already exists then its value is replaced.- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
patch
List<DavResource> patch(String url, Map<QName, String> addProps, List<QName> removeProps) throws IOExceptionAdd or remove custom properties for a url using WebDAVPROPPATCH.- Parameters:
url- Path to the resource including protocol and hostnameaddProps- Properties to add to resource. If a property already exists then its value is replaced.removeProps- Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
patch
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps) throws IOException Add or remove custom properties for a url using WebDAVPROPPATCH.- Parameters:
url- Path to the resource including protocol and hostnameaddProps- Properties to add to resource. If a property already exists then its value is replaced.removeProps- Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
patch
List<DavResource> patch(String url, List<Element> addProps, List<QName> removeProps, Map<String, String> headers) throws IOExceptionAdd or remove custom properties for a url using WebDAVPROPPATCH.- Parameters:
url- Path to the resource including protocol and hostnameaddProps- Properties to add to resource. If a property already exists then its value is replaced.removeProps- Properties to remove from resource. Specifying the removal of a property that does not exist is not an error.headers- Additional HTTP headers to add to the request- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
get
Uses HTTPGETto download data from a server. The stream must be closed after reading.- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- Data stream to read from
- Throws:
IOException- I/O error or HTTP response validation failure
-
get
Uses HTTPGETto download data from a server. The stream must be closed after reading.- Parameters:
url- Path to the resource including protocol and hostnameheaders- Additional HTTP headers to add to the request- Returns:
- Data stream to read from
- Throws:
IOException- I/O error or HTTP response validation failure
-
put
Uses HTTPPUTto send data to a server. Repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)data- Input source- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto send data to a server. Not repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)dataStream- Input source- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto send data to a server with a specific content type header. Repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)data- Input sourcecontentType- MIME type to add to the HTTP request header- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)dataStream- Input sourcecontentType- MIME type to add to the HTTP request header- Throws:
IOException- I/O error or HTTP response validation failure
-
put
void put(String url, InputStream dataStream, String contentType, boolean expectContinue) throws IOException UsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)dataStream- Input sourcecontentType- MIME type to add to the HTTP request headerexpectContinue- EnableExpect: continueheader forPUTrequests.- Throws:
IOException- I/O error or HTTP response validation failure
-
put
void put(String url, InputStream dataStream, String contentType, boolean expectContinue, long contentLength) throws IOException UsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)dataStream- Input sourcecontentType- MIME type to add to the HTTP request headerexpectContinue- EnableExpect: continueheader forPUTrequests.contentLength- data size in bytes to set to Content-Length header- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto send data to a server with specific headers. Not repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)dataStream- Input sourceheaders- Additional HTTP headers to add to the request- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto upload file to a server with specific contentType. Repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)localFile- local file to sendcontentType- MIME type to add to the HTTP request header- Throws:
IOException- I/O error or HTTP response validation failure
-
put
UsesPUTto upload file to a server with specific contentType. Repeatable on authentication failure.- Parameters:
url- Path to the resource including protocol and hostname (must not point to a directory)localFile- local file to sendcontentType- MIME type to add to the HTTP request headerexpectContinue- EnableExpect: continueheader forPUTrequests.- Throws:
IOException- I/O error or HTTP response validation failure
-
delete
Delete a resource using HTTPDELETEat the specified url- Parameters:
url- Path to the resource including protocol and hostname (trailing slash is mandatory for directories)- Throws:
IOException- I/O error or HTTP response validation failure
-
delete
Delete a resource using HTTPDELETEat the specified url- Parameters:
url- Path to the resource including protocol and hostnameheaders- Additional HTTP headers to add to the request- Throws:
IOException- I/O error or HTTP response validation failure
-
createDirectory
Uses WebDAVMKCOLto create a directory at the specified url- Parameters:
url- Path to the resource including protocol and hostname- Throws:
IOException- I/O error or HTTP response validation failure
-
move
Move a url to from source to destination using WebDAVMOVE. Assumes overwrite.- Parameters:
sourceUrl- Path to the resource including protocol and hostname (trailing slash is mandatory for directories)destinationUrl- Path to the resource including protocol and hostname- Throws:
IOException- I/O error or HTTP response validation failure
-
move
Move a url to from source to destination using WebDAVMOVE.- Parameters:
sourceUrl- Path to the resource including protocol and hostname (trailing slash is mandatory for directories)destinationUrl- Path to the resource including protocol and hostnameoverwrite-trueto overwrite if the destination exists,falseotherwise.- Throws:
IOException- I/O error or HTTP response validation failure
-
move
void move(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOExceptionMove a url to from source to destination using WebDAVMOVE.- Parameters:
sourceUrl- Path to the resource including protocol and hostnamedestinationUrl- Path to the resource including protocol and hostnameoverwrite-trueto overwrite if the destination exists,falseotherwise.headers- Additional HTTP headers to add to the request- Throws:
IOException- I/O error or HTTP response validation failure
-
copy
Copy a url from source to destination using WebDAVCOPY. Assumes overwrite.- Parameters:
sourceUrl- Path to the resource including protocol and hostname (trailing slash is mandatory for directories)destinationUrl- Path to the resource including protocol and hostname- Throws:
IOException- I/O error or HTTP response validation failure
-
copy
Copy a url from source to destination using WebDAVCOPY.- Parameters:
sourceUrl- Path to the resource including protocol and hostname (trailing slash is mandatory for directories)destinationUrl- Path to the resource including protocol and hostnameoverwrite-trueto overwrite if the destination exists,falseotherwise.- Throws:
IOException- I/O error or HTTP response validation failure
-
copy
void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOExceptionCopy a url from source to destination using WebDAVCOPY.- Parameters:
sourceUrl- Path to the resource including protocol and hostnamedestinationUrl- Path to the resource including protocol and hostnameoverwrite-trueto overwrite if the destination exists,falseotherwise.headers- Additional HTTP headers to add to the request- Throws:
IOException- I/O error or HTTP response validation failure
-
exists
Performs a HTTPHEADrequest to see if a resource exists or not.- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- Anything outside of the 200-299 response code range returns false.
- Throws:
IOException- I/O error or HTTP response validation failure
-
lock
Put an exclusive write lock on this resource. A write lock must prevent a principal without the lock from successfully executing a PUT, POST, PROPPATCH, LOCK, UNLOCK, MOVE, DELETE, or MKCOL on the locked resource. All other current methods, GET in particular, function independently of the lock.
A WebDAV compliant server is not required to support locking in any form. If the server does support locking it may choose to support any combination of exclusive and shared locks for any access types.- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- The lock token to unlock this resource. A lock token is a type of state token, represented
as a URI, which identifies a particular lock. A lock token is returned by every successful
LOCKoperation in the lockdiscovery property in the response body, and can also be found through lock discovery on a resource. - Throws:
IOException- I/O error or HTTP response validation failure
-
refreshLock
A LOCK request with no request body is a "LOCK refresh" request. It's purpose is to restart all timers associated with a lock. The request MUST include an "If" header that contains the lock tokens of the locks to be refreshed (note there may be multiple in the case of shared locks).- Parameters:
url- Path to the resource including protocol and hostnametoken- The lock token used to lock the resourcefile- The name of the file at the end of the url- Returns:
- The lock token to unlock this resource. A lock token is a type of state token, represented
as a URI, which identifies a particular lock. A lock token is returned by every successful
LOCKoperation in the lockdiscovery property in the response body, and can also be found through lock discovery on a resource. - Throws:
IOException- I/O error or HTTP response validation failure
-
unlock
Unlock the resource.
A WebDAV compliant server is not required to support locking in any form. If the server does support locking it may choose to support any combination of exclusive and shared locks for any access types.- Parameters:
url- Path to the resource including protocol and hostnametoken- The lock token to unlock this resource.- Throws:
IOException- I/O error or HTTP response validation failure- See Also:
-
getAcl
Read access control list for resource- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- Current ACL set on the resource
- Throws:
IOException- I/O error or HTTP response validation failure
-
getQuota
Read quota properties for resource- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- Current Quota and Size Properties for resource
- Throws:
IOException- I/O error or HTTP response validation failure
-
setAcl
Write access control list for resource- Parameters:
url- Path to the resource including protocol and hostnameaces- Access control elements- Throws:
IOException- I/O error or HTTP response validation failure
-
getPrincipals
List the principals that can be used to set ACLs on given url- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- List of principals (in the form of urls according to spec)
- Throws:
IOException- I/O error or HTTP response validation failure
-
getPrincipalCollectionSet
The principals that are available on the server that implements this resource.- Parameters:
url- Path to the resource including protocol and hostname- Returns:
- The URLs in DAV:principal-collection-set
- Throws:
IOException- I/O error or HTTP response validation failure
-
enableCompression
void enableCompression()Enables HTTP GZIP compression. If enabled, requests originating from Sardine will include "gzip" as an "Accept-Encoding" header.
If the server also supports gzip compression, it should serve the contents in compressed gzip format and include "gzip" as the Content-Encoding. If the content encoding is present, Sardine will automatically decompress the files upon reception. -
disableCompression
void disableCompression()Disables support for HTTP compression.- See Also:
-
ignoreCookies
void ignoreCookies()Ignores cookies. -
enablePreemptiveAuthentication
Send aBasicauthentication header with each request even before 401 is returned. Uses default ports: 80 for http and 443 for https- Parameters:
hostname- The hostname to enable preemptive authentication for.
-
enablePreemptiveAuthentication
Send aBasicauthentication header with each request even before 401 is returned.- Parameters:
url- The hostname, protocol and port to enable preemptive authentication for.
-
enablePreemptiveAuthentication
Send aBasicauthentication header with each request even before 401 is returned.- Parameters:
hostname- The hostname to enable preemptive authentication for.httpPort- The http port to enable preemptive authentication for. -1 for default value.httpsPort- The https port to enable preemptive authentication for. -1 for default value.
-
disablePreemptiveAuthentication
void disablePreemptiveAuthentication()Disable preemptive authentication. -
shutdown
Releasing any resources that might be held open. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources. Once a client has been shutdown, it should not be used to make any more requests.- Throws:
IOException
-