public class Host extends Folder
| Modifier and Type | Field and Description |
|---|---|
static List<QName> |
defaultFields |
String |
password |
Integer |
port |
String |
rootPath |
String |
server |
String |
user |
displayName, name, parent| Constructor and Description |
|---|
Host(String server,
Integer port,
String user,
String password,
ProxyDetails proxyDetails) |
Host(String server,
Integer port,
String user,
String password,
ProxyDetails proxyDetails,
Map<Folder,List<Resource>> cache) |
Host(String server,
String rootPath,
Integer port,
String user,
String password,
ProxyDetails proxyDetails,
int timeoutMillis,
Map<Folder,List<Resource>> cache,
FileSyncer fileSyncer) |
Host(String server,
String rootPath,
Integer port,
String user,
String password,
ProxyDetails proxyDetails,
Map<Folder,List<Resource>> cache) |
| Modifier and Type | Method and Description |
|---|---|
List<PropFindResponse> |
_doPropFind(String url,
int depth,
List<QName> fields) |
static Resource |
_find(Folder parent,
String[] arr,
int i,
boolean invalidateCache) |
void |
addConnectionListener(ConnectionListener e) |
void |
addCookie(String name,
String value) |
String |
baseHref() |
String |
buildEncodedUrl(Path path) |
void |
buildResponses(org.jdom.Document document,
Date serverDate,
List<PropFindResponse> responses,
int depth) |
int |
doCopy(String from,
String newUri) |
int |
doDelete(Path path)
Deletes the item at the given path, relative to the root path of this
host
|
int |
doDelete(String url) |
byte[] |
doGet(Path path) |
void |
doGet(Path path,
File file,
ProgressListener listener) |
byte[] |
doGet(Path path,
Map<String,String> queryParams) |
void |
doGet(Path path,
OutputStream out,
Map<String,String> queryParams) |
void |
doGet(String url,
StreamReceiver receiver,
List<Range> rangeList,
ProgressListener listener) |
String |
doLock(String uri)
Attempts to lock a resource with infinite timeout and returns the lock
token, which must be retained to unlock the resource
|
String |
doLock(String uri,
int timeout)
Attempts to lock a resource with the specified timeout and returns the
lock token, which must be retained to unlock the resource
|
int |
doMkCol(Path newUri)
Create a collection at the given absolute path.
|
int |
doMkCol(String newUri) |
int |
doMove(String sourceUrl,
String newUri) |
void |
doOptions(Path path) |
String |
doPost(String url,
Map<String,String> params)
POSTs the variables and returns the body
|
HttpResult |
doPut(Path path,
byte[] data,
String contentType) |
HttpResult |
doPut(Path remotePath,
File file,
IfMatchCheck matchCheck,
ProgressListener listener) |
HttpResult |
doPut(Path path,
InputStream content,
Long contentLength,
String contentType,
IfMatchCheck matchCheck) |
HttpResult |
doPut(String newUri,
InputStream content,
Long contentLength,
String contentType,
IfMatchCheck matchCheck,
ProgressListener listener)
Uploads the data.
|
int |
doUnLock(String uri,
String lockToken) |
String |
encodedUrl() |
Resource |
find(String path)
Finds the resource by iterating through the path parts resolving
collections as it goes.
|
Resource |
find(String path,
boolean invalidateCache) |
byte[] |
get(Path path)
GET the contents of the given path.
|
byte[] |
get(String path)
Retrieve the bytes at the specified path.
|
org.apache.http.client.HttpClient |
getClient() |
Map<String,String> |
getCookies() |
Folder |
getFolder(String path)
Find a folder at the given path.
|
String |
getHref(Path path)
Returns the fully qualified URL for the given path
|
static org.jdom.Document |
getJDomDocument(InputStream in) |
Folder |
getOrCreateFolder(Path remoteParentPath,
boolean create) |
org.jdom.Document |
getResponseAsDocument(InputStream in) |
int |
getTimeout() |
Host |
host() |
String |
href()
Returns the UN-encoded url
|
boolean |
isSecure() |
boolean |
isUseDigestForPreemptiveAuth() |
boolean |
isUsePreemptiveAuth() |
protected org.apache.http.protocol.HttpContext |
newContext() |
void |
options(String path) |
List<PropFindResponse> |
propFind(Path path,
int depth,
List<QName> fields) |
List<PropFindResponse> |
propFind(Path path,
int depth,
QName... fields) |
List<PropFindResponse> |
propFind(String path,
int depth,
QName... fields) |
void |
setSecure(boolean secure) |
void |
setTimeout(int timeout) |
void |
setUseDigestForPreemptiveAuth(boolean useDigestForPreemptiveAuth) |
void |
setUsePreemptiveAuth(boolean usePreemptiveAuth) |
addListener, child, children, createFolder, downloadTo, flush, getChild, hasChildren, numChildren, post, removeListener, toString, upload, upload, upload, upload, upload, uploadFile, uploadFile, uploadFile, uploadFolderaddListener, copyTo, copyTo, decodePath, delete, encodedName, finalize, getCount, getCreatedDate, getLockOwner, getLockToken, getModifiedDate, lock, lock, moveTo, moveTo, path, post, removeListener, rename, unlockpublic final String server
public final Integer port
public final String user
public final String password
public final String rootPath
public Host(String server, Integer port, String user, String password, ProxyDetails proxyDetails)
public Host(String server, Integer port, String user, String password, ProxyDetails proxyDetails, Map<Folder,List<Resource>> cache)
public Host(String server, String rootPath, Integer port, String user, String password, ProxyDetails proxyDetails, Map<Folder,List<Resource>> cache)
public static org.jdom.Document getJDomDocument(InputStream in) throws org.jdom.JDOMException
org.jdom.JDOMExceptionpublic Resource find(String path) throws IOException, HttpException, NotAuthorizedException, BadRequestException
path - IOExceptionHttpExceptionNotAuthorizedExceptionBadRequestExceptionpublic Resource find(String path, boolean invalidateCache) throws IOException, HttpException, NotAuthorizedException, BadRequestException
public static Resource _find(Folder parent, String[] arr, int i, boolean invalidateCache) throws IOException, HttpException, NotAuthorizedException, BadRequestException
public Folder getFolder(String path) throws IOException, HttpException, NotAuthorizedException, BadRequestException
path - IOExceptionHttpExceptionNotAuthorizedExceptionBadRequestExceptionpublic int doMkCol(Path newUri) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
newUri - HttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic int doMkCol(String newUri) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
newUri - - must be fully qualified and correctly encodedHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic String doLock(String uri) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
uri - - must be encodedHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic String doLock(String uri, int timeout) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
uri - - must be encodedtimeout - lock timeout in seconds, or -1 if infiniteHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic int doUnLock(String uri, String lockToken) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
uri - - must be encodedlockToken - HttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic HttpResult doPut(Path path, InputStream content, Long contentLength, String contentType, IfMatchCheck matchCheck)
path - - an Un-encoded path. Eg /a/b c/ = /a/b%20c/content - contentLength - contentType - public HttpResult doPut(Path path, byte[] data, String contentType)
public HttpResult doPut(Path remotePath, File file, IfMatchCheck matchCheck, ProgressListener listener) throws FileNotFoundException, HttpException, Utils.CancelledException, NotAuthorizedException, ConflictException
remotePath - file - listener - FileNotFoundExceptionHttpExceptionUtils.CancelledExceptionNotAuthorizedExceptionConflictExceptionpublic HttpResult doPut(String newUri, InputStream content, Long contentLength, String contentType, IfMatchCheck matchCheck, ProgressListener listener)
newUri - - encoded full URLcontent - contentLength - contentType - public int doCopy(String from, String newUri) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
from - - encoded source urlnewUri - - encoded destinationHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic int doDelete(Path path) throws IOException, HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException
path - - unencoded and relative to Host's rootPathIOExceptionHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionpublic int doDelete(String url) throws IOException, HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException
url - - encoded urlIOExceptionHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionpublic int doMove(String sourceUrl, String newUri) throws IOException, HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException, URISyntaxException
sourceUrl - - encoded source urlnewUri - - encoded destination urlIOExceptionHttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionURISyntaxExceptionpublic List<PropFindResponse> propFind(Path path, int depth, QName... fields) throws IOException, HttpException, NotAuthorizedException, BadRequestException
public List<PropFindResponse> propFind(String path, int depth, QName... fields) throws IOException, HttpException, NotAuthorizedException, BadRequestException
public List<PropFindResponse> propFind(Path path, int depth, List<QName> fields) throws IOException, HttpException, NotAuthorizedException, BadRequestException
path - - unencoded path, which will be evaluated relative to this
Host's basePathdepth - - 1 is to find immediate children, 2 includes their
children, etcfields - - the list of fields to get, or null to use default fieldsIOExceptionHttpExceptionNotAuthorizedExceptionBadRequestExceptionpublic List<PropFindResponse> _doPropFind(String url, int depth, List<QName> fields) throws IOException, HttpException, NotAuthorizedException, BadRequestException
url - - the encoded absolute URL to query. This method does not
apply basePathdepth - - depth to generate responses for. Zero means only the
specified url, 1 means it and its direct children, etcIOExceptionHttpExceptionNotAuthorizedExceptionBadRequestExceptionpublic void buildResponses(org.jdom.Document document,
Date serverDate,
List<PropFindResponse> responses,
int depth)
public org.jdom.Document getResponseAsDocument(InputStream in) throws IOException
IOExceptionpublic void doGet(String url, StreamReceiver receiver, List<Range> rangeList, ProgressListener listener) throws HttpException, Utils.CancelledException, NotAuthorizedException, BadRequestException, ConflictException, NotFoundException
url - - fully qualified and encoded URLreceiver - rangeList - - if null does a normal GET requestHttpExceptionUtils.CancelledExceptionNotAuthorizedExceptionBadRequestExceptionConflictExceptionNotFoundExceptionpublic void doGet(Path path, File file, ProgressListener listener) throws IOException, NotFoundException, HttpException, Utils.CancelledException, NotAuthorizedException, BadRequestException, ConflictException
path - - the path to get, relative to the base path of the hostfile - - the file to write content tolistener - IOExceptionNotFoundExceptionHttpExceptionUtils.CancelledExceptionNotAuthorizedExceptionBadRequestExceptionConflictExceptionpublic byte[] doGet(Path path) throws IOException, NotFoundException, HttpException, NotAuthorizedException, BadRequestException, ConflictException
public byte[] doGet(Path path, Map<String,String> queryParams) throws IOException, NotFoundException, HttpException, NotAuthorizedException, BadRequestException, ConflictException
public void doGet(Path path, OutputStream out, Map<String,String> queryParams) throws IOException, NotFoundException, HttpException, NotAuthorizedException, BadRequestException, ConflictException
public void options(String path) throws ConnectException, NotAuthorizedException, UnknownHostException, SocketTimeoutException, IOException, HttpException, NotFoundException
path - - encoded path, but not fully qualified. Must not be prefixed
with a slash, as it will be appended to the host's URLConnectExceptionNotAuthorizedExceptionUnknownHostExceptionSocketTimeoutExceptionIOExceptionHttpExceptionNotFoundExceptionpublic void doOptions(Path path) throws NotFoundException, NotAuthorizedException, IOException, HttpException
public byte[] get(Path path) throws HttpException, NotAuthorizedException, BadRequestException, ConflictException, NotFoundException
path - HttpExceptionNotAuthorizedExceptionBadRequestExceptionConflictExceptionNotFoundExceptionpublic byte[] get(String path) throws HttpException, NotAuthorizedException, BadRequestException, ConflictException, NotFoundException
path - - encoded and relative to host's rootPath. Must NOT be slash
prefixed as it will be appended to the host's urlHttpExceptionNotAuthorizedExceptionBadRequestExceptionConflictExceptionNotFoundExceptionpublic String doPost(String url, Map<String,String> params) throws HttpException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException
url - - fully qualified and encoded URL to post toparams - HttpExceptionNotAuthorizedExceptionConflictExceptionBadRequestExceptionNotFoundExceptionpublic String baseHref()
public String getHref(Path path)
path - public String encodedUrl()
encodedUrl in class Folderpublic Folder getOrCreateFolder(Path remoteParentPath, boolean create) throws HttpException, IOException, NotAuthorizedException, ConflictException, BadRequestException, NotFoundException
public int getTimeout()
public void setTimeout(int timeout)
timeout - the timeout to setpublic void addConnectionListener(ConnectionListener e)
public boolean isSecure()
public void setSecure(boolean secure)
public org.apache.http.client.HttpClient getClient()
public boolean isUseDigestForPreemptiveAuth()
public void setUseDigestForPreemptiveAuth(boolean useDigestForPreemptiveAuth)
public boolean isUsePreemptiveAuth()
public void setUsePreemptiveAuth(boolean usePreemptiveAuth)
protected org.apache.http.protocol.HttpContext newContext()
Copyright © 2021 McEvoy Software Ltd. All rights reserved.