| Constructor and Description |
|---|
SardineImpl()
Access resources with no authentication
|
SardineImpl(org.apache.http.impl.client.AbstractHttpClient http) |
SardineImpl(org.apache.http.impl.client.AbstractHttpClient http,
org.apache.http.client.RedirectStrategy redirect) |
SardineImpl(org.apache.http.impl.client.AbstractHttpClient http,
String username,
String password) |
SardineImpl(String username,
String password)
Supports standard authentication mechanisms
|
SardineImpl(String username,
String password,
ProxySelector selector) |
| Modifier and Type | Method and Description |
|---|---|
void |
copy(String sourceUrl,
String destinationUrl)
Copy a url from source to destination using WebDAV
COPY. |
protected org.apache.http.impl.client.AbstractHttpClient |
createDefaultClient(ProxySelector selector)
Creates an AbstractHttpClient with all of the defaults.
|
protected org.apache.http.conn.ClientConnectionManager |
createDefaultConnectionManager(org.apache.http.conn.scheme.SchemeRegistry schemeRegistry)
Use fail fast connection manager when connections are not released properly.
|
protected org.apache.http.params.HttpParams |
createDefaultHttpParams()
Creates default params setting the user agent.
|
protected org.apache.http.conn.routing.HttpRoutePlanner |
createDefaultRoutePlanner(org.apache.http.conn.scheme.SchemeRegistry schemeRegistry,
ProxySelector selector)
Override to provide proxy configuration
|
protected org.apache.http.conn.scheme.SchemeRegistry |
createDefaultSchemeRegistry()
Creates a new
SchemeRegistry for default ports
with socket factories. |
protected org.apache.http.conn.ssl.SSLSocketFactory |
createDefaultSecureSocketFactory() |
protected org.apache.http.conn.scheme.PlainSocketFactory |
createDefaultSocketFactory() |
void |
createDirectory(String url)
Uses WebDAV
MKCOL to create a directory at the specified url |
void |
delete(String url)
Delete a resource using HTTP
DELETE at the specified url |
void |
disableCompression()
Disable GZIP compression header.
|
void |
disablePreemptiveAuthentication()
Disable preemptive authentication.
|
void |
enableCompression()
Adds handling of GZIP compression to the client.
|
void |
enablePreemptiveAuthentication(String hostname)
Send a
Basic authentication header with each request even before 401 is returned. |
protected org.apache.http.HttpResponse |
execute(org.apache.http.client.methods.HttpRequestBase request)
No validation of the response.
|
protected <T> T |
execute(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.client.ResponseHandler<T> responseHandler)
Validate the response using the response handler.
|
boolean |
exists(String url)
Performs a HTTP
HEAD request to see if a resource exists or not. |
ContentLengthInputStream |
get(String url)
Uses HTTP
GET to download data from a server. |
ContentLengthInputStream |
get(String url,
Map<String,String> headers)
Uses HTTP
GET to download data from a server. |
DavAcl |
getAcl(String url)
Read access control list for resource
|
List<String> |
getPrincipalCollectionSet(String url)
The principals that are available on the server that implements this resource.
|
List<DavPrincipal> |
getPrincipals(String url)
List the principals that can be used to set ACLs on given url
|
DavQuota |
getQuota(String url)
Read quota properties for resource
|
List<DavResource> |
getResources(String url) |
List<DavResource> |
list(String url)
Gets a directory listing using WebDAV
PROPFIND. |
List<DavResource> |
list(String url,
int depth)
Gets a directory listing using WebDAV
PROPFIND. |
List<DavResource> |
list(String url,
int depth,
boolean allProp)
Gets a directory listing using WebDAV
PROPFIND. |
String |
lock(String url)
Put an exclusive write lock on this resource.
|
void |
move(String sourceUrl,
String destinationUrl)
Move a url to from source to destination using WebDAV
MOVE. |
List<DavResource> |
patch(String url,
Map<QName,String> setProps)
Add custom properties for a url WebDAV
PROPPATCH. |
List<DavResource> |
patch(String url,
Map<QName,String> setProps,
List<QName> removeProps)
Creates a
Propertyupdate element containing all properties to set from setProps and all properties to
remove from removeProps. |
void |
put(String url,
byte[] data)
Uses HTTP
PUT to send data to a server. |
void |
put(String url,
byte[] data,
String contentType)
Uses
PUT to send data to a server with a specific content type
header. |
void |
put(String url,
org.apache.http.HttpEntity entity,
Map<String,String> headers)
Upload the entity using
PUT |
<T> T |
put(String url,
org.apache.http.HttpEntity entity,
Map<String,String> headers,
org.apache.http.client.ResponseHandler<T> handler) |
void |
put(String url,
org.apache.http.HttpEntity entity,
String contentType,
boolean expectContinue)
Upload the entity using
PUT |
void |
put(String url,
InputStream dataStream)
Uses
PUT to send data to a server. |
void |
put(String url,
InputStream dataStream,
Map<String,String> headers)
Uses
PUT to send data to a server with specific headers. |
void |
put(String url,
InputStream dataStream,
String contentType)
Uses
PUT to send data to a server with a specific content
type header. |
void |
put(String url,
InputStream dataStream,
String contentType,
boolean expectContinue)
Uses
PUT to send data to a server with a specific content
type header. |
void |
put(String url,
InputStream dataStream,
String contentType,
boolean expectContinue,
long contentLength)
Uses
PUT to send data to a server with a specific content
type header. |
String |
refreshLock(String url,
String token,
String file)
A LOCK request with no request body is a "LOCK refresh" request.
|
void |
setAcl(String url,
List<DavAce> aces)
Write access control list for resource
|
void |
setCredentials(String username,
String password)
Add credentials to any scope.
|
void |
setCredentials(String username,
String password,
String domain,
String workstation) |
void |
setCustomProps(String url,
Map<String,String> set,
List<String> remove) |
void |
shutdown()
Releasing any resources that might be held
open.
|
void |
unlock(String url,
String token)
Unlock the resource.
|
public SardineImpl()
public SardineImpl(String username, String password)
username - Use in authentication header credentialspassword - Use in authentication header credentialspublic SardineImpl(String username, String password, ProxySelector selector)
username - Use in authentication header credentialspassword - Use in authentication header credentialsselector - Proxy configurationpublic SardineImpl(org.apache.http.impl.client.AbstractHttpClient http)
http - Custom client configurationpublic SardineImpl(org.apache.http.impl.client.AbstractHttpClient http,
org.apache.http.client.RedirectStrategy redirect)
http - Custom client configurationredirect - Custom redirect strategypublic void setCredentials(String username, String password)
setCredentials in interface Sardineusername - Use in authentication header credentialspassword - Use in authentication header credentialspublic void setCredentials(String username, String password, String domain, String workstation)
setCredentials in interface Sardineusername - Use in authentication header credentialspassword - Use in authentication header credentialsndomain - NTLM authenticationworkstation - NTLM authenticationpublic void enableCompression()
enableCompression in interface Sardinepublic void disableCompression()
disableCompression in interface SardineSardine.enableCompression()public void enablePreemptiveAuthentication(String hostname)
SardineBasic authentication header with each request even before 401 is returned.enablePreemptiveAuthentication in interface Sardinehostname - The hostname to enable preemptive authentication for.public void disablePreemptiveAuthentication()
SardinedisablePreemptiveAuthentication in interface Sardinepublic List<DavResource> getResources(String url) throws IOException
getResources in interface SardineIOExceptionSardine.list(String)public List<DavResource> list(String url) throws IOException
SardinePROPFIND.list in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic List<DavResource> list(String url, int depth) throws IOException
SardinePROPFIND.list in interface Sardineurl - Path to the resource including protocol and hostnamedepth - The depth to look at (use 0 for single ressource, 1 for directory listing)IOException - I/O error or HTTP response validation failurepublic List<DavResource> list(String url, int depth, boolean allProp) throws IOException
SardinePROPFIND.list in interface Sardineurl - Path to the resource including protocol and hostnamedepth - The depth to look at (use 0 for single ressource, 1 for directory listing)allProp - If allprop should be used, which can be inefficient sometimes;
warning: no allprop does not retrieve custom props, just the basic onesIOException - I/O error or HTTP response validation failurepublic void setCustomProps(String url, Map<String,String> set, List<String> remove) throws IOException
setCustomProps in interface SardineIOExceptionSardine.patch(String, java.util.Map, java.util.List)public List<DavResource> patch(String url, Map<QName,String> setProps) throws IOException
SardinePROPPATCH.patch in interface Sardineurl - Path to the resource including protocol and hostnamesetProps - Properties to add to resource. If a property already exists then its value is replaced.IOException - I/O error or HTTP response validation failurepublic List<DavResource> patch(String url, Map<QName,String> setProps, List<QName> removeProps) throws IOException
Propertyupdate element containing all properties to set from setProps and all properties to
remove from removeProps. Note this method will use a SardineUtil.CUSTOM_NAMESPACE_URI as
namespace and SardineUtil.CUSTOM_NAMESPACE_PREFIX as prefix.patch in interface Sardineurl - Path to the resource including protocol and hostnamesetProps - 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.IOException - I/O error or HTTP response validation failurepublic String lock(String url) throws IOException
Sardinelock in interface Sardineurl - Path to the resource including protocol and hostnameLOCK operation in the lockdiscovery property in the response body, and can also be found through
lock discovery on a resource.IOException - I/O error or HTTP response validation failurepublic String refreshLock(String url, String token, String file) throws IOException
SardinerefreshLock in interface Sardineurl - 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 urlLOCK operation in the lockdiscovery property in the response body, and can also be found through
lock discovery on a resource.IOException - I/O error or HTTP response validation failurepublic void unlock(String url, String token) throws IOException
Sardineunlock in interface Sardineurl - Path to the resource including protocol and hostnametoken - The lock token to unlock this resource.IOException - I/O error or HTTP response validation failureSardine.lock(String)public void setAcl(String url, List<DavAce> aces) throws IOException
SardinesetAcl in interface Sardineurl - Path to the resource including protocol and hostnameaces - Access control elementsIOException - I/O error or HTTP response validation failurepublic DavAcl getAcl(String url) throws IOException
SardinegetAcl in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic DavQuota getQuota(String url) throws IOException
SardinegetQuota in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic List<DavPrincipal> getPrincipals(String url) throws IOException
SardinegetPrincipals in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic List<String> getPrincipalCollectionSet(String url) throws IOException
SardinegetPrincipalCollectionSet in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic ContentLengthInputStream get(String url) throws IOException
SardineGET to download data from a server. The stream must be closed after reading.get in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic ContentLengthInputStream get(String url, Map<String,String> headers) throws IOException
SardineGET to download data from a server. The stream must be closed after reading.get in interface Sardineurl - Path to the resource including protocol and hostnameheaders - Additional HTTP headers to add to the requestIOException - I/O error or HTTP response validation failurepublic void put(String url, byte[] data) throws IOException
SardinePUT to send data to a server. Repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedata - Input sourceIOException - I/O error or HTTP response validation failurepublic void put(String url, byte[] data, String contentType) throws IOException
SardinePUT to send data to a server with a specific content type
header. Repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedata - Input sourcecontentType - MIME type to add to the HTTP request headerIOException - I/O error or HTTP response validation failurepublic void put(String url, InputStream dataStream) throws IOException
SardinePUT to send data to a server. Not repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedataStream - Input sourceIOException - I/O error or HTTP response validation failurepublic void put(String url, InputStream dataStream, String contentType) throws IOException
SardinePUT to send data to a server with a specific content
type header. Not repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedataStream - Input sourcecontentType - MIME type to add to the HTTP request headerIOException - I/O error or HTTP response validation failurepublic void put(String url, InputStream dataStream, String contentType, boolean expectContinue) throws IOException
SardinePUT to send data to a server with a specific content
type header. Not repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedataStream - Input sourcecontentType - MIME type to add to the HTTP request headerexpectContinue - Enable Expect: continue header for PUT requests.IOException - I/O error or HTTP response validation failurepublic void put(String url, InputStream dataStream, String contentType, boolean expectContinue, long contentLength) throws IOException
SardinePUT to send data to a server with a specific content
type header. Not repeatable on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedataStream - Input sourcecontentType - MIME type to add to the HTTP request headerexpectContinue - Enable Expect: continue header for PUT requests.contentLength - data size in bytes to set to Content-Length headerIOException - I/O error or HTTP response validation failurepublic void put(String url, InputStream dataStream, Map<String,String> headers) throws IOException
SardinePUT to send data to a server with specific headers. Not repeatable
on authentication failure.put in interface Sardineurl - Path to the resource including protocol and hostnamedataStream - Input sourceheaders - Additional HTTP headers to add to the requestIOException - I/O error or HTTP response validation failurepublic void put(String url, org.apache.http.HttpEntity entity, String contentType, boolean expectContinue) throws IOException
PUTurl - Resourceentity - The entity to read fromcontentType - Content Type headerexpectContinue - Add Expect: continue headerIOExceptionpublic void put(String url, org.apache.http.HttpEntity entity, Map<String,String> headers) throws IOException
PUTurl - Resourceentity - The entity to read fromheaders - Headers to add to requestIOExceptionpublic <T> T put(String url, org.apache.http.HttpEntity entity, Map<String,String> headers, org.apache.http.client.ResponseHandler<T> handler) throws IOException
IOExceptionpublic void delete(String url) throws IOException
SardineDELETE at the specified urldelete in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic void move(String sourceUrl, String destinationUrl) throws IOException
SardineMOVE. Assumes overwrite.move in interface SardinesourceUrl - Path to the resource including protocol and hostnamedestinationUrl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic void copy(String sourceUrl, String destinationUrl) throws IOException
SardineCOPY. Assumes overwrite.copy in interface SardinesourceUrl - Path to the resource including protocol and hostnamedestinationUrl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic void createDirectory(String url) throws IOException
SardineMKCOL to create a directory at the specified urlcreateDirectory in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failurepublic boolean exists(String url) throws IOException
SardineHEAD request to see if a resource exists or not.exists in interface Sardineurl - Path to the resource including protocol and hostnameIOException - I/O error or HTTP response validation failureprotected <T> T execute(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.client.ResponseHandler<T> responseHandler)
throws IOException
T - Return typerequest - Request to executeresponseHandler - Determines the return type.IOExceptionprotected org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpRequestBase request)
throws IOException
request - Request to executeIOExceptionpublic void shutdown()
Sardineprotected org.apache.http.impl.client.AbstractHttpClient createDefaultClient(ProxySelector selector)
protected org.apache.http.params.HttpParams createDefaultHttpParams()
protected org.apache.http.conn.scheme.SchemeRegistry createDefaultSchemeRegistry()
SchemeRegistry for default ports
with socket factories.SchemeRegistry.protected org.apache.http.conn.scheme.PlainSocketFactory createDefaultSocketFactory()
protected org.apache.http.conn.ssl.SSLSocketFactory createDefaultSecureSocketFactory()
protected org.apache.http.conn.ClientConnectionManager createDefaultConnectionManager(org.apache.http.conn.scheme.SchemeRegistry schemeRegistry)
schemeRegistry - Protocol registryprotected org.apache.http.conn.routing.HttpRoutePlanner createDefaultRoutePlanner(org.apache.http.conn.scheme.SchemeRegistry schemeRegistry,
ProxySelector selector)
schemeRegistry - Protocol registryselector - Proxy configurationCopyright © 2014. All rights reserved.