@RunWithCustomExecutor @Test public void listContainerObjectsTests() throws Exception { try { simpleDistribution.listContainerObjects(null, null); fail("Waiting for an illegal argument exception"); } catch (IllegalArgumentException exc) { } try { simpleDistribution.listContainerObjects(VitamConfiguration.getDefaultStrategy(), null); fail("Waiting for an illegal argument exception"); } catch (IllegalArgumentException exc) { } try { simpleDistribution.listContainerObjects(VitamConfiguration.getDefaultStrategy(), DataCategory.OBJECT); fail("Waiting for an illegal argument exception"); } catch (IllegalArgumentException exc) { } try { simpleDistribution.listContainerObjects(VitamConfiguration.getDefaultStrategy(), null); fail("Waiting for an illegal argument exception"); } catch (IllegalArgumentException exc) { } try { VitamThreadUtils.getVitamSession().setTenantId(0); simpleDistribution.listContainerObjects(VitamConfiguration.getDefaultStrategy(), DataCategory.OBJECT); } catch (IllegalArgumentException exc) { fail("Waiting for an illegal argument exception"); } }
@Override public CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category) throws StorageException { ParametersChecker.checkParameter(STRATEGY_ID_IS_MANDATORY, strategyId); ParametersChecker.checkParameter(CATEGORY_IS_MANDATORY, category); final StorageStrategy storageStrategy = STRATEGY_PROVIDER.getStorageStrategy(strategyId); if (storageStrategy != null) { final List<OfferReference> offerReferenceList = getOfferListFromHotStrategy(storageStrategy); Optional<OfferReference> offerReference = offerReferenceList .stream() .filter(OfferReference::isReferent) .findFirst(); if (!offerReference.isPresent()) { offerReference = offerReferenceList .stream() .findFirst(); } if (!offerReference.isPresent()) { LOGGER.error("No offer found"); throw new StorageTechnicalException("No offer found"); } return listContainerObjectsForOffer(category, offerReference.get().getId(), false); } LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); throw new StorageNotFoundException(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); }
StorageDistributionImpl implements StorageDistribution { @Override public CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category) throws StorageException { ParametersChecker.checkParameter(STRATEGY_ID_IS_MANDATORY, strategyId); ParametersChecker.checkParameter(CATEGORY_IS_MANDATORY, category); final StorageStrategy storageStrategy = STRATEGY_PROVIDER.getStorageStrategy(strategyId); if (storageStrategy != null) { final List<OfferReference> offerReferenceList = getOfferListFromHotStrategy(storageStrategy); Optional<OfferReference> offerReference = offerReferenceList .stream() .filter(OfferReference::isReferent) .findFirst(); if (!offerReference.isPresent()) { offerReference = offerReferenceList .stream() .findFirst(); } if (!offerReference.isPresent()) { LOGGER.error("No offer found"); throw new StorageTechnicalException("No offer found"); } return listContainerObjectsForOffer(category, offerReference.get().getId(), false); } LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); throw new StorageNotFoundException(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); } }
StorageDistributionImpl implements StorageDistribution { @Override public CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category) throws StorageException { ParametersChecker.checkParameter(STRATEGY_ID_IS_MANDATORY, strategyId); ParametersChecker.checkParameter(CATEGORY_IS_MANDATORY, category); final StorageStrategy storageStrategy = STRATEGY_PROVIDER.getStorageStrategy(strategyId); if (storageStrategy != null) { final List<OfferReference> offerReferenceList = getOfferListFromHotStrategy(storageStrategy); Optional<OfferReference> offerReference = offerReferenceList .stream() .filter(OfferReference::isReferent) .findFirst(); if (!offerReference.isPresent()) { offerReference = offerReferenceList .stream() .findFirst(); } if (!offerReference.isPresent()) { LOGGER.error("No offer found"); throw new StorageTechnicalException("No offer found"); } return listContainerObjectsForOffer(category, offerReference.get().getId(), false); } LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); throw new StorageNotFoundException(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); } StorageDistributionImpl(StorageConfiguration configuration, StorageLog storageLogService); @VisibleForTesting  StorageDistributionImpl(WorkspaceClientFactory workspaceClientFactory, DigestType digestType,
        StorageLog storageLogService,
        ExecutorService batchExecutorService, int batchDigestComputationTimeout,
        BulkStorageDistribution bulkStorageDistribution); }
StorageDistributionImpl implements StorageDistribution { @Override public CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category) throws StorageException { ParametersChecker.checkParameter(STRATEGY_ID_IS_MANDATORY, strategyId); ParametersChecker.checkParameter(CATEGORY_IS_MANDATORY, category); final StorageStrategy storageStrategy = STRATEGY_PROVIDER.getStorageStrategy(strategyId); if (storageStrategy != null) { final List<OfferReference> offerReferenceList = getOfferListFromHotStrategy(storageStrategy); Optional<OfferReference> offerReference = offerReferenceList .stream() .filter(OfferReference::isReferent) .findFirst(); if (!offerReference.isPresent()) { offerReference = offerReferenceList .stream() .findFirst(); } if (!offerReference.isPresent()) { LOGGER.error("No offer found"); throw new StorageTechnicalException("No offer found"); } return listContainerObjectsForOffer(category, offerReference.get().getId(), false); } LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); throw new StorageNotFoundException(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); } StorageDistributionImpl(StorageConfiguration configuration, StorageLog storageLogService); @VisibleForTesting  StorageDistributionImpl(WorkspaceClientFactory workspaceClientFactory, DigestType digestType,
        StorageLog storageLogService,
        ExecutorService batchExecutorService, int batchDigestComputationTimeout,
        BulkStorageDistribution bulkStorageDistribution); @Override StoredInfoResult copyObjectFromOfferToOffer(DataContext context, String sourceOffer, String destinationOffer); @Override StoredInfoResult storeDataInOffers(String strategyId, String objectId, DataCategory category,
        String requester,
        List<String> offerIds, Response response); @Override StoredInfoResult storeDataInOffers(String strategyId, StreamAndInfo streamAndInfo, String objectId,
        DataCategory category, String requester,
        List<String> offerIds); @Override StoredInfoResult storeDataInAllOffers(String strategyId, String objectId,
        ObjectDescription createObjectDescription, DataCategory category, String requester); @Override BulkObjectStoreResponse bulkCreateFromWorkspace(String strategyId,
        BulkObjectStoreRequest bulkObjectStoreRequest, String requester); @Override List<String> getOfferIds(String strategyId); @Override Map<String, StorageStrategy> getStrategies(); @Override JsonNode getContainerInformation(String strategyId); @Override CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category); @Override CloseableIterator<ObjectEntry> listContainerObjectsForOffer(DataCategory category,
        String offerId, boolean includeDisabled); @Override RequestResponse<OfferLog> getOfferLogs(String strategyId, DataCategory category, Long offset, int limit,
        Order order); @Override RequestResponse<OfferLog> getOfferLogsByOfferId(String strategyId, String offerId,
        DataCategory category,
        Long offset, int limit, Order order); @Override Response getContainerByCategory(String strategyId, String objectId, DataCategory category,
        AccessLogInfoModel logInformation); @Override Response getContainerByCategory(String strategyId, String objectId, DataCategory category, String
        offerId); @Override JsonNode getContainerInformation(String strategyId, DataCategory type, String objectId,
        List<String> offerIds, boolean noCache); @Override Map<String, Boolean> checkObjectExisting(String strategyId, String objectId, DataCategory category,
        List<String> offerIds); @Override void deleteObjectInAllOffers(String strategyId, DataContext context); @Override void deleteObjectInOffers(String strategyId, DataContext context, List<String> offers); @Override List<BatchObjectInformationResponse> getBatchObjectInformation(String strategyId, DataCategory type,
        List<String> objectIds, List<String> offerIds); @Override void close(); }
StorageDistributionImpl implements StorageDistribution { @Override public CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category) throws StorageException { ParametersChecker.checkParameter(STRATEGY_ID_IS_MANDATORY, strategyId); ParametersChecker.checkParameter(CATEGORY_IS_MANDATORY, category); final StorageStrategy storageStrategy = STRATEGY_PROVIDER.getStorageStrategy(strategyId); if (storageStrategy != null) { final List<OfferReference> offerReferenceList = getOfferListFromHotStrategy(storageStrategy); Optional<OfferReference> offerReference = offerReferenceList .stream() .filter(OfferReference::isReferent) .findFirst(); if (!offerReference.isPresent()) { offerReference = offerReferenceList .stream() .findFirst(); } if (!offerReference.isPresent()) { LOGGER.error("No offer found"); throw new StorageTechnicalException("No offer found"); } return listContainerObjectsForOffer(category, offerReference.get().getId(), false); } LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); throw new StorageNotFoundException(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_STRATEGY_NOT_FOUND)); } StorageDistributionImpl(StorageConfiguration configuration, StorageLog storageLogService); @VisibleForTesting  StorageDistributionImpl(WorkspaceClientFactory workspaceClientFactory, DigestType digestType,
        StorageLog storageLogService,
        ExecutorService batchExecutorService, int batchDigestComputationTimeout,
        BulkStorageDistribution bulkStorageDistribution); @Override StoredInfoResult copyObjectFromOfferToOffer(DataContext context, String sourceOffer, String destinationOffer); @Override StoredInfoResult storeDataInOffers(String strategyId, String objectId, DataCategory category,
        String requester,
        List<String> offerIds, Response response); @Override StoredInfoResult storeDataInOffers(String strategyId, StreamAndInfo streamAndInfo, String objectId,
        DataCategory category, String requester,
        List<String> offerIds); @Override StoredInfoResult storeDataInAllOffers(String strategyId, String objectId,
        ObjectDescription createObjectDescription, DataCategory category, String requester); @Override BulkObjectStoreResponse bulkCreateFromWorkspace(String strategyId,
        BulkObjectStoreRequest bulkObjectStoreRequest, String requester); @Override List<String> getOfferIds(String strategyId); @Override Map<String, StorageStrategy> getStrategies(); @Override JsonNode getContainerInformation(String strategyId); @Override CloseableIterator<ObjectEntry> listContainerObjects(String strategyId, DataCategory category); @Override CloseableIterator<ObjectEntry> listContainerObjectsForOffer(DataCategory category,
        String offerId, boolean includeDisabled); @Override RequestResponse<OfferLog> getOfferLogs(String strategyId, DataCategory category, Long offset, int limit,
        Order order); @Override RequestResponse<OfferLog> getOfferLogsByOfferId(String strategyId, String offerId,
        DataCategory category,
        Long offset, int limit, Order order); @Override Response getContainerByCategory(String strategyId, String objectId, DataCategory category,
        AccessLogInfoModel logInformation); @Override Response getContainerByCategory(String strategyId, String objectId, DataCategory category, String
        offerId); @Override JsonNode getContainerInformation(String strategyId, DataCategory type, String objectId,
        List<String> offerIds, boolean noCache); @Override Map<String, Boolean> checkObjectExisting(String strategyId, String objectId, DataCategory category,
        List<String> offerIds); @Override void deleteObjectInAllOffers(String strategyId, DataContext context); @Override void deleteObjectInOffers(String strategyId, DataContext context, List<String> offers); @Override List<BatchObjectInformationResponse> getBatchObjectInformation(String strategyId, DataCategory type,
        List<String> objectIds, List<String> offerIds); @Override void close(); static final String DIGEST; }