@Test void getFileEntriesWithoutContent() throws Exception { List<FileEntry> fileEntries = new ArrayList<>(); FileEntry existingFile = addFile(TEST_FILE_LOCATION); fileEntries.add(existingFile); FileEntry existingFile2 = addFile(SECOND_FILE_TEST_LOCATION); fileEntries.add(existingFile2); FileEntry nonExistingFile = createFileEntry(); fileEntries.add(nonExistingFile); List<FileEntry> withoutContent = fileStorage.getFileEntriesWithoutContent(fileEntries); assertEquals(1, withoutContent.size()); assertEquals(nonExistingFile.getId(), withoutContent.get(0) .getId()); }
@Override public List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries) { Set<String> existingFiles = blobStore.list(container) .stream() .map(StorageMetadata::getName) .collect(Collectors.toSet()); return fileEntries.stream() .filter(fileEntry -> { String id = fileEntry.getId(); return !existingFiles.contains(id); }) .collect(Collectors.toList()); }
ObjectStoreFileStorage implements FileStorage { @Override public List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries) { Set<String> existingFiles = blobStore.list(container) .stream() .map(StorageMetadata::getName) .collect(Collectors.toSet()); return fileEntries.stream() .filter(fileEntry -> { String id = fileEntry.getId(); return !existingFiles.contains(id); }) .collect(Collectors.toList()); } }
ObjectStoreFileStorage implements FileStorage { @Override public List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries) { Set<String> existingFiles = blobStore.list(container) .stream() .map(StorageMetadata::getName) .collect(Collectors.toSet()); return fileEntries.stream() .filter(fileEntry -> { String id = fileEntry.getId(); return !existingFiles.contains(id); }) .collect(Collectors.toList()); } ObjectStoreFileStorage(BlobStore blobStore, String container); }
ObjectStoreFileStorage implements FileStorage { @Override public List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries) { Set<String> existingFiles = blobStore.list(container) .stream() .map(StorageMetadata::getName) .collect(Collectors.toSet()); return fileEntries.stream() .filter(fileEntry -> { String id = fileEntry.getId(); return !existingFiles.contains(id); }) .collect(Collectors.toList()); } ObjectStoreFileStorage(BlobStore blobStore, String container); @Override void addFile(FileEntry fileEntry, File file); @Override List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries); @Override void deleteFile(String id, String space); @Override void deleteFilesBySpace(String space); @Override void deleteFilesBySpaceAndNamespace(String space, String namespace); @Override int deleteFilesModifiedBefore(Date modificationTime); @Override T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor); }
ObjectStoreFileStorage implements FileStorage { @Override public List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries) { Set<String> existingFiles = blobStore.list(container) .stream() .map(StorageMetadata::getName) .collect(Collectors.toSet()); return fileEntries.stream() .filter(fileEntry -> { String id = fileEntry.getId(); return !existingFiles.contains(id); }) .collect(Collectors.toList()); } ObjectStoreFileStorage(BlobStore blobStore, String container); @Override void addFile(FileEntry fileEntry, File file); @Override List<FileEntry> getFileEntriesWithoutContent(List<FileEntry> fileEntries); @Override void deleteFile(String id, String space); @Override void deleteFilesBySpace(String space); @Override void deleteFilesBySpaceAndNamespace(String space, String namespace); @Override int deleteFilesModifiedBefore(Date modificationTime); @Override T processFileContent(String space, String id, FileContentProcessor<T> fileContentProcessor);  }