@Test(expected = ContentAddressableStorageNotFoundException.class) public void givenContainerNotFoundWhenPurgeContainerThenRaiseAnException() throws Exception { storage.purgeContainer(CONTAINER_NAME); }
@Override public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException { if (!isExistingContainer(containerName)) { LOGGER.info(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } try { Path containerPath = getContainerPath(containerName); try (Stream<Path> streams = Files.walk(containerPath, FileVisitOption.FOLLOW_LINKS)) { streams.filter(path -> !containerPath.equals(path)) .sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException { if (!isExistingContainer(containerName)) { LOGGER.info(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } try { Path containerPath = getContainerPath(containerName); try (Stream<Path> streams = Files.walk(containerPath, FileVisitOption.FOLLOW_LINKS)) { streams.filter(path -> !containerPath.equals(path)) .sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException { if (!isExistingContainer(containerName)) { LOGGER.info(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } try { Path containerPath = getContainerPath(containerName); try (Stream<Path> streams = Files.walk(containerPath, FileVisitOption.FOLLOW_LINKS)) { streams.filter(path -> !containerPath.equals(path)) .sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException { if (!isExistingContainer(containerName)) { LOGGER.info(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } try { Path containerPath = getContainerPath(containerName); try (Stream<Path> streams = Files.walk(containerPath, FileVisitOption.FOLLOW_LINKS)) { streams.filter(path -> !containerPath.equals(path)) .sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); void checkWorkspaceFile(String... paths); @Override void createContainer(String containerName); @Override void purgeContainer(String containerName); @Override void purgeOldFilesInContainer(String containerName, TimeToLive timeToLive); @Override void deleteContainer(String containerName, boolean recursive); @Override boolean isExistingContainer(String containerName); @Override void createFolder(String containerName, String folderName); @Override void deleteFolder(String containerName, String folderName); @Override boolean isExistingFolder(String containerName, String folderName); @Override List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName); @Override void uncompressObject(String containerName, String folderName, String archiveMimeType,
        InputStream inputStreamObject); @Override void putObject(String containerName, String objectName, InputStream stream); @Override void putAtomicObject(String containerName, String objectName, InputStream stream, long size); @Override Response getObject(String containerName, String objectName, Long chunkOffset,
        Long maxChunkSize); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String computeObjectDigest(String containerName, String objectName, DigestType algo); @Override ContainerInformation getContainerInformation(String containerName); @Override JsonNode getObjectInformation(String containerName, String objectName); @Override long countObjects(String containerName); void compress(String containerName, List<String> folderNames, String zipName,
        String outputContainer); }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void purgeContainer(String containerName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageServerException { if (!isExistingContainer(containerName)) { LOGGER.info(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } try { Path containerPath = getContainerPath(containerName); try (Stream<Path> streams = Files.walk(containerPath, FileVisitOption.FOLLOW_LINKS)) { streams.filter(path -> !containerPath.equals(path)) .sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); } } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); void checkWorkspaceFile(String... paths); @Override void createContainer(String containerName); @Override void purgeContainer(String containerName); @Override void purgeOldFilesInContainer(String containerName, TimeToLive timeToLive); @Override void deleteContainer(String containerName, boolean recursive); @Override boolean isExistingContainer(String containerName); @Override void createFolder(String containerName, String folderName); @Override void deleteFolder(String containerName, String folderName); @Override boolean isExistingFolder(String containerName, String folderName); @Override List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName); @Override void uncompressObject(String containerName, String folderName, String archiveMimeType,
        InputStream inputStreamObject); @Override void putObject(String containerName, String objectName, InputStream stream); @Override void putAtomicObject(String containerName, String objectName, InputStream stream, long size); @Override Response getObject(String containerName, String objectName, Long chunkOffset,
        Long maxChunkSize); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String computeObjectDigest(String containerName, String objectName, DigestType algo); @Override ContainerInformation getContainerInformation(String containerName); @Override JsonNode getObjectInformation(String containerName, String objectName); @Override long countObjects(String containerName); void compress(String containerName, List<String> folderNames, String zipName,
        String outputContainer);  }