public class AbstractClient extends Object
Modifier and Type | Field and Description |
---|---|
protected HttpClient | client HTTP client used to connect to GeoRocket |
Constructor and Description |
---|
AbstractClient(HttpClient client) Construct a new client using the given HTTP client |
Modifier and Type | Method and Description |
---|---|
protected HttpClientRequest | configureRequest(HttpClientRequest request) Configure an HTTP request. |
protected static <T> void | fail(HttpClientResponse response, Handler<AsyncResult<T>> handler) Parses an HTTP response and calls the given handler with the parsed error message |
protected static <T> void | fail(HttpClientResponse response, Handler<AsyncResult<T>> handler, Function<String,Throwable> map) Parses an HTTP response, maps it to an exception and then calls the given handler |
protected void | getWithParameter(String endpoint, String parameterName, String parameterValue, String query, String layer, Handler<AsyncResult<ReadStream<Buffer>>> handler) Execute a get request with specified path, query and additional parameter |
protected String | prepareQuery(String query, String layer) Prepare a query. |
protected void | update(HttpMethod method, String fieldEndpoint, String fieldName, String query, String layer, List<String> updates, Handler<AsyncResult<Void>> handler) Update a field in the chunk metadata (such as properties or tags). |
protected String | urlencode(String str) Convenience method to URL-encode a string |
protected final HttpClient client
public AbstractClient(HttpClient client)
client
- the HTTP clientprotected void getWithParameter(String endpoint, String parameterName, String parameterValue, String query, String layer, Handler<AsyncResult<ReadStream<Buffer>>> handler)
endpoint
- the endpointparameterName
- the name of the query parameterparameterValue
- the value of the query parameterquery
- a search query specifying which chunks to return (may be null
)layer
- the name of the layer where to search for chunks recursively (may be null
)handler
- a handler that will receive the ReadStream
from which the results matching the given criteria can be readprotected void update(HttpMethod method, String fieldEndpoint, String fieldName, String query, String layer, List<String> updates, Handler<AsyncResult<Void>> handler)
Update a field in the chunk metadata (such as properties or tags).
The chunks are either specified by a query
or layer
information or both. If none is given, all chunks in the data store will be updated.
method
- the http method to use for the updatefieldEndpoint
- the path of the endpoint which should be usedfieldName
- the name of the field to updatequery
- a search query specifying the chunks, whose fields should be updated (or null
if the fields of all chunks in all sub-layers from the given layer
should be updated)layer
- the absolute path to the layer from which to update fields (or null
if the entire store should be queried to find the chunks, whose fields should be updated)updates
- a collection of values to updatehandler
- a handler that will be called when the operation has finishedprotected String prepareQuery(String query, String layer)
query
- the search query (may be null
)layer
- the layer to export (may be null
)protected String urlencode(String str)
str
- the stringprotected HttpClientRequest configureRequest(HttpClientRequest request)
request
- request the request to configureHttpClientRequest
as given but with options setprotected static <T> void fail(HttpClientResponse response, Handler<AsyncResult<T>> handler)
T
- the type of the handler's resultresponse
- the HTTP responsehandler
- the handler to callprotected static <T> void fail(HttpClientResponse response, Handler<AsyncResult<T>> handler, Function<String,Throwable> map)
T
- the type of the handler's resultresponse
- the HTTP responsehandler
- the handler to callmap
- a function that maps the parsed error message to an exception