public class RestClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RestClient.Pageable
Wraps paging and sorting
|
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
cookies |
protected org.springframework.web.client.RestTemplate |
restTemplate |
protected String |
url |
| Constructor and Description |
|---|
RestClient(String url)
Creates a new
RestClient. |
RestClient(String url,
Map<String,String> cookies)
Creates a new
RestClient, using an existing cookie. |
| Modifier and Type | Method and Description |
|---|---|
RestResponseEntity<Datasource> |
datasource(String application,
String id)
Retrieves the
Datasource. |
RestResponseEntity<Datasource> |
datasource(String application,
String id,
org.springframework.util.MultiValueMap<String,String> parameters)
Retrieves the
Datasource. |
RestResponseEntity<Datasource> |
datasource(String application,
String id,
RestClient.Pageable pageable)
Retrieves the
Datasource. |
RestResponseEntity<Datasource> |
datasource(String application,
String id,
RestClient.Pageable pageable,
org.springframework.util.MultiValueMap<String,String> parameters)
Retrieves the
Datasource. |
<OUT,IN> RestResponseEntity<IN> |
exchange(String path,
OUT body,
Class<IN> returnType,
org.springframework.http.HttpMethod method)
Retrieves a REST-Resource with a given HTTP method.
Example: |
protected <IN,OUT> RestResponseEntity<IN> |
exchange(URI uri,
OUT body,
org.springframework.http.HttpMethod method,
Class<IN> returnType) |
protected <IN,OUT> RestResponseEntity<IN> |
exchange(URI uri,
OUT body,
org.springframework.http.HttpMethod method,
Class<IN> returnType,
boolean acceptAnyType) |
RestResponseEntity<Action> |
getAction(Link link)
|
RestResponseEntity<Action> |
getAction(String application,
String eventId,
String actionId,
String... pathVariables)
Retrieves the
Action. |
protected URI |
getActionURL(String application,
String eventId,
String actionId,
String[] pathVariables) |
RestResponseEntity<byte[]> |
getBinaryData(Link link)
Returns the resource represented by the link as binary data
|
RestResponseEntity<byte[]> |
getBinaryData(String relativePath)
Returns the resource represented by the relative path
|
Map<String,String> |
getCookies()
Returns the current cookies or this client
|
protected org.springframework.http.HttpHeaders |
getHeaders(boolean acceptAnyType) |
<IN> RestResponseEntity<IN> |
getResource(String path,
Class<IN> returnType)
Retrieves a REST-Resource with HTTP GET.
Example: |
RestResponseEntity<Action> |
performAction(Action data,
Link link)
|
RestResponseEntity<Action> |
performAction(String application,
Action data,
String... pathVariables)
Performs an
Action. |
protected void |
setCookies(org.springframework.http.ResponseEntity<?> entity) |
protected org.springframework.web.client.RestTemplate restTemplate
protected String url
public RestClient(String url)
RestClient.
Note that you probably need to perform a login action before you can use this client.
url - the URL pointing to a site's service URL (/service/<site-name>)public RestClient(String url, Map<String,String> cookies)
RestClient, using an existing cookie. This cookie should be retrieved from another client
that performed a login action.url - the URL pointing to a site's service URL (/service/<site-name>)cookies - the cookie to usegetCookies()public RestResponseEntity<Datasource> datasource(String application, String id) throws URISyntaxException
Datasource.application - the name of the applicationid - the ID of the DatasourceDatasource wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Datasource> datasource(String application, String id, RestClient.Pageable pageable) throws URISyntaxException
Datasource.application - the name of the applicationid - the ID of the Datasourcepageable - a RestClient.Pageable (optional)Datasource wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Datasource> datasource(String application, String id, org.springframework.util.MultiValueMap<String,String> parameters) throws URISyntaxException
Datasource.application - the name of the applicationid - the ID of the Datasourceparameters - some additional parametersDatasource wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Datasource> datasource(String application, String id, RestClient.Pageable pageable, org.springframework.util.MultiValueMap<String,String> parameters) throws URISyntaxException
Datasource.application - the name of the applicationid - the ID of the Datasourcepageable - a RestClient.Pageable (optional)parameters - some additional parametersDatasource wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Action> getAction(String application, String eventId, String actionId, String... pathVariables) throws URISyntaxException
Action.application - the name of the applicationeventId - the event-ID of the ActionactionId - the ID of the ActionpathVariables - some additional path variablesAction wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Action> getAction(Link link) throws URISyntaxException
link - the Link representing the Action's URIAction wrapped in a RestResponseEntityURISyntaxException - if something is wrong with the URIpublic RestResponseEntity<Action> performAction(Action data, Link link) throws URISyntaxException
data - the Action-data to sendlink - the LinkRestResponseEntity wrapping the resulting ActionURISyntaxException - if something is wrong with the URIprotected void setCookies(org.springframework.http.ResponseEntity<?> entity)
protected URI getActionURL(String application, String eventId, String actionId, String[] pathVariables) throws URISyntaxException
URISyntaxExceptionpublic RestResponseEntity<Action> performAction(String application, Action data, String... pathVariables) throws URISyntaxException
Action.application - the name of the applicationdata - the Action-data to sendpathVariables - some additional path variablesRestResponseEntity wrapping the resulting ActionURISyntaxException - if something is wrong with the URIprotected org.springframework.http.HttpHeaders getHeaders(boolean acceptAnyType)
public Map<String,String> getCookies()
public RestResponseEntity<byte[]> getBinaryData(Link link) throws URISyntaxException
link - the ink to there resourceURISyntaxException - if something is wrong with the linkpublic RestResponseEntity<byte[]> getBinaryData(String relativePath) throws URISyntaxException
relativePath - the relative path, e.g. /application/rest/downloads/4711URISyntaxException - if something is wrong with the pathpublic <OUT,IN> RestResponseEntity<IN> exchange(String path, OUT body, Class<IN> returnType, org.springframework.http.HttpMethod method) throws URISyntaxException
ResponseEntityresult = restClient.retrieveResource("/application/rest/calculator/add/47/11", null, Integer.class, HttpMethod.GET)
path - the relative path to the resource, starting with the application's namebody - the request body (optional)returnType - the type of the responsemethod - the HttpMethod to useRestResponseEntityURISyntaxExceptionprotected <IN,OUT> RestResponseEntity<IN> exchange(URI uri, OUT body, org.springframework.http.HttpMethod method, Class<IN> returnType)
protected <IN,OUT> RestResponseEntity<IN> exchange(URI uri, OUT body, org.springframework.http.HttpMethod method, Class<IN> returnType, boolean acceptAnyType)
public <IN> RestResponseEntity<IN> getResource(String path, Class<IN> returnType) throws URISyntaxException
ResponseEntityresult = restClient.retrieveResource("/application/rest/calculator/add/47/11", null, Integer.class, HttpMethod.GET)
path - the relative path to the resource, starting with the application's namereturnType - the type of the responseRestResponseEntityURISyntaxExceptionCopyright © 2011–2020 aiticon GmbH. All rights reserved.