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
,AutoCloseable
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
-
Method Summary
Modifier and TypeMethodDescriptionbulkStoreFilesFromWorkspace
(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) Store objects available in workspace into offerscheckAccessRequestStatuses
(String strategyId, String offerId, List<String> accessRequestIds, boolean adminCrossTenantAccessRequestAllowed) Check access request statuses of asynchronous offer.checkBulkObjectAvailability
(String strategyId, String offerId, BulkObjectAvailabilityRequest bulkObjectAvailabilityRequest) Checks immediate object availability in storage offer.copyObjectFromOfferToOffer
(String objectId, DataCategory category, String source, String destination, String strategyId) create
(String strategyId, String objectId, DataCategory category, InputStream inputStream, Long inputStreamSize, List<String> offerIds) createAccessRequestIfRequired
(String strategyId, String offerId, DataCategory dataCategory, List<String> objectNames) Create access request if target offer does not support synchronous read (tape library storage).boolean
delete
(String strategyId, DataCategory type, String guid) Delete an object of given type in the storage offer strategyboolean
Delete an object of given type in the storage offer strategyCheck the existence of an object in storage by its id and typeDataCategory
.getBatchObjectInformation
(String strategyId, DataCategory type, Collection<String> offerIds, Collection<String> objectIds) Get object information from objects in storagejavax.ws.rs.core.Response
getContainerAsync
(String strategyId, String guid, DataCategory type, AccessLogInfoModel logInfo) Retrieves a binary object knowing its guid as an inputStream for a specific tenant/strategyjavax.ws.rs.core.Response
getContainerAsync
(String strategyId, String offerId, 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.JsonNode
getInformation
(String strategyId, DataCategory type, String guid, List<String> offerIds, boolean noCache) Get object information from objects in storagegetOfferLogs
(String strategyId, String offerId, DataCategory type, Long offset, int limit, Order order) Get offer log .get List of offers for a strategygetReferentOffer
(String strategy) Get referent offer of strategycom.fasterxml.jackson.databind.JsonNode
getStorageInformation
(String strategyId) Check if the storage of objects could be done, knowing a required sizeGet strategies.javax.ws.rs.core.Response
launchOfferLogCompaction
(VitamContext vitamContext, String offerId) listContainer
(String strategyId, String offerId, DataCategory type) List object type in containervoid
removeAccessRequest
(String strategyId, String offerId, String accessRequestId, boolean adminCrossTenantAccessRequestAllowed) Removes (cancel / delete) and access request for an asynchronous offer.storageAccessLogBackup
(List<Integer> tenants) Call storage accesslog backup operation.storageLogBackup
(List<Integer> tenants) Call storage log backup operation.storageLogTraceability
(List<Integer> tenants) Call storage log traceability operation.storeFileFromWorkspace
(String strategyId, DataCategory type, String guid, ObjectDescription description) Store an object available in workspace by its vitam guidMethods 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
-
Constructor Details
-
StorageClientMock
public StorageClientMock()
-
-
Method Details
-
getStorageInformation
public com.fasterxml.jackson.databind.JsonNode getStorageInformation(String strategyId) throws StorageServerClientException Description copied from interface:StorageClient
Check if the storage of objects could be done, knowing a required size- Specified by:
getStorageInformation
in interfaceStorageClient
- Parameters:
strategyId
- the storage strategy id- Returns:
- the capacity of the storage
- Throws:
StorageServerClientException
- if the Server got an internal error
-
getOffers
public List<String> getOffers(String strategyId) throws StorageNotFoundClientException, StorageServerClientException Description copied from interface:StorageClient
get List of offers for a strategy- Specified by:
getOffers
in interfaceStorageClient
- Parameters:
strategyId
- strategyId- Returns:
- list id of offers
- Throws:
StorageNotFoundClientException
StorageServerClientException
-
storeFileFromWorkspace
public StoredInfoResult storeFileFromWorkspace(String strategyId, DataCategory type, String guid, ObjectDescription description) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException Description copied from interface:StorageClient
Store an object available in workspace by its vitam guid- Specified by:
storeFileFromWorkspace
in 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(String strategyId, DataCategory type, String guid) throws StorageServerClientException Description copied from interface:StorageClient
Delete an object of given type in the storage offer strategy- Specified by:
delete
in 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(String strategyId, DataCategory type, String guid, List<String> offerIds) throws StorageServerClientException Description copied from interface:StorageClient
Delete an object of given type in the storage offer strategy- Specified by:
delete
in 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 Map<String,Boolean> exists(String strategyId, DataCategory type, String guid, List<String> offerIds) throws StorageServerClientException Description copied from interface:StorageClient
Check the existence of an object in storage by its id and typeDataCategory
.- Specified by:
exists
in 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(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) Description copied from interface:StorageClient
Store objects available in workspace into offers- Specified by:
bulkStoreFilesFromWorkspace
in interfaceStorageClient
- Parameters:
strategyId
- the storage strategy idbulkObjectStoreRequest
- request- Returns:
- the result status of object creation
-
getContainerAsync
public javax.ws.rs.core.Response getContainerAsync(String strategyId, String guid, DataCategory type, AccessLogInfoModel logInfo) throws StorageServerClientException, StorageNotFoundException Description copied from interface:StorageClient
Retrieves a binary object knowing its guid as an inputStream for a specific tenant/strategy- Specified by:
getContainerAsync
in 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(String strategyId, String offerId, String objectName, DataCategory type, AccessLogInfoModel logInfo) throws StorageServerClientException, StorageNotFoundException Description copied from interface:StorageClient
Retrieves a binary object knowing its guid as an inputStream for a specific tenant/strategy/offerId- Specified by:
getContainerAsync
in interfaceStorageClient
- Returns:
- Throws:
StorageServerClientException
StorageNotFoundException
-
listContainer
public CloseableIterator<ObjectEntry> listContainer(String strategyId, String offerId, DataCategory type) Description copied from interface:StorageClient
List object type in container- Specified by:
listContainer
in interfaceStorageClient
- Parameters:
strategyId
- the strategy IDofferId
- the Offer IDtype
- the object type to list- Returns:
- an iterator with object list
-
storageAccessLogBackup
Description copied from interface:StorageClient
Call storage accesslog backup operation.- Specified by:
storageAccessLogBackup
in interfaceStorageClient
- Parameters:
tenants
- tenants list to backup- Returns:
- Storage logbook backup response
-
storageLogBackup
Description copied from interface:StorageClient
Call storage log backup operation.- Specified by:
storageLogBackup
in interfaceStorageClient
- Parameters:
tenants
- tenants list to backup- Returns:
- Storage logbook backup response
-
storageLogTraceability
public RequestResponseOK<StorageLogTraceabilityResult> storageLogTraceability(List<Integer> tenants) Description copied from interface:StorageClient
Call storage log traceability operation.- Specified by:
storageLogTraceability
in interfaceStorageClient
- Returns:
- storage log traceability response
-
getInformation
public com.fasterxml.jackson.databind.JsonNode getInformation(String strategyId, DataCategory type, String guid, List<String> offerIds, boolean noCache) throws StorageServerClientException, StorageNotFoundClientException Description copied from interface:StorageClient
Get object information from objects in storage- Specified by:
getInformation
in 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(String strategyId, DataCategory type, Collection<String> offerIds, Collection<String> objectIds) Description copied from interface:StorageClient
Get object information from objects in storage- Specified by:
getBatchObjectInformation
in interfaceStorageClient
- Parameters:
strategyId
- the storage strategy idtype
- the object type to listofferIds
- offers idsobjectIds
- list of object ids- Returns:
- informations
-
copyObjectFromOfferToOffer
public RequestResponseOK copyObjectFromOfferToOffer(String objectId, DataCategory category, String source, String destination, String strategyId) throws StorageServerClientException, InvalidParseOperationException - Specified by:
copyObjectFromOfferToOffer
in interfaceStorageClient
- Parameters:
objectId
- objectIdcategory
- categorysource
- sourcedestination
- destinationstrategyId
- strategyId- Returns:
- RequestResponseOK
- Throws:
StorageServerClientException
- StorageServerClientExceptionInvalidParseOperationException
- StorageServerClientException
-
create
public RequestResponseOK create(String strategyId, String objectId, DataCategory category, InputStream inputStream, Long inputStreamSize, List<String> offerIds) throws StorageServerClientException, InvalidParseOperationException - Specified by:
create
in interfaceStorageClient
- Parameters:
strategyId
- strategyIdobjectId
- objectIdcategory
- categoryinputStream
- inputStreaminputStreamSize
- inputStreamSizeofferIds
- offers ids- Returns:
- RequestResponseOK
- Throws:
StorageServerClientException
- StorageServerClientExceptionInvalidParseOperationException
- InvalidParseOperationException
-
getOfferLogs
public RequestResponse<OfferLog> getOfferLogs(String strategyId, String offerId, DataCategory type, Long offset, int limit, Order order) throws StorageServerClientException Description copied from interface:StorageClient
Get offer log .- Specified by:
getOfferLogs
in 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
Description copied from interface:StorageClient
Get strategies.- Specified by:
getStorageStrategies
in interfaceStorageClient
- Returns:
- strategies available for storage
- Throws:
StorageServerClientException
-
createAccessRequestIfRequired
public Optional<String> createAccessRequestIfRequired(String strategyId, String offerId, DataCategory dataCategory, List<String> objectNames) Description copied from interface:StorageClient
Create 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:
createAccessRequestIfRequired
in 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 Map<String,AccessRequestStatus> checkAccessRequestStatuses(String strategyId, String offerId, List<String> accessRequestIds, boolean adminCrossTenantAccessRequestAllowed) Description copied from interface:StorageClient
Check access request statuses of asynchronous offer.- Specified by:
checkAccessRequestStatuses
in 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(String strategyId, String offerId, String accessRequestId, boolean adminCrossTenantAccessRequestAllowed) Description copied from interface:StorageClient
Removes (cancel / delete) and access request for an asynchronous offer. Does nothing is access request id does not exist (idempotency)- Specified by:
removeAccessRequest
in 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(String strategyId, String offerId, BulkObjectAvailabilityRequest bulkObjectAvailabilityRequest) Description copied from interface:StorageClient
Checks 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:
checkBulkObjectAvailability
in 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:
true
if ALL objects are available, otherwisefalse
.
-
getReferentOffer
public String getReferentOffer(String strategy) throws StorageNotFoundClientException, StorageServerClientException Description copied from interface:StorageClient
Get referent offer of strategy- Specified by:
getReferentOffer
in interfaceStorageClient
- Returns:
- Throws:
StorageNotFoundClientException
StorageServerClientException
-
launchOfferLogCompaction
public javax.ws.rs.core.Response launchOfferLogCompaction(VitamContext vitamContext, String offerId) throws StorageServerClientException - Specified by:
launchOfferLogCompaction
in interfaceStorageClient
- Throws:
StorageServerClientException
-