@Test public void listObjectsTest() throws Exception { StorageListRequest storageRequest = new StorageListRequest(TENANT_ID, DataCategory.OBJECT.getFolder()); String responseContent = "{objectId:\"id\", size: 10}\n" + "{}"; InputStream is = new ByteArrayInputStream(responseContent.getBytes(StandardCharsets.UTF_8)); when(mock.get()).thenReturn(Response.ok(is).build()); try (Connection connection = driver.connect(offer.getId())) { Iterator<ObjectEntry> response = connection.listObjects(storageRequest); List<ObjectEntry> objectEntries = IteratorUtils.toList(response); assertThat(objectEntries).hasSize(1); assertThat(objectEntries.get(0).getObjectId()).isEqualTo("id"); assertThat(objectEntries.get(0).getSize()).isEqualTo(10L); } }
@Override public CloseableIterator<ObjectEntry> listObjects(StorageListRequest request) throws StorageDriverException { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); VitamRequestBuilder requestBuilder = get() .withPath(OBJECTS_PATH + "/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withJsonAccept(); try { Response response = make(requestBuilder); try { checkStorageException(response); } catch (Exception e) { StreamUtils.consumeAnyEntityAndClose(response); throw e; } InputStream rawResponseInputStream = response.readEntity(InputStream.class); return new ObjectEntryReader(rawResponseInputStream); } catch (Exception exc) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR), exc); throw new StorageDriverException(getDriverName(), true, exc); } }
ConnectionImpl extends AbstractConnection { @Override public CloseableIterator<ObjectEntry> listObjects(StorageListRequest request) throws StorageDriverException { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); VitamRequestBuilder requestBuilder = get() .withPath(OBJECTS_PATH + "/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withJsonAccept(); try { Response response = make(requestBuilder); try { checkStorageException(response); } catch (Exception e) { StreamUtils.consumeAnyEntityAndClose(response); throw e; } InputStream rawResponseInputStream = response.readEntity(InputStream.class); return new ObjectEntryReader(rawResponseInputStream); } catch (Exception exc) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR), exc); throw new StorageDriverException(getDriverName(), true, exc); } } }
ConnectionImpl extends AbstractConnection { @Override public CloseableIterator<ObjectEntry> listObjects(StorageListRequest request) throws StorageDriverException { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); VitamRequestBuilder requestBuilder = get() .withPath(OBJECTS_PATH + "/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withJsonAccept(); try { Response response = make(requestBuilder); try { checkStorageException(response); } catch (Exception e) { StreamUtils.consumeAnyEntityAndClose(response); throw e; } InputStream rawResponseInputStream = response.readEntity(InputStream.class); return new ObjectEntryReader(rawResponseInputStream); } catch (Exception exc) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR), exc); throw new StorageDriverException(getDriverName(), true, exc); } } ConnectionImpl(String driverName, VitamClientFactoryInterface<? extends AbstractConnection> factory); }
ConnectionImpl extends AbstractConnection { @Override public CloseableIterator<ObjectEntry> listObjects(StorageListRequest request) throws StorageDriverException { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); VitamRequestBuilder requestBuilder = get() .withPath(OBJECTS_PATH + "/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withJsonAccept(); try { Response response = make(requestBuilder); try { checkStorageException(response); } catch (Exception e) { StreamUtils.consumeAnyEntityAndClose(response); throw e; } InputStream rawResponseInputStream = response.readEntity(InputStream.class); return new ObjectEntryReader(rawResponseInputStream); } catch (Exception exc) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR), exc); throw new StorageDriverException(getDriverName(), true, exc); } } 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 CloseableIterator<ObjectEntry> listObjects(StorageListRequest request) throws StorageDriverException { ParametersChecker.checkParameter(REQUEST_IS_A_MANDATORY_PARAMETER, request); ParametersChecker.checkParameter(TENANT_IS_A_MANDATORY_PARAMETER, request.getTenantId()); ParametersChecker.checkParameter(TYPE_IS_A_MANDATORY_PARAMETER, request.getType()); VitamRequestBuilder requestBuilder = get() .withPath(OBJECTS_PATH + "/" + DataCategory.getByFolder(request.getType())) .withHeader(GlobalDataRest.X_TENANT_ID, request.getTenantId()) .withJsonAccept(); try { Response response = make(requestBuilder); try { checkStorageException(response); } catch (Exception e) { StreamUtils.consumeAnyEntityAndClose(response); throw e; } InputStream rawResponseInputStream = response.readEntity(InputStream.class); return new ObjectEntryReader(rawResponseInputStream); } catch (Exception exc) { LOGGER.error(VitamCodeHelper.getLogMessage(VitamCode.STORAGE_TECHNICAL_INTERNAL_ERROR), exc); throw new StorageDriverException(getDriverName(), true, exc); } } 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);  }