public class WorkspaceClient extends DefaultClient
Modifier and Type | Field and Description |
---|---|
protected static String |
INTERNAL_SERVER_ERROR |
STATUS_URL
Modifier and Type | Method and Description |
---|---|
boolean |
checkObject(String containerName,
String objectId,
String digest,
DigestType digestAlgorithm)
Check object
|
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 |
compress(String containerName,
CompressInformation compressInformation)
Compress
|
RequestResponse<String> |
computeObjectDigest(String containerName,
String objectName,
DigestType algo)
Compute digest for an object
|
void |
consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
Helper when an error occurs on client usage side to consume response however
|
long |
countObjects(String containerName)
Count the number of object in a container
|
void |
createContainer(String containerName)
Create container
|
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.
|
void |
createFolder(String containerName,
String folderName)
Create a folder
|
void |
deleteContainer(String containerName,
boolean recursive)
Delete container
|
void |
deleteFolder(String containerName,
String folderName)
Delete folder
|
void |
deleteObject(String containerName,
String objectName)
Delete object
|
protected javax.ws.rs.client.Client |
getClient(boolean chunked) |
RequestResponse<ContainerInformation> |
getContainerInformation(String containerName) |
RequestResponse<List<URI>> |
getListUriDigitalObjectFromFolder(String containerName,
String folderName)
Get List of digital object
|
javax.ws.rs.core.Response |
getObject(String containerName,
String objectName)
Get Object
|
RequestResponse<com.fasterxml.jackson.databind.JsonNode> |
getObjectInformation(String containerName,
String objectName)
Get Object Information
|
RequestResponse<MetadatasObject> |
getObjectMetadatas(String containerName,
String objectId)
Get Object Metadata
|
String |
getResourcePath()
Get the resource path of the server.
|
String |
getServiceUrl()
Get the service URL
|
VitamClientFactory<?> |
getVitamClientFactory() |
boolean |
isExistingContainer(String containerName)
Check if container exists
|
boolean |
isExistingFolder(String containerName,
String folderName)
Check if folder exists
|
boolean |
isExistingObject(String containerName,
String objectName)
Check if obejct is existing
|
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,
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.MultivaluedHashMap<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
|
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
|
void |
putObject(String containerName,
String objectName,
InputStream stream)
Put object
|
static void |
staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
This method consume everything (in particular InpuStream) and close the response.
|
String |
toString() |
void |
uncompressObject(String containerName,
String folderName,
String archiveType,
InputStream inputStreamObject)
Uncompress object
|
protected static final String INTERNAL_SERVER_ERROR
public void createContainer(String containerName) throws ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException
containerName
- the container nameContentAddressableStorageAlreadyExistException
- in case the container already existsContentAddressableStorageServerException
- in case of any other errorpublic void deleteContainer(String containerName, boolean recursive) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container namerecursive
- true if should be deleted recursivelyContentAddressableStorageNotFoundException
- if the container could not be foundContentAddressableStorageServerException
- in case of any other errorpublic boolean isExistingContainer(String containerName) throws ContentAddressableStorageServerException
containerName
- the container nameContentAddressableStorageServerException
- in case of any errorpublic long countObjects(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container nameContentAddressableStorageNotFoundException
- in case the container could not be foundContentAddressableStorageServerException
- in case of any other errorpublic void createFolder(String containerName, String folderName) throws ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException
containerName
- the container namefolderName
- the folder nameContentAddressableStorageAlreadyExistException
- in case the folder already existsContentAddressableStorageServerException
- in case of any other errorpublic void deleteFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container namefolderName
- the folder nameContentAddressableStorageNotFoundException
- if the folder does not existContentAddressableStorageServerException
- in case of any other errorpublic boolean isExistingFolder(String containerName, String folderName) throws ContentAddressableStorageServerException
containerName
- the container namefolderName
- the folder nameContentAddressableStorageServerException
- in case of errorpublic void putObject(String containerName, String objectName, InputStream stream) throws ContentAddressableStorageServerException
containerName
- the container nameobjectName
- the object namestream
- the input stream to be putContentAddressableStorageServerException
- in case of errorpublic javax.ws.rs.core.Response getObject(String containerName, String objectName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container nameobjectName
- the object nameContentAddressableStorageNotFoundException
- in case the object couldnt be foundContentAddressableStorageServerException
- in case of any other errorpublic void deleteObject(String containerName, String objectName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the name of the containerobjectName
- the name of objectContentAddressableStorageNotFoundException
- in case the object could not be foundContentAddressableStorageServerException
- in case of any other errorpublic boolean isExistingObject(String containerName, String objectName) throws ContentAddressableStorageServerException
containerName
- the container nameobjectName
- the object nameContentAddressableStorageServerException
- in case of errorpublic RequestResponse<List<URI>> getListUriDigitalObjectFromFolder(String containerName, String folderName) throws ContentAddressableStorageServerException
containerName
- the container namefolderName
- the folder nameContentAddressableStorageServerException
- in case of errorpublic void compress(String containerName, CompressInformation compressInformation) throws ContentAddressableStorageServerException
containerName
- the container namecompressInformation
- information on compressionContentAddressableStorageServerException
public void uncompressObject(String containerName, String folderName, String archiveType, InputStream inputStreamObject) throws ContentAddressableStorageException
containerName
- the name of the containerfolderName
- the folder namearchiveType
- the archive typeinputStreamObject
- the input stream to be uncompressContentAddressableStorageException
- in case of errorpublic RequestResponse<String> computeObjectDigest(String containerName, String objectName, DigestType algo) throws ContentAddressableStorageException
containerName
- the container nameobjectName
- the object namealgo
- the digest typeContentAddressableStorageException
- in case of errorpublic RequestResponse<ContainerInformation> getContainerInformation(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container nameContentAddressableStorageNotFoundException
- in case the container could not be foundContentAddressableStorageServerException
- in case of any other errorpublic RequestResponse<com.fasterxml.jackson.databind.JsonNode> getObjectInformation(String containerName, String objectName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException
containerName
- the container nameobjectName
- the object nameContentAddressableStorageNotFoundException
- in case the object couldnt be foundContentAddressableStorageServerException
- in case of any other errorpublic boolean checkObject(String containerName, String objectId, String digest, DigestType digestAlgorithm) throws ContentAddressableStorageException
containerName
- the name of the containerobjectId
- the object iddigest
- the digestdigestAlgorithm
- the digest algorithmContentAddressableStorageException
- in case the object couldnt be foundpublic RequestResponse<MetadatasObject> getObjectMetadatas(String containerName, String objectId) throws ContentAddressableStorageException, IOException
containerName
- the name of the containerobjectId
- the object idContentAddressableStorageException
IOException
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 static final void staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
response
- 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.MultivaluedHashMap<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.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 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
public VitamClientFactory<?> getVitamClientFactory()
Copyright © 2018 Vitam. All rights reserved.