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) |
AlfrescoHttpClient(String scheme,
String host,
int port) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the HttpClient.
|
org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpRequestBase request)
Execute HttpClient request.
|
org.apache.http.HttpResponse |
executeRequest(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.protocol.HttpContext context)
Execute HttpClient request.
|
org.apache.http.client.methods.HttpPost |
generatePostRequest(String requestURL,
org.json.simple.JSONObject body)
Creates the post request message body.
|
String |
getAlfrescoUrl() |
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() |
String |
getHost() |
org.apache.http.client.HttpClient |
getHttpClientWithBasicAuth(String username,
String password)
Get basic http client with basic credential.
|
String |
getParameterFromJSON(String result,
String param)
Method to get parameters from JSON
|
int |
getPort() |
String |
getScheme() |
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) throws IOException, org.json.simple.parser.ParseException
username - user identifierpassword - user passwordorg.json.simple.parser.ParseException - if errorIOException - if errorpublic org.apache.http.client.methods.HttpPost generatePostRequest(String requestURL, org.json.simple.JSONObject body) throws Exception
requestURL - url end pointbody - content of requestHttpPost post request in json formatException - if errorpublic org.apache.http.entity.StringEntity setMessageBody(org.json.simple.JSONObject json)
throws UnsupportedEncodingException
json - JSONObject contentStringEntity content.UnsupportedEncodingException - if unsupportedpublic org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpRequestBase request)
throws Exception
request - to sendHttpResponse responseException - if errorpublic org.apache.http.HttpResponse executeRequest(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.protocol.HttpContext context)
throws Exception
request - the request to executecontext - the context to use for the executionHttpResponse responseException - if errorpublic org.apache.http.client.HttpClient getHttpClientWithBasicAuth(String username, String password)
username - String usernamepassword - String passwordHttpClient clientpublic org.json.simple.JSONObject readStream(org.apache.http.HttpEntity entity)
JSONObject.entity - Http response entityJSONObject responsepublic String getParameterFromJSON(String result, String param) throws org.json.simple.parser.ParseException
result - json messageparam - key identifierorg.json.simple.parser.ParseException - if error parsingpublic void close()
throws IOException
IOException - if errorpublic org.apache.http.client.HttpClient getClient()
public String getScheme()
public String getHost()
public int getPort()
public String getApiUrl()
public String getAlfrescoUrl()
Copyright © 2015 Alfresco Software. All rights reserved.