public class ConnectionImpl extends AbstractConnection
Modifier and Type | Field and Description |
---|---|
protected static String |
INTERNAL_SERVER_ERROR |
STATUS_URL
Constructor and Description |
---|
ConnectionImpl(String driverName,
VitamClientFactoryInterface<? extends AbstractConnection> factory,
Properties parameters)
Constructor
|
Modifier and Type | Method and Description |
---|---|
StorageBulkPutResult |
bulkPutObjects(StorageBulkPutRequest request)
Bulk put object files into the storage offer.
|
void |
checkStatus()
Check the status from the service
|
void |
checkStatus(javax.ws.rs.core.MultivaluedHashMap<String,Object> headers)
Check the status from the service
used to passe "X-SSL-CLIENT-CERT" header that contain a pem certificate
|
void |
close()
Close the underneath http client
|
void |
consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
Helper when an error occurs on client usage side to consume response however
|
protected VitamClientException |
createExceptionFromResponse(javax.ws.rs.core.Response response)
Handle all errors and throw a VitamClientException in case the response does not contains a vitamError type
result.
|
RequestResponse<TapeReadRequestReferentialEntity> |
createReadOrderRequest(StorageObjectRequest request)
Asynchronous retrieve an object from the storage offer based on criterias defined in request argument.
|
protected javax.ws.rs.client.Client |
getClient(boolean chunked) |
StorageMetadataResult |
getMetadatas(StorageGetMetadataRequest request)
Get metadata of object
|
StorageGetResult |
getObject(StorageObjectRequest request)
Retrieve an object from the storage offer based on criterias defined in request argument.
|
RequestResponse<OfferLog> |
getOfferLogs(StorageOfferLogRequest storageGetOfferLogRequest)
Get a listing of offer logs on a container type
|
RequestResponse<TapeReadRequestReferentialEntity> |
getReadOrderRequest(String readOrderRequestId,
int tenant) |
String |
getResourcePath()
Get the resource path of the server.
|
String |
getServiceUrl()
Get the service URL
|
StorageCapacityResult |
getStorageCapacity(Integer tenantId)
Retrieve the remaining storage capacity available on the distant offer.
|
protected <R> R |
handleResponseStatus(javax.ws.rs.core.Response response,
Class<R> responseType)
Common method to handle response status
|
RequestResponse<com.fasterxml.jackson.databind.JsonNode> |
listObjects(StorageListRequest request)
List object on a container type
|
boolean |
objectExistsInOffer(StorageObjectRequest request)
Check if an object is present in the offer
|
protected Future<javax.ws.rs.core.Response> |
performAsyncRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedHashMap<String,Object> headers,
Object body,
javax.ws.rs.core.MediaType contentType,
javax.ws.rs.core.MediaType accept)
Perform an Async HTTP request to the server with full control of action on caller
|
protected <T> Future<T> |
performAsyncRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedHashMap<String,Object> headers,
Object body,
javax.ws.rs.core.MediaType contentType,
javax.ws.rs.core.MediaType accept,
javax.ws.rs.client.InvocationCallback<T> callback)
Perform an Async HTTP request to the server with callback
|
protected javax.ws.rs.core.Response |
performRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedHashMap<String,Object> headers,
Object body,
javax.ws.rs.core.MediaType contentType,
javax.ws.rs.core.MediaType accept,
boolean chunkedMode)
Perform a HTTP request to the server for synchronous call
|
protected javax.ws.rs.core.Response |
performRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedMap<String,Object> headers,
javax.ws.rs.core.MediaType accept)
Perform a HTTP request to the server for synchronous call
|
protected javax.ws.rs.core.Response |
performRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedMap<String,Object> headers,
javax.ws.rs.core.MultivaluedMap<String,Object> queryParams,
javax.ws.rs.core.MediaType accept)
Perform a HTTP request to the server for synchronous call
|
protected javax.ws.rs.core.Response |
performRequest(String httpMethod,
String path,
javax.ws.rs.core.MultivaluedMap<String,Object> headers,
Object body,
javax.ws.rs.core.MediaType contentType,
javax.ws.rs.core.MediaType accept)
Perform a HTTP request to the server for synchronous call
|
StoragePutResult |
putObject(StoragePutRequest request)
Put the object file into the storage offer based on criterias defined in request argument and underlaying
connection parameters.
|
StorageRemoveResult |
removeObject(StorageRemoveRequest request)
Delete an object on the distant storage offer.
|
void |
removeReadOrderRequest(String readOrderRequestId,
int tenant) |
static void |
staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
This method consume everything (in particular InpuStream) and close the response.
|
String |
toString() |
getDriverName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close
protected static final String INTERNAL_SERVER_ERROR
public ConnectionImpl(String driverName, VitamClientFactoryInterface<? extends AbstractConnection> factory, Properties parameters)
driverName
- factory
- parameters
- public StorageCapacityResult getStorageCapacity(Integer tenantId) throws StorageDriverPreconditionFailedException, StorageDriverNotFoundException, StorageDriverException
Connection
tenantId
- the tenant id needed to get storage capacityStorageDriverPreconditionFailedException
- if a bad request is encounteredStorageDriverNotFoundException
- if container is not foundStorageDriverException
- if any problem occurs during requestpublic StorageGetResult getObject(StorageObjectRequest request) throws StorageDriverException
Connection
request
- the request to send. It contains informations needed to retrieve a given object.StorageDriverException
- if any problem occurs during requestpublic RequestResponse<TapeReadRequestReferentialEntity> createReadOrderRequest(StorageObjectRequest request) throws StorageDriverException
Connection
request
- the request to send. It contains informations needed to retrieve a given object.StorageDriverException
- if any problem occurs during requestpublic RequestResponse<TapeReadRequestReferentialEntity> getReadOrderRequest(String readOrderRequestId, int tenant) throws StorageDriverException
StorageDriverException
public void removeReadOrderRequest(String readOrderRequestId, int tenant) throws StorageDriverException
StorageDriverException
public StoragePutResult putObject(StoragePutRequest request) throws StorageDriverException
Connection
request
- the request to send. It may contains informations needed to store the file.StorageDriverException
- if any problem occurs during requestpublic StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException
Connection
StorageDriverException
- if any problem occurs during requestpublic StorageRemoveResult removeObject(StorageRemoveRequest request) throws StorageDriverException
Connection
request
- the request to send, it contains information needed to delete an object on the distant storeStorageDriverException
- if any problem occurs during requestpublic boolean objectExistsInOffer(StorageObjectRequest request) throws StorageDriverException
Connection
request
- the request to send. It contains informations needed to retrieve a given object.StorageDriverException
- if any problem occurs during requestprotected <R> R handleResponseStatus(javax.ws.rs.core.Response response, Class<R> responseType) throws StorageDriverException
R
- the class type to be returnedresponse
- the response to be handledresponseType
- the type to map the response intoStorageDriverException
- if any from the serverpublic StorageMetadataResult getMetadatas(StorageGetMetadataRequest request) throws StorageDriverException
Connection
StorageDriverException
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> listObjects(StorageListRequest request) throws StorageDriverException
Connection
request
- the request contains data needed to list container typeStorageDriverException
public RequestResponse<OfferLog> getOfferLogs(StorageOfferLogRequest storageGetOfferLogRequest) throws StorageDriverException
Connection
storageGetOfferLogRequest
- the request contains data needed to retrieve the listing of the containerStorageDriverException
- to be thrown in case of any driver exceptionpublic static void staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
response
- protected javax.ws.rs.client.Client getClient(boolean chunked) throws IllegalStateException
IllegalStateException
public final void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
MockOrRestClient
consumeAnyEntityAndClose
in interface MockOrRestClient
public void checkStatus() throws VitamApplicationServerException
MockOrRestClient
checkStatus
in interface MockOrRestClient
VitamApplicationServerException
- if the Server is unavailablepublic void checkStatus(javax.ws.rs.core.MultivaluedHashMap<String,Object> headers) throws VitamApplicationServerException
MockOrRestClient
checkStatus
in interface MockOrRestClient
VitamApplicationServerException
- if the Server is unavailableprotected javax.ws.rs.core.Response performRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedMap<String,Object> headers, javax.ws.rs.core.MediaType accept) throws VitamClientInternalException
httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullaccept
- asked type of responseVitamClientInternalException
protected javax.ws.rs.core.Response performRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedMap<String,Object> headers, javax.ws.rs.core.MultivaluedMap<String,Object> queryParams, javax.ws.rs.core.MediaType accept) throws VitamClientInternalException
httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullqueryParams
- query parameters to add to get request, my be nullaccept
- asked type of responseVitamClientInternalException
protected javax.ws.rs.core.Response performRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedMap<String,Object> headers, Object body, javax.ws.rs.core.MediaType contentType, javax.ws.rs.core.MediaType accept) throws VitamClientInternalException
httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullbody
- body content of type contentType, may be nullcontentType
- the media type of the body to send, null if body is nullaccept
- asked type of responseVitamClientInternalException
protected javax.ws.rs.core.Response performRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedHashMap<String,Object> headers, Object body, javax.ws.rs.core.MediaType contentType, javax.ws.rs.core.MediaType accept, boolean chunkedMode) throws VitamClientInternalException
httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullbody
- body content of type contentType, may be nullcontentType
- the media type of the body to send, null if body is nullaccept
- asked type of responsechunkedMode
- True use default client, else False use non Chunked mode clientVitamClientInternalException
protected <T> Future<T> performAsyncRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedHashMap<String,Object> headers, Object body, javax.ws.rs.core.MediaType contentType, javax.ws.rs.core.MediaType accept, javax.ws.rs.client.InvocationCallback<T> callback) throws VitamClientInternalException
T
- the type of the Future result (generally Response)httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullbody
- body content of type contentType, may be nullcontentType
- the media type of the body to send, null if body is nullaccept
- asked type of responsecallback
- VitamClientInternalException
protected Future<javax.ws.rs.core.Response> performAsyncRequest(String httpMethod, String path, javax.ws.rs.core.MultivaluedHashMap<String,Object> headers, Object body, javax.ws.rs.core.MediaType contentType, javax.ws.rs.core.MediaType accept) throws VitamClientInternalException
httpMethod
- HTTP method to use for requestpath
- URL to requestheaders
- headers HTTP to add to request, may be nullbody
- body content of type contentType, may be nullcontentType
- the media type of the body to send, null if body is nullaccept
- asked type of responseVitamClientInternalException
protected VitamClientException createExceptionFromResponse(javax.ws.rs.core.Response response)
response
- responsepublic String getResourcePath()
MockOrRestClient
getResourcePath
in interface MockOrRestClient
public String getServiceUrl()
MockOrRestClient
getServiceUrl
in interface MockOrRestClient
public void close()
MockOrRestClient
close
in interface MockOrRestClient
close
in interface VitamAutoCloseable
close
in interface AutoCloseable
Copyright © 2019 Vitam. All rights reserved.