@Test public void getObjectMetadataExistingObject() throws Exception { doReturn(Optional.of( new TapeObjectReferentialEntity(new TapeLibraryObjectReferentialId("containerName", "objectName"), 20L, "SHA-512", "digest", "storageId", null, "date1", "date2")) ).when(objectReferentialRepository).find(any(), any()); MetadatasObject objectMetadata = tapeLibraryContentAddressableStorage.getObjectMetadata("0_unit", "objectName", true); assertThat(objectMetadata.getType()).isEqualTo("unit"); assertThat(objectMetadata.getDigest()).isEqualTo("digest"); assertThat(objectMetadata.getFileSize()).isEqualTo(20L); assertThat(objectMetadata.getObjectName()).isEqualTo("objectName"); assertThat(objectMetadata.getLastModifiedDate()).isEqualTo("date1"); verify(objectReferentialRepository).find("0_unit", "objectName"); Mockito.verifyNoMoreInteractions(basicFileStorage, objectReferentialRepository, archiveReferentialRepository, fileBucketTarCreatorManager, readWriteQueueRepository, tapeCatalogService); }
@Override public MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache) throws ContentAddressableStorageException { LOGGER.debug(String.format("Get metadata of object %s in container %s", objectName, containerName)); ParametersChecker.checkParameter(ErrorMessage.CONTAINER_OBJECT_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, objectName); try { Optional<TapeObjectReferentialEntity> objectReferentialEntity = objectReferentialRepository.find(containerName, objectName); if (!objectReferentialEntity.isPresent()) { throw new ContentAddressableStorageNotFoundException( String.format("No such object %s in container %s", objectName, containerName)); } MetadatasStorageObject result = new MetadatasStorageObject(); result.setType(ContainerUtils.parseDataCategoryFromContainerName(containerName).getFolder()); result.setObjectName(objectName); result.setDigest(objectReferentialEntity.get().getDigest()); result.setFileSize(objectReferentialEntity.get().getSize()); result.setLastModifiedDate(objectReferentialEntity.get().getLastObjectModifiedDate()); return result; } catch (ObjectReferentialException ex) { throw new ContentAddressableStorageServerException( String.format("Could not get metadata of object %s in container %s", objectName, containerName), ex); } }
TapeLibraryContentAddressableStorage implements ContentAddressableStorage { @Override public MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache) throws ContentAddressableStorageException { LOGGER.debug(String.format("Get metadata of object %s in container %s", objectName, containerName)); ParametersChecker.checkParameter(ErrorMessage.CONTAINER_OBJECT_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, objectName); try { Optional<TapeObjectReferentialEntity> objectReferentialEntity = objectReferentialRepository.find(containerName, objectName); if (!objectReferentialEntity.isPresent()) { throw new ContentAddressableStorageNotFoundException( String.format("No such object %s in container %s", objectName, containerName)); } MetadatasStorageObject result = new MetadatasStorageObject(); result.setType(ContainerUtils.parseDataCategoryFromContainerName(containerName).getFolder()); result.setObjectName(objectName); result.setDigest(objectReferentialEntity.get().getDigest()); result.setFileSize(objectReferentialEntity.get().getSize()); result.setLastModifiedDate(objectReferentialEntity.get().getLastObjectModifiedDate()); return result; } catch (ObjectReferentialException ex) { throw new ContentAddressableStorageServerException( String.format("Could not get metadata of object %s in container %s", objectName, containerName), ex); } } }
TapeLibraryContentAddressableStorage implements ContentAddressableStorage { @Override public MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache) throws ContentAddressableStorageException { LOGGER.debug(String.format("Get metadata of object %s in container %s", objectName, containerName)); ParametersChecker.checkParameter(ErrorMessage.CONTAINER_OBJECT_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, objectName); try { Optional<TapeObjectReferentialEntity> objectReferentialEntity = objectReferentialRepository.find(containerName, objectName); if (!objectReferentialEntity.isPresent()) { throw new ContentAddressableStorageNotFoundException( String.format("No such object %s in container %s", objectName, containerName)); } MetadatasStorageObject result = new MetadatasStorageObject(); result.setType(ContainerUtils.parseDataCategoryFromContainerName(containerName).getFolder()); result.setObjectName(objectName); result.setDigest(objectReferentialEntity.get().getDigest()); result.setFileSize(objectReferentialEntity.get().getSize()); result.setLastModifiedDate(objectReferentialEntity.get().getLastObjectModifiedDate()); return result; } catch (ObjectReferentialException ex) { throw new ContentAddressableStorageServerException( String.format("Could not get metadata of object %s in container %s", objectName, containerName), ex); } } TapeLibraryContentAddressableStorage(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository,
        ArchiveReferentialRepository archiveReferentialRepository,
        ReadRequestReferentialRepository readRequestReferentialRepository,
        FileBucketTarCreatorManager fileBucketTarCreatorManager,
        QueueRepository readWriteQueue, TapeCatalogService tapeCatalogService,
        String outputTarStorageFolder,
        ArchiveOutputRetentionPolicy archiveOutputRetentionPolicy); }
TapeLibraryContentAddressableStorage implements ContentAddressableStorage { @Override public MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache) throws ContentAddressableStorageException { LOGGER.debug(String.format("Get metadata of object %s in container %s", objectName, containerName)); ParametersChecker.checkParameter(ErrorMessage.CONTAINER_OBJECT_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, objectName); try { Optional<TapeObjectReferentialEntity> objectReferentialEntity = objectReferentialRepository.find(containerName, objectName); if (!objectReferentialEntity.isPresent()) { throw new ContentAddressableStorageNotFoundException( String.format("No such object %s in container %s", objectName, containerName)); } MetadatasStorageObject result = new MetadatasStorageObject(); result.setType(ContainerUtils.parseDataCategoryFromContainerName(containerName).getFolder()); result.setObjectName(objectName); result.setDigest(objectReferentialEntity.get().getDigest()); result.setFileSize(objectReferentialEntity.get().getSize()); result.setLastModifiedDate(objectReferentialEntity.get().getLastObjectModifiedDate()); return result; } catch (ObjectReferentialException ex) { throw new ContentAddressableStorageServerException( String.format("Could not get metadata of object %s in container %s", objectName, containerName), ex); } } TapeLibraryContentAddressableStorage(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository,
        ArchiveReferentialRepository archiveReferentialRepository,
        ReadRequestReferentialRepository readRequestReferentialRepository,
        FileBucketTarCreatorManager fileBucketTarCreatorManager,
        QueueRepository readWriteQueue, TapeCatalogService tapeCatalogService,
        String outputTarStorageFolder,
        ArchiveOutputRetentionPolicy archiveOutputRetentionPolicy); @Override void createContainer(String containerName); @Override boolean isExistingContainer(String containerName); @Override String putObject(String containerName, String objectName, InputStream stream, DigestType digestType,
        Long size); @Override ObjectContent getObject(String containerName, String objectName); @Override String createReadOrderRequest(String containerName, List<String> objectsIds); @Override void removeReadOrderRequest(String readRequestID); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String getObjectDigest(String containerName, String objectName, DigestType algo, boolean noCache); @Override ContainerInformation getContainerInformation(String containerName); @Override MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache); @Override void listContainer(String containerName, ObjectListingListener objectListingListener); @Override void close(); }
TapeLibraryContentAddressableStorage implements ContentAddressableStorage { @Override public MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache) throws ContentAddressableStorageException { LOGGER.debug(String.format("Get metadata of object %s in container %s", objectName, containerName)); ParametersChecker.checkParameter(ErrorMessage.CONTAINER_OBJECT_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, objectName); try { Optional<TapeObjectReferentialEntity> objectReferentialEntity = objectReferentialRepository.find(containerName, objectName); if (!objectReferentialEntity.isPresent()) { throw new ContentAddressableStorageNotFoundException( String.format("No such object %s in container %s", objectName, containerName)); } MetadatasStorageObject result = new MetadatasStorageObject(); result.setType(ContainerUtils.parseDataCategoryFromContainerName(containerName).getFolder()); result.setObjectName(objectName); result.setDigest(objectReferentialEntity.get().getDigest()); result.setFileSize(objectReferentialEntity.get().getSize()); result.setLastModifiedDate(objectReferentialEntity.get().getLastObjectModifiedDate()); return result; } catch (ObjectReferentialException ex) { throw new ContentAddressableStorageServerException( String.format("Could not get metadata of object %s in container %s", objectName, containerName), ex); } } TapeLibraryContentAddressableStorage(
        BasicFileStorage basicFileStorage,
        ObjectReferentialRepository objectReferentialRepository,
        ArchiveReferentialRepository archiveReferentialRepository,
        ReadRequestReferentialRepository readRequestReferentialRepository,
        FileBucketTarCreatorManager fileBucketTarCreatorManager,
        QueueRepository readWriteQueue, TapeCatalogService tapeCatalogService,
        String outputTarStorageFolder,
        ArchiveOutputRetentionPolicy archiveOutputRetentionPolicy); @Override void createContainer(String containerName); @Override boolean isExistingContainer(String containerName); @Override String putObject(String containerName, String objectName, InputStream stream, DigestType digestType,
        Long size); @Override ObjectContent getObject(String containerName, String objectName); @Override String createReadOrderRequest(String containerName, List<String> objectsIds); @Override void removeReadOrderRequest(String readRequestID); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String getObjectDigest(String containerName, String objectName, DigestType algo, boolean noCache); @Override ContainerInformation getContainerInformation(String containerName); @Override MetadatasObject getObjectMetadata(String containerName, String objectName, boolean noCache); @Override void listContainer(String containerName, ObjectListingListener objectListingListener); @Override void close();  }