public class MetaDataClientRest extends DefaultClient implements MetaDataClient
Modifier and Type | Field and Description |
---|---|
static String |
CONSISTENCY_ERROR_AN_INTERNAL_DATA_CONSISTENCY_ERROR_HAS_BEEN_DETECTED |
static String |
DESCRIPTION |
protected static String |
INTERNAL_SERVER_ERROR |
STATUS_URL
Constructor and Description |
---|
MetaDataClientRest(VitamClientFactoryInterface factory)
Constructor using given scheme (http)
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
flushObjectGroups() |
boolean |
flushUnits() |
protected javax.ws.rs.client.Client |
getClient(boolean chunked) |
RequestResponse<com.fasterxml.jackson.databind.JsonNode> |
getObjectGroupByIdRaw(String objectGroupId)
Search object group by path unit id
|
String |
getResourcePath()
Get the resource path of the server.
|
String |
getServiceUrl()
Get the service URL
|
RequestResponse<com.fasterxml.jackson.databind.JsonNode> |
getUnitByIdRaw(String unitId)
Search units by path unit id
|
VitamClientFactory<?> |
getVitamClientFactory() |
com.fasterxml.jackson.databind.JsonNode |
insertObjectGroup(com.fasterxml.jackson.databind.JsonNode insertQuery) |
com.fasterxml.jackson.databind.JsonNode |
insertUnit(com.fasterxml.jackson.databind.JsonNode insertQuery) |
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
|
com.fasterxml.jackson.databind.JsonNode |
reindex(IndexParameters indexParam)
Reindex a collection with parameters
|
List<ObjectGroupPerOriginatingAgency> |
selectAccessionRegisterOnObjectByOperationId(String operationId) |
List<UnitPerOriginatingAgency> |
selectAccessionRegisterOnUnitByOperationId(String operationId) |
com.fasterxml.jackson.databind.JsonNode |
selectObjectGroups(com.fasterxml.jackson.databind.JsonNode selectQuery)
Search objectgroups by select query (DSL)
|
com.fasterxml.jackson.databind.JsonNode |
selectObjectGrouptbyId(com.fasterxml.jackson.databind.JsonNode selectQuery,
String objectGroupId)
Search Object Group by query (DSL) and path objectGroup id
|
com.fasterxml.jackson.databind.JsonNode |
selectUnitbyId(com.fasterxml.jackson.databind.JsonNode selectQuery,
String unitId)
Search units by query (DSL) and path unit id
|
com.fasterxml.jackson.databind.JsonNode |
selectUnits(com.fasterxml.jackson.databind.JsonNode selectQuery)
Search units by select query (DSL)
|
static void |
staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
This method consume everything (in particular InpuStream) and close the response.
|
com.fasterxml.jackson.databind.JsonNode |
switchIndexes(SwitchIndexParameters switchIndexParam)
Switch indexes
|
String |
toString() |
void |
updateObjectGroupById(com.fasterxml.jackson.databind.JsonNode queryUpdate,
String objectGroupId)
Update ObjectGroup
|
com.fasterxml.jackson.databind.JsonNode |
updateUnitbyId(com.fasterxml.jackson.databind.JsonNode updateQuery,
String unitId)
Update units by query (DSL) and path unit id
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
public static final String DESCRIPTION
public static final String CONSISTENCY_ERROR_AN_INTERNAL_DATA_CONSISTENCY_ERROR_HAS_BEEN_DETECTED
protected static final String INTERNAL_SERVER_ERROR
public MetaDataClientRest(VitamClientFactoryInterface factory)
factory
- The client factorypublic com.fasterxml.jackson.databind.JsonNode insertUnit(com.fasterxml.jackson.databind.JsonNode insertQuery) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataAlreadyExistException, MetaDataDocumentSizeException, MetaDataClientServerException
insertUnit
in interface MetaDataClient
insertQuery
- as JsonNode InvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataAlreadyExistException
MetaDataDocumentSizeException
MetaDataClientServerException
public com.fasterxml.jackson.databind.JsonNode selectUnits(com.fasterxml.jackson.databind.JsonNode selectQuery) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException, VitamDBException
MetaDataClient
selectUnits
in interface MetaDataClient
selectQuery
- : select query SelectMultiQuery
as String MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
VitamDBException
public com.fasterxml.jackson.databind.JsonNode selectObjectGroups(com.fasterxml.jackson.databind.JsonNode selectQuery) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
MetaDataClient
selectObjectGroups
in interface MetaDataClient
selectQuery
- : select query SelectMultiQuery
as String MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
public com.fasterxml.jackson.databind.JsonNode selectUnitbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, String unitId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException
MetaDataClient
selectUnitbyId
in interface MetaDataClient
selectQuery
- : select query Select
as JsonNode
unitId
- : unit id MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
public com.fasterxml.jackson.databind.JsonNode selectObjectGrouptbyId(com.fasterxml.jackson.databind.JsonNode selectQuery, String objectGroupId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetadataInvalidSelectException, MetaDataClientServerException
MetaDataClient
selectObjectGrouptbyId
in interface MetaDataClient
selectQuery
- : select query Select
as JsonNode
objectGroupId
- : objectGroup id MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
- thrown when the Query is badly formatted or objectGroupId is emptyMetadataInvalidSelectException
- thrown when objectGroupId or selectQuery id is null or blankMetaDataClientServerException
public com.fasterxml.jackson.databind.JsonNode updateUnitbyId(com.fasterxml.jackson.databind.JsonNode updateQuery, String unitId) throws MetaDataExecutionException, MetaDataDocumentSizeException, InvalidParseOperationException, MetaDataClientServerException, MetaDataNotFoundException
MetaDataClient
updateUnitbyId
in interface MetaDataClient
updateQuery
- update query Select
as JsonNode
unitId
- unit id MetaDataExecutionException
- thrown when internal Server Error (fatal technical exception thrown)MetaDataDocumentSizeException
- thrown when Query document Size is Too LargeInvalidParseOperationException
MetaDataClientServerException
MetaDataNotFoundException
public com.fasterxml.jackson.databind.JsonNode insertObjectGroup(com.fasterxml.jackson.databind.JsonNode insertQuery) throws InvalidParseOperationException, MetaDataExecutionException, MetaDataNotFoundException, MetaDataAlreadyExistException, MetaDataDocumentSizeException, MetaDataClientServerException
insertObjectGroup
in interface MetaDataClient
insertQuery
- as StringInvalidParseOperationException
MetaDataExecutionException
MetaDataNotFoundException
MetaDataAlreadyExistException
MetaDataDocumentSizeException
MetaDataClientServerException
public void updateObjectGroupById(com.fasterxml.jackson.databind.JsonNode queryUpdate, String objectGroupId) throws InvalidParseOperationException, MetaDataClientServerException, MetaDataExecutionException
MetaDataClient
updateObjectGroupById
in interface MetaDataClient
InvalidParseOperationException
MetaDataClientServerException
MetaDataExecutionException
public List<UnitPerOriginatingAgency> selectAccessionRegisterOnUnitByOperationId(String operationId) throws MetaDataClientServerException
selectAccessionRegisterOnUnitByOperationId
in interface MetaDataClient
MetaDataClientServerException
public List<ObjectGroupPerOriginatingAgency> selectAccessionRegisterOnObjectByOperationId(String operationId) throws MetaDataClientServerException
selectAccessionRegisterOnObjectByOperationId
in interface MetaDataClient
MetaDataClientServerException
public boolean flushUnits() throws MetaDataClientServerException
flushUnits
in interface MetaDataClient
MetaDataClientServerException
public boolean flushObjectGroups() throws MetaDataClientServerException
flushObjectGroups
in interface MetaDataClient
MetaDataClientServerException
public com.fasterxml.jackson.databind.JsonNode reindex(IndexParameters indexParam) throws InvalidParseOperationException, MetaDataClientServerException, MetaDataNotFoundException
MetaDataClient
reindex
in interface MetaDataClient
indexParam
- reindexation parametersInvalidParseOperationException
MetaDataClientServerException
MetaDataNotFoundException
- in case the index does not existpublic com.fasterxml.jackson.databind.JsonNode switchIndexes(SwitchIndexParameters switchIndexParam) throws InvalidParseOperationException, MetaDataClientServerException, MetaDataNotFoundException
MetaDataClient
switchIndexes
in interface MetaDataClient
switchIndexParam
- switch index parametersInvalidParseOperationException
MetaDataClientServerException
MetaDataNotFoundException
- in case the index does not existpublic RequestResponse<com.fasterxml.jackson.databind.JsonNode> getUnitByIdRaw(String unitId) throws VitamClientException
MetaDataClient
getUnitByIdRaw
in interface MetaDataClient
unitId
- : unit id VitamClientException
public RequestResponse<com.fasterxml.jackson.databind.JsonNode> getObjectGroupByIdRaw(String objectGroupId) throws VitamClientException
MetaDataClient
getObjectGroupByIdRaw
in interface MetaDataClient
objectGroupId
- : objectGroup id VitamClientException
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.