Class StorageClientMock
- java.lang.Object
-
- fr.gouv.vitam.common.client.AbstractMockClient
-
- fr.gouv.vitam.storage.engine.client.StorageClientMock
-
- All Implemented Interfaces:
BasicClient,MockOrRestClient,VitamAutoCloseable,StorageClient,java.lang.AutoCloseable
public class StorageClientMock extends AbstractMockClient implements StorageClient
Mock client implementation for storage
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class fr.gouv.vitam.common.client.AbstractMockClient
AbstractMockClient.FakeInboundResponse
-
-
Field Summary
-
Fields inherited from interface fr.gouv.vitam.common.client.BasicClient
STATUS_URL
-
-
Constructor Summary
Constructors Constructor Description StorageClientMock()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BulkObjectStoreResponsebulkStoreFilesFromWorkspace(java.lang.String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest)Store objects available in workspace into offersjava.util.Map<java.lang.String,AccessRequestStatus>checkAccessRequestStatuses(java.lang.String strategyId, java.lang.String offerId, java.util.List<java.lang.String> accessRequestIds, boolean adminCrossTenantAccessRequestAllowed)Check access request statuses of asynchronous offer.BulkObjectAvailabilityResponsecheckBulkObjectAvailability(java.lang.String strategyId, java.lang.String offerId, BulkObjectAvailabilityRequest bulkObjectAvailabilityRequest)Checks immediate object availability in storage offer.RequestResponseOKcopyObjectFromOfferToOffer(java.lang.String objectId, DataCategory category, java.lang.String source, java.lang.String destination, java.lang.String strategyId)RequestResponseOKcreate(java.lang.String strategyId, java.lang.String objectId, DataCategory category, java.io.InputStream inputStream, java.lang.Long inputStreamSize, java.util.List<java.lang.String> offerIds)java.util.Optional<java.lang.String>createAccessRequestIfRequired(java.lang.String strategyId, java.lang.String offerId, DataCategory dataCategory, java.util.List<java.lang.String> objectNames)Create access request if target offer does not support synchronous read (tape library storage).booleandelete(java.lang.String strategyId, DataCategory type, java.lang.String guid)Delete an object of given type in the storage offer strategybooleandelete(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds)Delete an object of given type in the storage offer strategyjava.util.Map<java.lang.String,java.lang.Boolean>exists(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds)Check the existence of an object in storage by its id and typeDataCategory.RequestResponse<BatchObjectInformationResponse>getBatchObjectInformation(java.lang.String strategyId, DataCategory type, java.util.Collection<java.lang.String> offerIds, java.util.Collection<java.lang.String> objectIds)Get object information from objects in storagejavax.ws.rs.core.ResponsegetContainerAsync(java.lang.String strategyId, java.lang.String guid, DataCategory type, AccessLogInfoModel logInfo)Retrieves a binary object knowing its guid as an inputStream for a specific tenant/strategyjavax.ws.rs.core.ResponsegetContainerAsync(java.lang.String strategyId, java.lang.String offerId, java.lang.String objectName, DataCategory type, AccessLogInfoModel logInfo)Retrieves a binary object knowing its guid as an inputStream for a specific tenant/strategy/offerIdcom.fasterxml.jackson.databind.JsonNodegetInformation(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds, boolean noCache)Get object information from objects in storageRequestResponse<OfferLog>getOfferLogs(java.lang.String strategyId, java.lang.String offerId, DataCategory type, java.lang.Long offset, int limit, Order order)Get offer log .java.util.List<java.lang.String>getOffers(java.lang.String strategyId)get List of offers for a strategyjava.lang.StringgetReferentOffer(java.lang.String strategy)Get referent offer of strategycom.fasterxml.jackson.databind.JsonNodegetStorageInformation(java.lang.String strategyId)Check if the storage of objects could be done, knowing a required sizeRequestResponse<StorageStrategy>getStorageStrategies()Get strategies.javax.ws.rs.core.ResponselaunchOfferLogCompaction(VitamContext vitamContext, java.lang.String offerId)CloseableIterator<ObjectEntry>listContainer(java.lang.String strategyId, java.lang.String offerId, DataCategory type)List object type in containervoidremoveAccessRequest(java.lang.String strategyId, java.lang.String offerId, java.lang.String accessRequestId, boolean adminCrossTenantAccessRequestAllowed)Removes (cancel / delete) and access request for an asynchronous offer.RequestResponseOK<StorageLogBackupResult>storageAccessLogBackup(java.util.List<java.lang.Integer> tenants)Call storage accesslog backup operation.RequestResponseOK<StorageLogBackupResult>storageLogBackup(java.util.List<java.lang.Integer> tenants)Call storage log backup operation.RequestResponseOK<StorageLogTraceabilityResult>storageLogTraceability(java.util.List<java.lang.Integer> tenants)Call storage log traceability operation.StoredInfoResultstoreFileFromWorkspace(java.lang.String strategyId, DataCategory type, java.lang.String guid, ObjectDescription description)Store an object available in workspace by its vitam guid-
Methods inherited from class fr.gouv.vitam.common.client.AbstractMockClient
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface fr.gouv.vitam.common.client.MockOrRestClient
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
-
-
-
-
Method Detail
-
getStorageInformation
public com.fasterxml.jackson.databind.JsonNode getStorageInformation(java.lang.String strategyId) throws StorageServerClientExceptionDescription copied from interface:StorageClientCheck if the storage of objects could be done, knowing a required size- Specified by:
getStorageInformationin interfaceStorageClient- Parameters:
strategyId- the storage strategy id- Returns:
- the capacity of the storage
- Throws:
StorageServerClientException- if the Server got an internal error
-
getOffers
public java.util.List<java.lang.String> getOffers(java.lang.String strategyId) throws StorageNotFoundClientException, StorageServerClientExceptionDescription copied from interface:StorageClientget List of offers for a strategy- Specified by:
getOffersin interfaceStorageClient- Parameters:
strategyId- strategyId- Returns:
- list id of offers
- Throws:
StorageNotFoundClientExceptionStorageServerClientException
-
storeFileFromWorkspace
public StoredInfoResult storeFileFromWorkspace(java.lang.String strategyId, DataCategory type, java.lang.String guid, ObjectDescription description) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException
Description copied from interface:StorageClientStore an object available in workspace by its vitam guid- Specified by:
storeFileFromWorkspacein interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the type of object collectionguid- vitam guiddescription- object description- Returns:
- the result status of object creation
- Throws:
StorageAlreadyExistsClientException- if the Server got a CONFLICT status resultStorageNotFoundClientException- if the Server got a NotFound resultStorageServerClientException- if the Server got an internal error
-
delete
public boolean delete(java.lang.String strategyId, DataCategory type, java.lang.String guid) throws StorageServerClientExceptionDescription copied from interface:StorageClientDelete an object of given type in the storage offer strategy- Specified by:
deletein interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the type of object collectionguid- vitam guid- Returns:
- true if deleted
- Throws:
StorageServerClientException- if the Server got an internal error
-
delete
public boolean delete(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds) throws StorageServerClientExceptionDescription copied from interface:StorageClientDelete an object of given type in the storage offer strategy- Specified by:
deletein interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the type of object collectionguid- vitam guidofferIds- offers ids to delete- Returns:
- true if deleted
- Throws:
StorageServerClientException
-
exists
public java.util.Map<java.lang.String,java.lang.Boolean> exists(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds) throws StorageServerClientExceptionDescription copied from interface:StorageClientCheck the existence of an object in storage by its id and typeDataCategory.- Specified by:
existsin interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the type of object collectionguid- vitam guid- Returns:
- true/false for each offer
- Throws:
StorageServerClientException- if the Server got an internal error
-
bulkStoreFilesFromWorkspace
public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(java.lang.String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest)
Description copied from interface:StorageClientStore objects available in workspace into offers- Specified by:
bulkStoreFilesFromWorkspacein interfaceStorageClient- Parameters:
strategyId- the storage strategy idbulkObjectStoreRequest- request- Returns:
- the result status of object creation
-
getContainerAsync
public javax.ws.rs.core.Response getContainerAsync(java.lang.String strategyId, java.lang.String guid, DataCategory type, AccessLogInfoModel logInfo) throws StorageServerClientException, StorageNotFoundExceptionDescription copied from interface:StorageClientRetrieves a binary object knowing its guid as an inputStream for a specific tenant/strategy- Specified by:
getContainerAsyncin interfaceStorageClient- Parameters:
strategyId- the storage strategy idguid- vitam guid of the object to be returnedtype- the object type to listlogInfo- additional information for accessLog- Returns:
- the object requested
- Throws:
StorageServerClientException- if the Server got an internal errorStorageNotFoundException- if the Server got a NotFound result, if the container or the object does not exist
-
getContainerAsync
public javax.ws.rs.core.Response getContainerAsync(java.lang.String strategyId, java.lang.String offerId, java.lang.String objectName, DataCategory type, AccessLogInfoModel logInfo) throws StorageServerClientException, StorageNotFoundExceptionDescription copied from interface:StorageClientRetrieves a binary object knowing its guid as an inputStream for a specific tenant/strategy/offerId- Specified by:
getContainerAsyncin interfaceStorageClient- Returns:
- Throws:
StorageServerClientExceptionStorageNotFoundException
-
listContainer
public CloseableIterator<ObjectEntry> listContainer(java.lang.String strategyId, java.lang.String offerId, DataCategory type)
Description copied from interface:StorageClientList object type in container- Specified by:
listContainerin interfaceStorageClient- Parameters:
strategyId- the strategy IDofferId- the Offer IDtype- the object type to list- Returns:
- an iterator with object list
-
storageAccessLogBackup
public RequestResponseOK<StorageLogBackupResult> storageAccessLogBackup(java.util.List<java.lang.Integer> tenants)
Description copied from interface:StorageClientCall storage accesslog backup operation.- Specified by:
storageAccessLogBackupin interfaceStorageClient- Parameters:
tenants- tenants list to backup- Returns:
- Storage logbook backup response
-
storageLogBackup
public RequestResponseOK<StorageLogBackupResult> storageLogBackup(java.util.List<java.lang.Integer> tenants)
Description copied from interface:StorageClientCall storage log backup operation.- Specified by:
storageLogBackupin interfaceStorageClient- Parameters:
tenants- tenants list to backup- Returns:
- Storage logbook backup response
-
storageLogTraceability
public RequestResponseOK<StorageLogTraceabilityResult> storageLogTraceability(java.util.List<java.lang.Integer> tenants)
Description copied from interface:StorageClientCall storage log traceability operation.- Specified by:
storageLogTraceabilityin interfaceStorageClient- Returns:
- storage log traceability response
-
getInformation
public com.fasterxml.jackson.databind.JsonNode getInformation(java.lang.String strategyId, DataCategory type, java.lang.String guid, java.util.List<java.lang.String> offerIds, boolean noCache) throws StorageServerClientException, StorageNotFoundClientExceptionDescription copied from interface:StorageClientGet object information from objects in storage- Specified by:
getInformationin interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the object type to listguid- vitam guidofferIds- offers ids to deletenoCache- noCache forces digest computation.- Returns:
- informations
- Throws:
StorageServerClientException- StorageServerClientExceptionStorageNotFoundClientException- StorageNotFoundClientException
-
getBatchObjectInformation
public RequestResponse<BatchObjectInformationResponse> getBatchObjectInformation(java.lang.String strategyId, DataCategory type, java.util.Collection<java.lang.String> offerIds, java.util.Collection<java.lang.String> objectIds)
Description copied from interface:StorageClientGet object information from objects in storage- Specified by:
getBatchObjectInformationin interfaceStorageClient- Parameters:
strategyId- the storage strategy idtype- the object type to listofferIds- offers idsobjectIds- list of object ids- Returns:
- informations
-
copyObjectFromOfferToOffer
public RequestResponseOK copyObjectFromOfferToOffer(java.lang.String objectId, DataCategory category, java.lang.String source, java.lang.String destination, java.lang.String strategyId) throws StorageServerClientException, InvalidParseOperationException
- Specified by:
copyObjectFromOfferToOfferin interfaceStorageClient- Parameters:
objectId- objectIdcategory- categorysource- sourcedestination- destinationstrategyId- strategyId- Returns:
- RequestResponseOK
- Throws:
StorageServerClientException- StorageServerClientExceptionInvalidParseOperationException- StorageServerClientException
-
create
public RequestResponseOK create(java.lang.String strategyId, java.lang.String objectId, DataCategory category, java.io.InputStream inputStream, java.lang.Long inputStreamSize, java.util.List<java.lang.String> offerIds) throws StorageServerClientException, InvalidParseOperationException
- Specified by:
createin interfaceStorageClient- Parameters:
strategyId- strategyIdobjectId- objectIdcategory- categoryinputStream- inputStreaminputStreamSize- inputStreamSizeofferIds- offers ids- Returns:
- RequestResponseOK
- Throws:
StorageServerClientException- StorageServerClientExceptionInvalidParseOperationException- InvalidParseOperationException
-
getOfferLogs
public RequestResponse<OfferLog> getOfferLogs(java.lang.String strategyId, java.lang.String offerId, DataCategory type, java.lang.Long offset, int limit, Order order) throws StorageServerClientException
Description copied from interface:StorageClientGet offer log .- Specified by:
getOfferLogsin interfaceStorageClient- Parameters:
strategyId- the strategy to get offersofferId- the offer Id to read object fromtype- the object type to listoffset- offset of the last object beforelimit- the number of result wantedorder- the order order- Returns:
- list of offer log
- Throws:
StorageServerClientException
-
getStorageStrategies
public RequestResponse<StorageStrategy> getStorageStrategies() throws StorageServerClientException
Description copied from interface:StorageClientGet strategies.- Specified by:
getStorageStrategiesin interfaceStorageClient- Returns:
- strategies available for storage
- Throws:
StorageServerClientException
-
createAccessRequestIfRequired
public java.util.Optional<java.lang.String> createAccessRequestIfRequired(java.lang.String strategyId, java.lang.String offerId, DataCategory dataCategory, java.util.List<java.lang.String> objectNames)Description copied from interface:StorageClientCreate access request if target offer does not support synchronous read (tape library storage). If target offer supports synchronous read requests, then no access request is created.- Specified by:
createAccessRequestIfRequiredin interfaceStorageClient- Parameters:
strategyId- the target storage strategy identifierofferId- the target offer identifier (Optional). If provided, the offerId must be a valid active offer of the specified strategy. Otherwise, the referent offer of strategy is used.dataCategory- the data category of objects to which access is requestedobjectNames- the object names/ids/guids to which access is requested- Returns:
- an AccessRequestId if access request is required (async offer), otherwiser
Optional.empty()
-
checkAccessRequestStatuses
public java.util.Map<java.lang.String,AccessRequestStatus> checkAccessRequestStatuses(java.lang.String strategyId, java.lang.String offerId, java.util.List<java.lang.String> accessRequestIds, boolean adminCrossTenantAccessRequestAllowed)
Description copied from interface:StorageClientCheck access request statuses of asynchronous offer.- Specified by:
checkAccessRequestStatusesin interfaceStorageClient- Parameters:
strategyId- the target storage strategy identifierofferId- the target offer identifier (Optional). If provided, the offerId must be a valid active offer of the specified strategy. Otherwise, the referent offer of strategy is used.accessRequestIds- the accessRequestIds whose status is to be checkedadminCrossTenantAccessRequestAllowed- whentrue, access to access requests of other tenants is allowed from Admin tenant- Returns:
- the statuses of provided access request ids
-
removeAccessRequest
public void removeAccessRequest(java.lang.String strategyId, java.lang.String offerId, java.lang.String accessRequestId, boolean adminCrossTenantAccessRequestAllowed)Description copied from interface:StorageClientRemoves (cancel / delete) and access request for an asynchronous offer. Does nothing is access request id does not exist (idempotency)- Specified by:
removeAccessRequestin interfaceStorageClient- Parameters:
strategyId- the target storage strategy identifierofferId- the target offer identifier (Optional). If provided, the offerId must be a valid active offer of the specified strategy. Otherwise, the referent offer of strategy is used.accessRequestId- the accessRequestId to removeadminCrossTenantAccessRequestAllowed- whentrue, removing access requests of other tenants is allowed from Admin tenant
-
checkBulkObjectAvailability
public BulkObjectAvailabilityResponse checkBulkObjectAvailability(java.lang.String strategyId, java.lang.String offerId, BulkObjectAvailabilityRequest bulkObjectAvailabilityRequest)
Description copied from interface:StorageClientChecks immediate object availability in storage offer. Synchronous offers have guaranteed immediate availability of objects. Async offers (tape storage) may not be able to serve object immediately.- Specified by:
checkBulkObjectAvailabilityin interfaceStorageClient- Parameters:
strategyId- the target storage strategy identifierofferId- the target offer identifier (Optional). If provided, the offerId must be a valid active offer of the specified strategy. Otherwise, the referent offer of strategy is used.bulkObjectAvailabilityRequest- object availability check request- Returns:
trueif ALL objects are available, otherwisefalse.
-
getReferentOffer
public java.lang.String getReferentOffer(java.lang.String strategy) throws StorageNotFoundClientException, StorageServerClientExceptionDescription copied from interface:StorageClientGet referent offer of strategy- Specified by:
getReferentOfferin interfaceStorageClient- Returns:
- Throws:
StorageNotFoundClientExceptionStorageServerClientException
-
launchOfferLogCompaction
public javax.ws.rs.core.Response launchOfferLogCompaction(VitamContext vitamContext, java.lang.String offerId) throws StorageServerClientException
- Specified by:
launchOfferLogCompactionin interfaceStorageClient- Throws:
StorageServerClientException
-
-