public class StoreClient extends Object
Constructor and Description |
---|
StoreClient(HttpClient client) Construct a new store client using the given HTTP client |
Modifier and Type | Method and Description |
---|---|
protected HttpClientRequest | configureRequest(HttpClientRequest request) Configure an HTTP request. |
void | delete(String query, Handler<AsyncResult<Void>> handler) Delete chunks from the GeoRocket data store. |
void | delete(String query, String layer, Handler<AsyncResult<Void>> handler) Delete chunks or layers from the GeoRocket data store. |
protected String | getEndpoint() Return the HTTP endpoint, the GeoRocket data store path at server side. |
protected String | prepareImport(String layer, Collection<String> tags) Prepare an import. |
protected String | prepareQuery(String query, String layer) Prepare a query. |
void | search(Handler<AsyncResult<ReadStream<Buffer>>> handler) Export the contents of the whole GeoRocket data store. |
void | search(String query, Handler<AsyncResult<ReadStream<Buffer>>> handler) Search the GeoRocket data store and return a ReadStream of merged chunks matching the given criteria. |
void | search(String query, String layer, Handler<AsyncResult<ReadStream<Buffer>>> handler) Search the GeoRocket data store and return a ReadStream of merged chunks matching the given criteria. |
WriteStream<Buffer> | startImport(Handler<AsyncResult<Void>> handler) Start importing data to GeoRocket. |
WriteStream<Buffer> | startImport(String layer, Collection<String> tags, Handler<AsyncResult<Void>> handler) Start importing data to GeoRocket. |
WriteStream<Buffer> | startImport(String layer, Collection<String> tags, long size, Handler<AsyncResult<Void>> handler) Start importing data to GeoRocket. |
WriteStream<Buffer> | startImport(String layer, Collection<String> tags, Optional<Long> size, Handler<AsyncResult<Void>> handler) Start importing data to GeoRocket. |
WriteStream<Buffer> | startImport(String layer, Handler<AsyncResult<Void>> handler) Start importing data to GeoRocket. |
protected String | urlencode(String str) Convenience method to URL-encode a string |
public StoreClient(HttpClient client)
client
- the HTTP clientprotected String urlencode(String str)
str
- the stringprotected String prepareQuery(String query, String layer)
query
- the search query (may be null
)layer
- the layer to export (may be null
)protected String prepareImport(String layer, Collection<String> tags)
layer
- the layer to import to (may be null
if data should be imported to the root layer)tags
- a collection of tags to attach to the imported data (may be null
if no tags need to be attached)public WriteStream<Buffer> startImport(Handler<AsyncResult<Void>> handler)
Start importing data to GeoRocket. The method opens a connection to the GeoRocket server and returns a WriteStream
that can be used to send data.
The caller is responsible for closing the stream (and ending the import process) through WriteStream.end()
and handling exceptions through WriteStream.exceptionHandler(Handler)
.
handler
- a handler that will be called when the data has been imported by the GeoRocket serverWriteStream
that can be used to send datapublic WriteStream<Buffer> startImport(String layer, Handler<AsyncResult<Void>> handler)
Start importing data to GeoRocket. The method opens a connection to the GeoRocket server and returns a WriteStream
that can be used to send data.
The caller is responsible for closing the stream (and ending the import process) through WriteStream.end()
and handling exceptions through WriteStream.exceptionHandler(Handler)
.
layer
- the layer to import to (may be null
if data should be imported to the root layer)handler
- a handler that will be called when the data has been imported by the GeoRocket serverWriteStream
that can be used to send datapublic WriteStream<Buffer> startImport(String layer, Collection<String> tags, Handler<AsyncResult<Void>> handler)
Start importing data to GeoRocket. The method opens a connection to the GeoRocket server and returns a WriteStream
that can be used to send data.
The caller is responsible for closing the stream (and ending the import process) through WriteStream.end()
and handling exceptions through WriteStream.exceptionHandler(Handler)
.
layer
- the layer to import to (may be null
if data should be imported to the root layer)tags
- a collection of tags to attach to the imported data (may be null
if no tags need to be attached)handler
- a handler that will be called when the data has been imported by the GeoRocket serverWriteStream
that can be used to send datapublic WriteStream<Buffer> startImport(String layer, Collection<String> tags, long size, Handler<AsyncResult<Void>> handler)
Start importing data to GeoRocket. The method opens a connection to the GeoRocket server and returns a WriteStream
that can be used to send data.
The caller is responsible for closing the stream (and ending the import process) through WriteStream.end()
and handling exceptions through WriteStream.exceptionHandler(Handler)
.
layer
- the layer to import to (may be null
if data should be imported to the root layer)tags
- a collection of tags to attach to the imported data (may be null
if no tags need to be attached)size
- size of the data to be sent in byteshandler
- a handler that will be called when the data has been imported by the GeoRocket serverWriteStream
that can be used to send datapublic WriteStream<Buffer> startImport(String layer, Collection<String> tags, Optional<Long> size, Handler<AsyncResult<Void>> handler)
Start importing data to GeoRocket. The method opens a connection to the GeoRocket server and returns a WriteStream
that can be used to send data.
The caller is responsible for closing the stream (and ending the import process) through WriteStream.end()
and handling exceptions through WriteStream.exceptionHandler(Handler)
.
layer
- the layer to import to (may be null
if data should be imported to the root layer)tags
- a collection of tags to attach to the imported data (may be null
if no tags need to be attached)size
- size of the data to be sent in bytes (optional)handler
- a handler that will be called when the data has been imported by the GeoRocket serverWriteStream
that can be used to send dataprotected HttpClientRequest configureRequest(HttpClientRequest request)
request
- request the request to configureHttpClientRequest
as given but with options setpublic void search(Handler<AsyncResult<ReadStream<Buffer>>> handler)
Export the contents of the whole GeoRocket data store. Return a ReadStream
from which merged chunks can be read.
The caller is responsible for handling exceptions through ReadStream.exceptionHandler(Handler)
.
handler
- a handler that will receive the ReadStream
public void search(String query, Handler<AsyncResult<ReadStream<Buffer>>> handler)
Search the GeoRocket data store and return a ReadStream
of merged chunks matching the given criteria.
If query
is null
the contents of the whole data store will be returned.
The caller is responsible for handling exceptions through ReadStream.exceptionHandler(Handler)
.
query
- a search query specifying which chunks to return (may be null
)handler
- a handler that will receive the ReadStream
from which the merged chunks matching the given criteria can be readpublic void search(String query, String layer, Handler<AsyncResult<ReadStream<Buffer>>> handler)
Search the GeoRocket data store and return a ReadStream
of merged chunks matching the given criteria.
If query
is null
or empty all chunks from the given layer
(and all sub-layers) will be returned. If layer
is also null
or empty the contents of the whole data store will be returned.
The caller is responsible for handling exceptions through ReadStream.exceptionHandler(Handler)
.
query
- 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 merged chunks matching the given criteria can be readpublic void delete(String query, Handler<AsyncResult<Void>> handler)
Delete chunks from the GeoRocket data store.
Either query
or layer
must be given to protect against requests that accidentally delete the whole data store. If you want to do so, provide an empty query
and the root layer /
.
query
- a search query specifying the chunks to delete (must not be null
to protect against requests that accidentally delete the whole data store. If you want to do so, use delete(String, String, Handler)
and provide an empty query
and the root layer /
.)handler
- a handler that will be called when the operation has finishedpublic void delete(String query, String layer, Handler<AsyncResult<Void>> handler)
Delete chunks or layers from the GeoRocket data store.
Either query
or layer
must be given to protect against requests that accidentally delete the whole data store. If you want to do so, provide an empty query
and the root layer /
.
query
- a search query specifying the chunks to delete (or null
if all chunks and all sub-layers from the given layer
should be deleted)layer
- the absolute path to the layer from which to delete (or null
if the whole store should be searched for chunks to delete)handler
- a handler that will be called when the operation has finishedprotected String getEndpoint()