public abstract class BaseCloudwordsClient extends Object
Modifier and Type | Field and Description |
---|---|
protected double |
apiVersion |
protected String |
baseUrlWithVersion |
protected static int |
connectionTimeoutMillis |
protected static String |
CW_FILE_PARAM |
protected static String |
CW_SOURCE_PARAM |
protected static String |
JSON_CONTENT_TYPE |
protected static int |
maxTotalConnections |
protected static int |
socketTimeoutMillis |
static String |
UTF_8 |
protected static String |
ZIP_CONTENT_TYPE |
Constructor and Description |
---|
BaseCloudwordsClient() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addZipEntry(ZipOutputStream zos,
String dirName,
File fileToAdd)
Adds zip entry to passed output stream.
|
protected String |
buildQuery(Object params) |
protected void |
delete(String path) |
InputStream |
downloadFileFromMetadata(CloudwordsFile metadata) |
protected org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpUriRequest request) |
protected <T> T |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
Class<T> expectedResponseType) |
protected <T> T |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
com.fasterxml.jackson.databind.JavaType expectedResponseType) |
protected <T> T |
executeRequest(org.apache.http.client.methods.HttpUriRequest request,
com.fasterxml.jackson.core.type.TypeReference<T> expectedResponseType) |
protected <T> T |
get(String path,
Class<T> type) |
protected <T> T |
get(String path,
com.fasterxml.jackson.core.type.TypeReference<T> type,
Object params) |
protected abstract String |
getAuthToken() |
protected abstract org.apache.http.client.HttpClient |
getClient() |
protected static String |
getFilename(String nameWithExtension)
Returns filename without extension.
|
protected <T> List<T> |
getList(String path,
Class<T> elemType) |
protected abstract com.fasterxml.jackson.databind.ObjectMapper |
getMapper() |
protected void |
initObjectMapper() |
protected boolean |
isErrorCodeMatched(int statusCode,
int codeToMatch) |
protected boolean |
isRequestSuccessful(int statusCode) |
protected org.apache.http.HttpResponse |
postFile(String path,
File file) |
protected <T> T |
postFile(String path,
File file,
Class<T> returnType) |
protected <T> T |
put(String path,
T object) |
protected void |
putFile(String path,
File file) |
protected <T> T |
putFile(String path,
File file,
Class<T> returnType) |
protected <T> List<T> |
putList(String path,
Class<T> elemType,
List<T> objects) |
protected void |
setBasicHeaders(org.apache.http.client.methods.HttpUriRequest request,
String acceptContentType,
String bodyContentType) |
protected InputStream |
streamFileFromPath(String path)
Stream the requested file back to the http response.
|
protected void |
validateZipFile(File zipFile) |
public static final String UTF_8
protected static final String JSON_CONTENT_TYPE
protected static final String ZIP_CONTENT_TYPE
protected static final String CW_FILE_PARAM
protected static final String CW_SOURCE_PARAM
protected static final int connectionTimeoutMillis
protected static final int socketTimeoutMillis
protected static final int maxTotalConnections
protected String baseUrlWithVersion
protected double apiVersion
protected abstract org.apache.http.client.HttpClient getClient()
protected abstract com.fasterxml.jackson.databind.ObjectMapper getMapper()
protected abstract String getAuthToken()
public InputStream downloadFileFromMetadata(CloudwordsFile metadata) throws IllegalStateException, CloudwordsClientException, IOException
protected <T> T executeRequest(org.apache.http.client.methods.HttpUriRequest request, Class<T> expectedResponseType) throws CloudwordsClientException
CloudwordsClientException
protected <T> T executeRequest(org.apache.http.client.methods.HttpUriRequest request, com.fasterxml.jackson.core.type.TypeReference<T> expectedResponseType) throws CloudwordsClientException
CloudwordsClientException
protected <T> T executeRequest(org.apache.http.client.methods.HttpUriRequest request, com.fasterxml.jackson.databind.JavaType expectedResponseType) throws CloudwordsClientException
CloudwordsClientException
protected <T> T get(String path, Class<T> type) throws CloudwordsClientException
CloudwordsClientException
protected <T> T get(String path, com.fasterxml.jackson.core.type.TypeReference<T> type, Object params) throws CloudwordsClientException
CloudwordsClientException
protected <T> List<T> getList(String path, Class<T> elemType) throws CloudwordsClientException
CloudwordsClientException
protected <T> T put(String path, T object) throws CloudwordsClientException
CloudwordsClientException
protected <T> List<T> putList(String path, Class<T> elemType, List<T> objects) throws CloudwordsClientException
CloudwordsClientException
protected <T> T postFile(String path, File file, Class<T> returnType) throws CloudwordsClientException
CloudwordsClientException
protected org.apache.http.HttpResponse postFile(String path, File file) throws CloudwordsClientException
CloudwordsClientException
protected <T> T putFile(String path, File file, Class<T> returnType) throws CloudwordsClientException
CloudwordsClientException
protected void putFile(String path, File file) throws CloudwordsClientException
CloudwordsClientException
protected void delete(String path) throws CloudwordsClientException
CloudwordsClientException
protected org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpUriRequest request) throws CloudwordsClientException
CloudwordsClientException
protected void setBasicHeaders(org.apache.http.client.methods.HttpUriRequest request, String acceptContentType, String bodyContentType)
protected void initObjectMapper()
protected boolean isRequestSuccessful(int statusCode)
protected boolean isErrorCodeMatched(int statusCode, int codeToMatch)
protected void validateZipFile(File zipFile) throws CloudwordsClientException
CloudwordsClientException
protected InputStream streamFileFromPath(String path) throws CloudwordsClientException, IllegalStateException, IOException
protected static String getFilename(String nameWithExtension)
nameWithExtension
- protected static void addZipEntry(ZipOutputStream zos, String dirName, File fileToAdd) throws IOException
zos
- Zip output streamdirName
- Destination zip directoryfileToAdd
- File in zip entryIOException
Copyright © 2016. All rights reserved.