@Test(expected = StorageDriverException.class) public void bulkPutObjectsWithRequestThrowsNotFoundErrorOnPutKO() throws Exception { final StorageBulkPutRequest request = getBulkPutObjectsRequest(true, true, true, true, true); when(mock.put()).thenReturn(Response.status(Status.NOT_FOUND).build()); try (Connection connection = driver.connect(offer.getId())) { connection.bulkPutObjects(request); } }
@Override public StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException { try { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds()); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds().toArray()); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(ALGORITHM_IS_A_MANDATORY_PARAMETER, request.getDigestType()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); ParametersChecker.checkParameter(TYPE_IS_NOT_VALID, DataCategory.getByFolder(request.getType())); ParametersChecker.checkParameter(STREAM_IS_A_MANDATORY_PARAMETER, request.getDataStream()); } catch (final IllegalArgumentException e) { throw new StorageDriverPreconditionFailedException(getDriverName(), e); } VitamRequestBuilder requestBuilder = put() .withPath("/bulk/objects/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withHeader(GlobalDataRest.X_DIGEST_ALGORITHM, request.getDigestType().getName()) .withHeader(GlobalDataRest.VITAM_CONTENT_LENGTH, request.getSize()) .withBody(request.getDataStream()) .withOctetContentType() .withJsonAccept(); try (Response response = make(requestBuilder)) { checkStorageException(response); if (Status.CREATED.getStatusCode() != response.getStatus()) { throw new StorageDriverException(getDriverName(), "Error while performing bulk put object operation for objects " + request.getObjectIds() + " (" + request.getType() + ")", true); } return response.readEntity(StorageBulkPutResult.class); } catch (final VitamClientInternalException e) { throw new StorageDriverException(getDriverName(), true, e); } }
ConnectionImpl extends AbstractConnection { @Override public StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException { try { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds()); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds().toArray()); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(ALGORITHM_IS_A_MANDATORY_PARAMETER, request.getDigestType()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); ParametersChecker.checkParameter(TYPE_IS_NOT_VALID, DataCategory.getByFolder(request.getType())); ParametersChecker.checkParameter(STREAM_IS_A_MANDATORY_PARAMETER, request.getDataStream()); } catch (final IllegalArgumentException e) { throw new StorageDriverPreconditionFailedException(getDriverName(), e); } VitamRequestBuilder requestBuilder = put() .withPath("/bulk/objects/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withHeader(GlobalDataRest.X_DIGEST_ALGORITHM, request.getDigestType().getName()) .withHeader(GlobalDataRest.VITAM_CONTENT_LENGTH, request.getSize()) .withBody(request.getDataStream()) .withOctetContentType() .withJsonAccept(); try (Response response = make(requestBuilder)) { checkStorageException(response); if (Status.CREATED.getStatusCode() != response.getStatus()) { throw new StorageDriverException(getDriverName(), "Error while performing bulk put object operation for objects " + request.getObjectIds() + " (" + request.getType() + ")", true); } return response.readEntity(StorageBulkPutResult.class); } catch (final VitamClientInternalException e) { throw new StorageDriverException(getDriverName(), true, e); } } }
ConnectionImpl extends AbstractConnection { @Override public StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException { try { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds()); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds().toArray()); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(ALGORITHM_IS_A_MANDATORY_PARAMETER, request.getDigestType()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); ParametersChecker.checkParameter(TYPE_IS_NOT_VALID, DataCategory.getByFolder(request.getType())); ParametersChecker.checkParameter(STREAM_IS_A_MANDATORY_PARAMETER, request.getDataStream()); } catch (final IllegalArgumentException e) { throw new StorageDriverPreconditionFailedException(getDriverName(), e); } VitamRequestBuilder requestBuilder = put() .withPath("/bulk/objects/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withHeader(GlobalDataRest.X_DIGEST_ALGORITHM, request.getDigestType().getName()) .withHeader(GlobalDataRest.VITAM_CONTENT_LENGTH, request.getSize()) .withBody(request.getDataStream()) .withOctetContentType() .withJsonAccept(); try (Response response = make(requestBuilder)) { checkStorageException(response); if (Status.CREATED.getStatusCode() != response.getStatus()) { throw new StorageDriverException(getDriverName(), "Error while performing bulk put object operation for objects " + request.getObjectIds() + " (" + request.getType() + ")", true); } return response.readEntity(StorageBulkPutResult.class); } catch (final VitamClientInternalException e) { throw new StorageDriverException(getDriverName(), true, e); } } ConnectionImpl(String driverName, VitamClientFactoryInterface<? extends AbstractConnection> factory); }
ConnectionImpl extends AbstractConnection { @Override public StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException { try { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds()); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds().toArray()); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(ALGORITHM_IS_A_MANDATORY_PARAMETER, request.getDigestType()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); ParametersChecker.checkParameter(TYPE_IS_NOT_VALID, DataCategory.getByFolder(request.getType())); ParametersChecker.checkParameter(STREAM_IS_A_MANDATORY_PARAMETER, request.getDataStream()); } catch (final IllegalArgumentException e) { throw new StorageDriverPreconditionFailedException(getDriverName(), e); } VitamRequestBuilder requestBuilder = put() .withPath("/bulk/objects/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withHeader(GlobalDataRest.X_DIGEST_ALGORITHM, request.getDigestType().getName()) .withHeader(GlobalDataRest.VITAM_CONTENT_LENGTH, request.getSize()) .withBody(request.getDataStream()) .withOctetContentType() .withJsonAccept(); try (Response response = make(requestBuilder)) { checkStorageException(response); if (Status.CREATED.getStatusCode() != response.getStatus()) { throw new StorageDriverException(getDriverName(), "Error while performing bulk put object operation for objects " + request.getObjectIds() + " (" + request.getType() + ")", true); } return response.readEntity(StorageBulkPutResult.class); } catch (final VitamClientInternalException e) { throw new StorageDriverException(getDriverName(), true, e); } } ConnectionImpl(String driverName, VitamClientFactoryInterface<? extends AbstractConnection> factory); @Override StorageCapacityResult getStorageCapacity(Integer tenantId); @Override StorageGetResult getObject(StorageObjectRequest request); @Override RequestResponse<TapeReadRequestReferentialEntity> createReadOrderRequest(StorageObjectRequest request); @Override RequestResponse<TapeReadRequestReferentialEntity> getReadOrderRequest(String readOrderRequestId, int tenant); @Override void removeReadOrderRequest(String readOrderRequestId, int tenant); @Override StoragePutResult putObject(StoragePutRequest request); @Override StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request); @Override StorageRemoveResult removeObject(StorageRemoveRequest request); @Override boolean objectExistsInOffer(StorageObjectRequest request); @Override StorageMetadataResult getMetadatas(StorageGetMetadataRequest request); @Override CloseableIterator<ObjectEntry> listObjects(StorageListRequest request); @Override RequestResponse<OfferLog> getOfferLogs(StorageOfferLogRequest storageGetOfferLogRequest); }
ConnectionImpl extends AbstractConnection { @Override public StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request) throws StorageDriverException { try { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds()); ParametersChecker.checkParameter(GUID_IS_A_MANDATORY_PARAMETER, request.getObjectIds().toArray()); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(ALGORITHM_IS_A_MANDATORY_PARAMETER, request.getDigestType()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); ParametersChecker.checkParameter(TYPE_IS_NOT_VALID, DataCategory.getByFolder(request.getType())); ParametersChecker.checkParameter(STREAM_IS_A_MANDATORY_PARAMETER, request.getDataStream()); } catch (final IllegalArgumentException e) { throw new StorageDriverPreconditionFailedException(getDriverName(), e); } VitamRequestBuilder requestBuilder = put() .withPath("/bulk/objects/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withHeader(GlobalDataRest.X_DIGEST_ALGORITHM, request.getDigestType().getName()) .withHeader(GlobalDataRest.VITAM_CONTENT_LENGTH, request.getSize()) .withBody(request.getDataStream()) .withOctetContentType() .withJsonAccept(); try (Response response = make(requestBuilder)) { checkStorageException(response); if (Status.CREATED.getStatusCode() != response.getStatus()) { throw new StorageDriverException(getDriverName(), "Error while performing bulk put object operation for objects " + request.getObjectIds() + " (" + request.getType() + ")", true); } return response.readEntity(StorageBulkPutResult.class); } catch (final VitamClientInternalException e) { throw new StorageDriverException(getDriverName(), true, e); } } ConnectionImpl(String driverName, VitamClientFactoryInterface<? extends AbstractConnection> factory); @Override StorageCapacityResult getStorageCapacity(Integer tenantId); @Override StorageGetResult getObject(StorageObjectRequest request); @Override RequestResponse<TapeReadRequestReferentialEntity> createReadOrderRequest(StorageObjectRequest request); @Override RequestResponse<TapeReadRequestReferentialEntity> getReadOrderRequest(String readOrderRequestId, int tenant); @Override void removeReadOrderRequest(String readOrderRequestId, int tenant); @Override StoragePutResult putObject(StoragePutRequest request); @Override StorageBulkPutResult bulkPutObjects(StorageBulkPutRequest request); @Override StorageRemoveResult removeObject(StorageRemoveRequest request); @Override boolean objectExistsInOffer(StorageObjectRequest request); @Override StorageMetadataResult getMetadatas(StorageGetMetadataRequest request); @Override CloseableIterator<ObjectEntry> listObjects(StorageListRequest request); @Override RequestResponse<OfferLog> getOfferLogs(StorageOfferLogRequest storageGetOfferLogRequest);  }