public class AlfrescoHttpClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
ALFRESCO_API_PATH |
static String |
ALFRESCO_API_VERSION |
static String |
MIME_TYPE_JSON |
static String |
UTF_8_ENCODING |
| Constructor and Description |
|---|
AlfrescoHttpClient(String scheme,
String host,
int port,
int sharePort) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the HttpClient.
|
void |
close(org.apache.http.impl.client.CloseableHttpClient client)
Closes the HttpClient.
|
org.apache.http.HttpResponse |
execute(String userName,
String password,
org.apache.http.client.methods.HttpRequestBase request)
Execute HttpClient request without releasing the connection
|
org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpRequestBase request)
Deprecated.
Execute HttpClient request.
|
org.apache.http.HttpResponse |
executeRequest(String userName,
String password,
org.apache.http.client.methods.HttpRequestBase request)
Execute HttpClient request.
|
org.apache.http.HttpResponse |
executeRequest(String userName,
String password,
org.json.simple.JSONObject body,
org.apache.http.client.methods.HttpEntityEnclosingRequestBase request)
Execute HttpClient POST OR PUT
|
String |
getAlfrescoUrl() |
String |
getAlfrescoVersion()
Get the alfresco version
|
String |
getAlfTicket(String username,
String password)
Generates an Alfresco Authentication Ticket based on the user name and password passed in.
|
String |
getApiUrl() |
String |
getApiVersionUrl() |
org.apache.http.client.HttpClient |
getClient() |
List<String> |
getElementsFromJsonArray(org.apache.http.HttpResponse response,
String objAbove,
String array,
String elementFromArray)
Get the elements from a JSONArray
|
String |
getHost() |
org.apache.http.impl.client.CloseableHttpClient |
getHttpClientWithBasicAuth(String username,
String password)
Get basic http client with basic credential.
|
org.json.simple.JSONArray |
getJSONArray(org.apache.http.HttpResponse response,
String firstParam,
String arrayName)
Get JSONArray from HttpResponse
|
String |
getParameterFromJSON(org.apache.http.HttpResponse response,
String parameter,
String... jsonObjs)
Get an element from HttpResponse
|
String |
getParameterFromJSON(String response,
String parameter,
String... jsonObjs)
Get an element from a string HttpResponse
|
int |
getPort() |
String |
getScheme() |
int |
getSharePort() |
String |
getShareUrl() |
String |
getSpecificElementFromJArray(org.apache.http.HttpResponse response,
String firstParam,
String array,
String itemName,
String itemParameter,
String requiredElement) |
org.json.simple.JSONObject |
readStream(org.apache.http.HttpEntity entity)
Parses http response stream into a
JSONObject. |
org.apache.http.entity.StringEntity |
setMessageBody(org.json.simple.JSONObject json)
Populate HTTP message call with given content.
|
public static final String UTF_8_ENCODING
public static final String MIME_TYPE_JSON
public static String ALFRESCO_API_PATH
public static String ALFRESCO_API_VERSION
public String getApiVersionUrl()
public String getAlfTicket(String username, String password)
username - user identifierpassword - user passwordpublic String getAlfrescoVersion()
public org.apache.http.entity.StringEntity setMessageBody(org.json.simple.JSONObject json)
json - JSONObject contentStringEntity content.public org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpRequestBase request)
request - to sendHttpResponse responsepublic org.apache.http.HttpResponse execute(String userName, String password, org.apache.http.client.methods.HttpRequestBase request)
userName - user namepassword - passwordrequest - to sendHttpResponse responsepublic org.apache.http.HttpResponse executeRequest(String userName, String password, org.apache.http.client.methods.HttpRequestBase request)
userName - String user namepassword - String passwordrequest - HttpRequestBase the requestHttpResponse responsepublic org.apache.http.HttpResponse executeRequest(String userName, String password, org.json.simple.JSONObject body, org.apache.http.client.methods.HttpEntityEnclosingRequestBase request)
userName - String user namepassword - String passwordbody - JSONObject body of the requestrequest - HttpEntityEnclosingRequestBase the requestHttpResponse responsepublic org.apache.http.impl.client.CloseableHttpClient getHttpClientWithBasicAuth(String username, String password)
username - String usernamepassword - String passwordCloseableHttpClient clientpublic org.json.simple.JSONObject readStream(org.apache.http.HttpEntity entity)
JSONObject.entity - Http response entityJSONObject responsepublic String getParameterFromJSON(org.apache.http.HttpResponse response, String parameter, String... jsonObjs)
response - responseparameter - wanted parameterjsonObjs - json objects to reach the parameterpublic String getParameterFromJSON(String response, String parameter, String... jsonObjs)
response - String responseparameter - String wanted parameterjsonObjs - String json objects to reach the parameterpublic List<String> getElementsFromJsonArray(org.apache.http.HttpResponse response, String objAbove, String array, String elementFromArray)
response - HttpResponse responsearray - String the name of the arrayelementFromArray - element from arraypublic String getSpecificElementFromJArray(org.apache.http.HttpResponse response, String firstParam, String array, String itemName, String itemParameter, String requiredElement)
public org.json.simple.JSONArray getJSONArray(org.apache.http.HttpResponse response,
String firstParam,
String arrayName)
response - HttpResponse the request responsefirstParam - String parameter that has the arrayarrayName - String array namepublic void close()
IOException - if errorpublic void close(org.apache.http.impl.client.CloseableHttpClient client)
client - CloseableHttpClient the clientIOException - if errorpublic org.apache.http.client.HttpClient getClient()
public String getScheme()
public String getHost()
public int getPort()
public int getSharePort()
public String getApiUrl()
public String getAlfrescoUrl()
public String getShareUrl()
Copyright © 2016 Alfresco Software. All rights reserved.