Class SardineImpl
java.lang.Object
com.github.sardine.impl.SardineImpl
- All Implemented Interfaces:
Sardine
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAccess resources with no authenticationSardineImpl(String bearerAuth) Access resources with Bearer authorizationSardineImpl(String username, String password) Supports standard authentication mechanismsSardineImpl(String username, String password, ProxySelector selector) SardineImpl(org.apache.http.impl.client.HttpClientBuilder builder) SardineImpl(org.apache.http.impl.client.HttpClientBuilder builder, String username, String password) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.http.impl.client.HttpClientBuilderconfigure(ProxySelector selector, org.apache.http.client.CredentialsProvider credentials) Creates a client with all of the defaults.voidCopy 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.protected org.apache.http.conn.HttpClientConnectionManagercreateDefaultConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> schemeRegistry) Use fail fast connection manager when connections are not released properly.protected SardineRedirectStrategyprotected org.apache.http.conn.routing.HttpRoutePlannercreateDefaultRoutePlanner(org.apache.http.conn.SchemePortResolver resolver, ProxySelector selector) Override to provide proxy configurationprotected org.apache.http.impl.conn.DefaultSchemePortResolverprotected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> Creates a new registry for default ports with socket factories.protected org.apache.http.conn.socket.ConnectionSocketFactoryprotected org.apache.http.conn.socket.ConnectionSocketFactoryvoidcreateDirectory(String url) Uses WebDAVMKCOLto create a directory at the specified urlvoidDelete a resource using HTTPDELETEat the specified urlvoidDelete a resource using HTTPDELETEat the specified urlvoidDisable GZIP compression header.voidDisable preemptive authentication.voidAdds handling of GZIP compression to the client.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.voidenablePreemptiveAuthentication(String hostname, int httpPort, int httpsPort, Charset credentialsCharset) voidSend aBasicauthentication header with each request even before 401 is returned.protected org.apache.http.HttpResponseexecute(org.apache.http.client.methods.HttpRequestBase request) No validation of the response.protected <T> Texecute(org.apache.http.client.methods.HttpRequestBase request, org.apache.http.client.ResponseHandler<T> responseHandler) Validate the response using the response handler.protected <T> Texecute(org.apache.http.client.protocol.HttpClientContext context, org.apache.http.client.methods.HttpRequestBase request, org.apache.http.client.ResponseHandler<T> responseHandler) Common method as single entry point responsible fo request executionbooleanPerforms 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) voidIgnores cookies by always returning the IgnoreSpecFactory regardless of the cookieSpec value being looked up.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.Creates aPropertyupdateelement containing all properties to set from setProps and all properties to remove from removeProps.Add or remove custom properties for a url using WebDAVPROPPATCH.Add custom properties for a url WebDAVPROPPATCH.Creates aPropertyupdateelement containing all properties to set from setProps and all properties to remove from removeProps.protected List<DavResource> 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.voidput(String url, InputStream dataStream, List<org.apache.http.Header> headers) voidUsesPUTto send data to a server with specific headers.voidUpload the entity usingPUTvoidUpload the entity usingPUT<T> Tput(String url, org.apache.http.HttpEntity entity, List<org.apache.http.Header> headers, org.apache.http.client.ResponseHandler<T> handler) 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) voidsetCredentials(org.apache.http.client.CredentialsProvider provider) voidvoidshutdown()Releasing any resources that might be held open.voidUnlock the resource.
-
Field Details
-
client
protected org.apache.http.impl.client.CloseableHttpClient clientHTTP client implementation -
context
protected org.apache.http.client.protocol.HttpClientContext contextLocal context with authentication cache. Make sure the same context is used to execute logically related requests.
-
-
Constructor Details
-
SardineImpl
public SardineImpl()Access resources with no authentication -
SardineImpl
Access resources with Bearer authorization -
SardineImpl
-
SardineImpl
- Parameters:
username- Use in authentication header credentialspassword- Use in authentication header credentialsselector- Proxy configuration
-
SardineImpl
public SardineImpl(org.apache.http.impl.client.HttpClientBuilder builder) - Parameters:
builder- Custom client configuration
-
SardineImpl
-
-
Method Details
-
setCredentials
Add credentials to any scope. Supports Basic, Digest and NTLM authentication methods.- Specified by:
setCredentialsin interfaceSardine- Parameters:
username- Use in authentication header credentialspassword- Use in authentication header credentials
-
setCredentials
- Specified by:
setCredentialsin interfaceSardine- Parameters:
username- Use in authentication header credentialspassword- Use in authentication header credentialsdomain- NTLM authenticationworkstation- NTLM authentication
-
setCredentials
public void setCredentials(org.apache.http.client.CredentialsProvider provider) -
enableCompression
public void enableCompression()Adds handling of GZIP compression to the client.- Specified by:
enableCompressionin interfaceSardine
-
disableCompression
public void disableCompression()Disable GZIP compression header.- Specified by:
disableCompressionin interfaceSardine- See Also:
-
ignoreCookies
public void ignoreCookies()Ignores cookies by always returning the IgnoreSpecFactory regardless of the cookieSpec value being looked up.- Specified by:
ignoreCookiesin interfaceSardine
-
enablePreemptiveAuthentication
Description copied from interface:SardineSend aBasicauthentication header with each request even before 401 is returned. Uses default ports: 80 for http and 443 for https- Specified by:
enablePreemptiveAuthenticationin interfaceSardine- Parameters:
hostname- The hostname to enable preemptive authentication for.
-
enablePreemptiveAuthentication
Description copied from interface:SardineSend aBasicauthentication header with each request even before 401 is returned.- Specified by:
enablePreemptiveAuthenticationin interfaceSardine- Parameters:
url- The hostname, protocol and port to enable preemptive authentication for.
-
enablePreemptiveAuthentication
Description copied from interface:SardineSend aBasicauthentication header with each request even before 401 is returned.- Specified by:
enablePreemptiveAuthenticationin interfaceSardine- 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.
-
enablePreemptiveAuthentication
-
disablePreemptiveAuthentication
public void disablePreemptiveAuthentication()Description copied from interface:SardineDisable preemptive authentication.- Specified by:
disablePreemptiveAuthenticationin interfaceSardine
-
getResources
- Specified by:
getResourcesin interfaceSardine- Throws:
IOException- See Also:
-
list
Description copied from interface:SardineGets a directory listing using WebDAVPROPFIND.- Specified by:
listin interfaceSardine- 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
Description copied from interface:SardineGets a directory listing using WebDAVPROPFIND.- Specified by:
listin interfaceSardine- 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
Description copied from interface:SardineGets a directory listing using WebDAVPROPFIND.- Specified by:
listin interfaceSardine- 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
-
list
Description copied from interface:SardineGets a directory listing using WebDAVPROPFIND.- Specified by:
listin interfaceSardine- 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
-
propfind
Description copied from interface:SardineFetches a resource using WebDAVPROPFIND. Only the specified properties are retrieved.- Specified by:
propfindin interfaceSardine- 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
-
propfind
- Throws:
IOException
-
report
Description copied from interface:SardineRuns a report on the given resource using WebDAVREPORT.- Specified by:
reportin interfaceSardine- 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
Description copied from interface:SardinePerform a search of the Webdav repository.- Specified by:
searchin interfaceSardine- 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
public void setCustomProps(String url, Map<String, String> set, List<String> remove) throws IOException- Specified by:
setCustomPropsin interfaceSardine- Throws:
IOException- See Also:
-
patch
Description copied from interface:SardineAdd custom properties for a url WebDAVPROPPATCH.- Specified by:
patchin interfaceSardine- Parameters:
url- Path to the resource including protocol and hostnamesetProps- 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
public List<DavResource> patch(String url, Map<QName, String> setProps, List<QName> removeProps) throws IOExceptionCreates aPropertyupdateelement containing all properties to set from setProps and all properties to remove from removeProps. Note this method will use aSardineUtil.CUSTOM_NAMESPACE_URIas namespace andSardineUtil.CUSTOM_NAMESPACE_PREFIXas prefix.- Specified by:
patchin interfaceSardine- Parameters:
url- 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.- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
patch
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps) throws IOException Creates aPropertyupdateelement containing all properties to set from setProps and all properties to remove from removeProps. Note this method will use aSardineUtil.CUSTOM_NAMESPACE_URIas namespace andSardineUtil.CUSTOM_NAMESPACE_PREFIXas prefix.- Specified by:
patchin interfaceSardine- Parameters:
url- 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.- Returns:
- The patched resources from the response
- Throws:
IOException- I/O error or HTTP response validation failure
-
patch
public List<DavResource> patch(String url, List<Element> setProps, List<QName> removeProps, Map<String, String> headers) throws IOExceptionDescription copied from interface:SardineAdd or remove custom properties for a url using WebDAVPROPPATCH.- Specified by:
patchin interfaceSardine- Parameters:
url- 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.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
-
lock
Description copied from interface:SardinePut 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.- Specified by:
lockin interfaceSardine- 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
Description copied from interface:SardineA 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).- Specified by:
refreshLockin interfaceSardine- 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
Description copied from interface:SardineUnlock 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.- Specified by:
unlockin interfaceSardine- 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:
-
setAcl
Description copied from interface:SardineWrite access control list for resource- Specified by:
setAclin interfaceSardine- Parameters:
url- Path to the resource including protocol and hostnameaces- Access control elements- Throws:
IOException- I/O error or HTTP response validation failure
-
getAcl
Description copied from interface:SardineRead access control list for resource- Specified by:
getAclin interfaceSardine- 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
Description copied from interface:SardineRead quota properties for resource- Specified by:
getQuotain interfaceSardine- 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
-
getPrincipals
Description copied from interface:SardineList the principals that can be used to set ACLs on given url- Specified by:
getPrincipalsin interfaceSardine- 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
Description copied from interface:SardineThe principals that are available on the server that implements this resource.- Specified by:
getPrincipalCollectionSetin interfaceSardine- 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
-
get
Description copied from interface:SardineUses HTTPGETto download data from a server. The stream must be closed after reading.- Specified by:
getin interfaceSardine- 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
Description copied from interface:SardineUses HTTPGETto download data from a server. The stream must be closed after reading.- Specified by:
getin interfaceSardine- 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
-
get
public ContentLengthInputStream get(String url, List<org.apache.http.Header> headers) throws IOException - Throws:
IOException
-
put
Description copied from interface:SardineUses HTTPPUTto send data to a server. Repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
Description copied from interface:SardineUsesPUTto send data to a server with a specific content type header. Repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
Description copied from interface:SardineUsesPUTto send data to a server. Not repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
Description copied from interface:SardineUsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
public void put(String url, InputStream dataStream, String contentType, boolean expectContinue) throws IOException Description copied from interface:SardineUsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
public void put(String url, InputStream dataStream, String contentType, boolean expectContinue, long contentLength) throws IOException Description copied from interface:SardineUsesPUTto send data to a server with a specific content type header. Not repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
Description copied from interface:SardineUsesPUTto send data to a server with specific headers. Not repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
public void put(String url, InputStream dataStream, List<org.apache.http.Header> headers) throws IOException - Throws:
IOException
-
put
public void put(String url, org.apache.http.HttpEntity entity, String contentType, boolean expectContinue) throws IOException Upload the entity usingPUT- Parameters:
url- Resourceentity- The entity to read fromcontentType- Content Type headerexpectContinue- AddExpect: continueheader- Throws:
IOException
-
put
public void put(String url, org.apache.http.HttpEntity entity, List<org.apache.http.Header> headers) throws IOException Upload the entity usingPUT- Parameters:
url- Resourceentity- The entity to read fromheaders- Headers to add to request- Throws:
IOException
-
put
public <T> T put(String url, org.apache.http.HttpEntity entity, List<org.apache.http.Header> headers, org.apache.http.client.ResponseHandler<T> handler) throws IOException - Throws:
IOException
-
put
Description copied from interface:SardineUsesPUTto upload file to a server with specific contentType. Repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
public void put(String url, File localFile, String contentType, boolean expectContinue) throws IOException Description copied from interface:SardineUsesPUTto upload file to a server with specific contentType. Repeatable on authentication failure.- Specified by:
putin interfaceSardine- 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
Description copied from interface:SardineDelete a resource using HTTPDELETEat the specified url- Specified by:
deletein interfaceSardine- 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
Description copied from interface:SardineDelete a resource using HTTPDELETEat the specified url- Specified by:
deletein interfaceSardine- 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
-
move
Description copied from interface:SardineMove a url to from source to destination using WebDAVMOVE. Assumes overwrite.- Specified by:
movein interfaceSardine- 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
Description copied from interface:SardineMove a url to from source to destination using WebDAVMOVE.- Specified by:
movein interfaceSardine- 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
public void move(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOExceptionDescription copied from interface:SardineMove a url to from source to destination using WebDAVMOVE.- Specified by:
movein interfaceSardine- 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
Description copied from interface:SardineCopy a url from source to destination using WebDAVCOPY. Assumes overwrite.- Specified by:
copyin interfaceSardine- 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
Description copied from interface:SardineCopy a url from source to destination using WebDAVCOPY.- Specified by:
copyin interfaceSardine- 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
public void copy(String sourceUrl, String destinationUrl, boolean overwrite, Map<String, String> headers) throws IOExceptionDescription copied from interface:SardineCopy a url from source to destination using WebDAVCOPY.- Specified by:
copyin interfaceSardine- 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
-
createDirectory
Description copied from interface:SardineUses WebDAVMKCOLto create a directory at the specified url- Specified by:
createDirectoryin interfaceSardine- Parameters:
url- Path to the resource including protocol and hostname- Throws:
IOException- I/O error or HTTP response validation failure
-
exists
Description copied from interface:SardinePerforms a HTTPHEADrequest to see if a resource exists or not.- Specified by:
existsin interfaceSardine- 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
-
execute
protected <T> T execute(org.apache.http.client.methods.HttpRequestBase request, org.apache.http.client.ResponseHandler<T> responseHandler) throws IOException Validate the response using the response handler. Aborts the request if there is an exception.- Type Parameters:
T- Return type- Parameters:
request- Request to executeresponseHandler- Determines the return type.- Returns:
- parsed response
- Throws:
IOException
-
execute
protected org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpRequestBase request) throws IOException No validation of the response. Aborts the request if there is an exception.- Parameters:
request- Request to execute- Returns:
- The response to check the reply status code
- Throws:
IOException
-
execute
protected <T> T execute(org.apache.http.client.protocol.HttpClientContext context, org.apache.http.client.methods.HttpRequestBase request, org.apache.http.client.ResponseHandler<T> responseHandler) throws IOException Common method as single entry point responsible fo request execution- Type Parameters:
T- will return raw HttpResponse when responseHandler is null or value reslved using provided ResponseHandler instance- Parameters:
context- clientContext to be used when executing requestrequest- Request to executeresponseHandler- can be null if you need raw HttpResponse or not null response handler for result handling.- Returns:
- value resolved using response handler or raw HttpResponse when responseHandler is null
- Throws:
IOException
-
shutdown
Description copied from interface:SardineReleasing 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.- Specified by:
shutdownin interfaceSardine- Throws:
IOException
-
configure
protected org.apache.http.impl.client.HttpClientBuilder configure(ProxySelector selector, org.apache.http.client.CredentialsProvider credentials) Creates a client with all of the defaults.- Parameters:
selector- Proxy configuration or nullcredentials- Authentication credentials or null
-
createDefaultSchemePortResolver
protected org.apache.http.impl.conn.DefaultSchemePortResolver createDefaultSchemePortResolver() -
createDefaultRedirectStrategy
-
createDefaultSchemeRegistry
protected org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> createDefaultSchemeRegistry()Creates a new registry for default ports with socket factories. -
createDefaultSocketFactory
protected org.apache.http.conn.socket.ConnectionSocketFactory createDefaultSocketFactory()- Returns:
- Default socket factory
-
createDefaultSecureSocketFactory
protected org.apache.http.conn.socket.ConnectionSocketFactory createDefaultSecureSocketFactory()- Returns:
- Default SSL socket factory
-
createDefaultConnectionManager
protected org.apache.http.conn.HttpClientConnectionManager createDefaultConnectionManager(org.apache.http.config.Registry<org.apache.http.conn.socket.ConnectionSocketFactory> schemeRegistry) Use fail fast connection manager when connections are not released properly.- Parameters:
schemeRegistry- Protocol registry- Returns:
- Default connection manager
-
createDefaultRoutePlanner
protected org.apache.http.conn.routing.HttpRoutePlanner createDefaultRoutePlanner(org.apache.http.conn.SchemePortResolver resolver, ProxySelector selector) Override to provide proxy configuration- Parameters:
resolver- Protocol registryselector- Proxy configuration- Returns:
- ProxySelectorRoutePlanner configured with schemeRegistry and selector
-