@RunWithCustomExecutor @Test(expected = StorageAlreadyExistsClientException.class) public void bulkCreateFromWorkspaceAlreadyExist() throws Exception { VitamThreadUtils.getVitamSession().setTenantId(TENANT_ID); when(mock.post()).thenReturn(Response.status(Response.Status.CONFLICT).build()); client.bulkStoreFilesFromWorkspace("idStrategy", getBulkObjectStoreRequest()); }
@Override public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException { Integer tenantId = ParameterHelper.getTenantParameter(); ParametersChecker.checkParameter("Expected valid request", bulkObjectStoreRequest); ParametersChecker.checkParameter("Invalid digest type", bulkObjectStoreRequest.getType()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs().toArray()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames().toArray()); if (bulkObjectStoreRequest.getObjectNames().size() != bulkObjectStoreRequest.getWorkspaceObjectURIs().size()) { throw new IllegalArgumentException("Object uris count do not match object ids count"); } VitamRequestBuilder request = post() .withPath("/bulk/" + bulkObjectStoreRequest.getType().getCollectionName()) .withHeader(GlobalDataRest.X_TENANT_ID, tenantId) .withHeader(GlobalDataRest.X_STRATEGY_ID, strategyId) .withBody(bulkObjectStoreRequest) .withJson(); try (Response response = make(request)) { return handleCommonResponseStatus(response).readEntity(BulkObjectStoreResponse.class); } catch (final VitamClientInternalException e) { final String errorMessage = VitamCodeHelper.getMessageFromVitamCode(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR); LOGGER.error(errorMessage, e); throw new StorageServerClientException(errorMessage, e); } }
StorageClientRest extends DefaultClient implements StorageClient { @Override public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException { Integer tenantId = ParameterHelper.getTenantParameter(); ParametersChecker.checkParameter("Expected valid request", bulkObjectStoreRequest); ParametersChecker.checkParameter("Invalid digest type", bulkObjectStoreRequest.getType()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs().toArray()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames().toArray()); if (bulkObjectStoreRequest.getObjectNames().size() != bulkObjectStoreRequest.getWorkspaceObjectURIs().size()) { throw new IllegalArgumentException("Object uris count do not match object ids count"); } VitamRequestBuilder request = post() .withPath("/bulk/" + bulkObjectStoreRequest.getType().getCollectionName()) .withHeader(GlobalDataRest.X_TENANT_ID, tenantId) .withHeader(GlobalDataRest.X_STRATEGY_ID, strategyId) .withBody(bulkObjectStoreRequest) .withJson(); try (Response response = make(request)) { return handleCommonResponseStatus(response).readEntity(BulkObjectStoreResponse.class); } catch (final VitamClientInternalException e) { final String errorMessage = VitamCodeHelper.getMessageFromVitamCode(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR); LOGGER.error(errorMessage, e); throw new StorageServerClientException(errorMessage, e); } } }
StorageClientRest extends DefaultClient implements StorageClient { @Override public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException { Integer tenantId = ParameterHelper.getTenantParameter(); ParametersChecker.checkParameter("Expected valid request", bulkObjectStoreRequest); ParametersChecker.checkParameter("Invalid digest type", bulkObjectStoreRequest.getType()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs().toArray()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames().toArray()); if (bulkObjectStoreRequest.getObjectNames().size() != bulkObjectStoreRequest.getWorkspaceObjectURIs().size()) { throw new IllegalArgumentException("Object uris count do not match object ids count"); } VitamRequestBuilder request = post() .withPath("/bulk/" + bulkObjectStoreRequest.getType().getCollectionName()) .withHeader(GlobalDataRest.X_TENANT_ID, tenantId) .withHeader(GlobalDataRest.X_STRATEGY_ID, strategyId) .withBody(bulkObjectStoreRequest) .withJson(); try (Response response = make(request)) { return handleCommonResponseStatus(response).readEntity(BulkObjectStoreResponse.class); } catch (final VitamClientInternalException e) { final String errorMessage = VitamCodeHelper.getMessageFromVitamCode(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR); LOGGER.error(errorMessage, e); throw new StorageServerClientException(errorMessage, e); } } StorageClientRest(StorageClientFactory factory); }
StorageClientRest extends DefaultClient implements StorageClient { @Override public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException { Integer tenantId = ParameterHelper.getTenantParameter(); ParametersChecker.checkParameter("Expected valid request", bulkObjectStoreRequest); ParametersChecker.checkParameter("Invalid digest type", bulkObjectStoreRequest.getType()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs().toArray()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames().toArray()); if (bulkObjectStoreRequest.getObjectNames().size() != bulkObjectStoreRequest.getWorkspaceObjectURIs().size()) { throw new IllegalArgumentException("Object uris count do not match object ids count"); } VitamRequestBuilder request = post() .withPath("/bulk/" + bulkObjectStoreRequest.getType().getCollectionName()) .withHeader(GlobalDataRest.X_TENANT_ID, tenantId) .withHeader(GlobalDataRest.X_STRATEGY_ID, strategyId) .withBody(bulkObjectStoreRequest) .withJson(); try (Response response = make(request)) { return handleCommonResponseStatus(response).readEntity(BulkObjectStoreResponse.class); } catch (final VitamClientInternalException e) { final String errorMessage = VitamCodeHelper.getMessageFromVitamCode(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR); LOGGER.error(errorMessage, e); throw new StorageServerClientException(errorMessage, e); } } StorageClientRest(StorageClientFactory factory); @Override JsonNode getStorageInformation(String strategyId); @Override List<String> getOffers(String strategyId); @Override StoredInfoResult storeFileFromWorkspace(String strategyId, DataCategory type, String guid,
        ObjectDescription description); @Override BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId,
        BulkObjectStoreRequest bulkObjectStoreRequest); @Override boolean existsContainer(String strategyId); @Override Map<String, Boolean> exists(String strategyId, DataCategory type, String guid, List<String> offerIds); @Override JsonNode getInformation(String strategyId, DataCategory type, String guid, List<String> offerIds,
        boolean noCache); @Override RequestResponse<BatchObjectInformationResponse> getBatchObjectInformation(String strategyId,
        DataCategory type, Collection<String> offerIds,
        Collection<String> objectIds); @Override boolean delete(String strategyId, DataCategory type, String guid); @Override boolean delete(String strategyId, DataCategory type, String guid, List<String> offerIds); @Override Response getContainerAsync(String strategyId, String guid, DataCategory type, AccessLogInfoModel logInfo); @Override CloseableIterator<ObjectEntry> listContainer(String strategyId, DataCategory type); @Override RequestResponseOK storageAccessLogBackup(); @Override RequestResponseOK storageLogBackup(); @Override RequestResponseOK storageLogTraceability(); @Override RequestResponseOK copyObjectToOneOfferAnother(String objectId, DataCategory category, String source,
        String destination, String strategyId); @Override RequestResponseOK create(String strategyId, String objectId, DataCategory category, InputStream inputStream,
        Long inputStreamSize,
        List<String> offerIds); @Override RequestResponse<OfferLog> getOfferLogs(String strategyId, DataCategory type, Long offset, int limit,
        Order order); @Override RequestResponse<StorageStrategy> getStorageStrategies(); }
StorageClientRest extends DefaultClient implements StorageClient { @Override public BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId, BulkObjectStoreRequest bulkObjectStoreRequest) throws StorageAlreadyExistsClientException, StorageNotFoundClientException, StorageServerClientException { Integer tenantId = ParameterHelper.getTenantParameter(); ParametersChecker.checkParameter("Expected valid request", bulkObjectStoreRequest); ParametersChecker.checkParameter("Invalid digest type", bulkObjectStoreRequest.getType()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs()); ParametersChecker.checkParameter("Invalid workspace URIs", bulkObjectStoreRequest.getWorkspaceObjectURIs().toArray()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames()); ParametersChecker.checkParameter("Invalid object ids", bulkObjectStoreRequest.getObjectNames().toArray()); if (bulkObjectStoreRequest.getObjectNames().size() != bulkObjectStoreRequest.getWorkspaceObjectURIs().size()) { throw new IllegalArgumentException("Object uris count do not match object ids count"); } VitamRequestBuilder request = post() .withPath("/bulk/" + bulkObjectStoreRequest.getType().getCollectionName()) .withHeader(GlobalDataRest.X_TENANT_ID, tenantId) .withHeader(GlobalDataRest.X_STRATEGY_ID, strategyId) .withBody(bulkObjectStoreRequest) .withJson(); try (Response response = make(request)) { return handleCommonResponseStatus(response).readEntity(BulkObjectStoreResponse.class); } catch (final VitamClientInternalException e) { final String errorMessage = VitamCodeHelper.getMessageFromVitamCode(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR); LOGGER.error(errorMessage, e); throw new StorageServerClientException(errorMessage, e); } } StorageClientRest(StorageClientFactory factory); @Override JsonNode getStorageInformation(String strategyId); @Override List<String> getOffers(String strategyId); @Override StoredInfoResult storeFileFromWorkspace(String strategyId, DataCategory type, String guid,
        ObjectDescription description); @Override BulkObjectStoreResponse bulkStoreFilesFromWorkspace(String strategyId,
        BulkObjectStoreRequest bulkObjectStoreRequest); @Override boolean existsContainer(String strategyId); @Override Map<String, Boolean> exists(String strategyId, DataCategory type, String guid, List<String> offerIds); @Override JsonNode getInformation(String strategyId, DataCategory type, String guid, List<String> offerIds,
        boolean noCache); @Override RequestResponse<BatchObjectInformationResponse> getBatchObjectInformation(String strategyId,
        DataCategory type, Collection<String> offerIds,
        Collection<String> objectIds); @Override boolean delete(String strategyId, DataCategory type, String guid); @Override boolean delete(String strategyId, DataCategory type, String guid, List<String> offerIds); @Override Response getContainerAsync(String strategyId, String guid, DataCategory type, AccessLogInfoModel logInfo); @Override CloseableIterator<ObjectEntry> listContainer(String strategyId, DataCategory type); @Override RequestResponseOK storageAccessLogBackup(); @Override RequestResponseOK storageLogBackup(); @Override RequestResponseOK storageLogTraceability(); @Override RequestResponseOK copyObjectToOneOfferAnother(String objectId, DataCategory category, String source,
        String destination, String strategyId); @Override RequestResponseOK create(String strategyId, String objectId, DataCategory category, InputStream inputStream,
        Long inputStreamSize,
        List<String> offerIds); @Override RequestResponse<OfferLog> getOfferLogs(String strategyId, DataCategory type, Long offset, int limit,
        Order order); @Override RequestResponse<StorageStrategy> getStorageStrategies();  }