@Test void listOnNonExisting() { try (Stream<AbsoluteLocation<ResolvedResource>> lsStorageService = storageService.list(root)) { assertThat(lsStorageService).isEmpty(); } }
@SneakyThrows @Override public Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path) { log.debug("List file request: {}", path.location()); Path filePath = resolve(path.location().getRawPath(), false); if (!filePath.toFile().exists()) { return Stream.empty(); } boolean shouldReturnDir = shouldReturnDir(path); return Files.walk(filePath) .filter(it -> (shouldReturnDir && allowableDir(it)) || !it.toFile().isDirectory()) .map(it -> new AbsoluteLocation<>( new BaseResolvedResource( new BasePrivateResource( new Uri(URI.create(UriEncoderDecoder.decodeAndDropAuthority(it.toUri()))) ), Instant.ofEpochMilli(it.toFile().lastModified())) ) ); }
FileSystemStorageService implements StorageService { @SneakyThrows @Override public Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path) { log.debug("List file request: {}", path.location()); Path filePath = resolve(path.location().getRawPath(), false); if (!filePath.toFile().exists()) { return Stream.empty(); } boolean shouldReturnDir = shouldReturnDir(path); return Files.walk(filePath) .filter(it -> (shouldReturnDir && allowableDir(it)) || !it.toFile().isDirectory()) .map(it -> new AbsoluteLocation<>( new BaseResolvedResource( new BasePrivateResource( new Uri(URI.create(UriEncoderDecoder.decodeAndDropAuthority(it.toUri()))) ), Instant.ofEpochMilli(it.toFile().lastModified())) ) ); } }
FileSystemStorageService implements StorageService { @SneakyThrows @Override public Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path) { log.debug("List file request: {}", path.location()); Path filePath = resolve(path.location().getRawPath(), false); if (!filePath.toFile().exists()) { return Stream.empty(); } boolean shouldReturnDir = shouldReturnDir(path); return Files.walk(filePath) .filter(it -> (shouldReturnDir && allowableDir(it)) || !it.toFile().isDirectory()) .map(it -> new AbsoluteLocation<>( new BaseResolvedResource( new BasePrivateResource( new Uri(URI.create(UriEncoderDecoder.decodeAndDropAuthority(it.toUri()))) ), Instant.ofEpochMilli(it.toFile().lastModified())) ) ); } FileSystemStorageService(Path dir); }
FileSystemStorageService implements StorageService { @SneakyThrows @Override public Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path) { log.debug("List file request: {}", path.location()); Path filePath = resolve(path.location().getRawPath(), false); if (!filePath.toFile().exists()) { return Stream.empty(); } boolean shouldReturnDir = shouldReturnDir(path); return Files.walk(filePath) .filter(it -> (shouldReturnDir && allowableDir(it)) || !it.toFile().isDirectory()) .map(it -> new AbsoluteLocation<>( new BaseResolvedResource( new BasePrivateResource( new Uri(URI.create(UriEncoderDecoder.decodeAndDropAuthority(it.toUri()))) ), Instant.ofEpochMilli(it.toFile().lastModified())) ) ); } FileSystemStorageService(Path dir); @SneakyThrows @Override Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path); @SneakyThrows @Override InputStream read(AbsoluteLocation path); @SneakyThrows @Override OutputStream write(WithCallback<AbsoluteLocation, ? extends ResourceWriteCallback> locationWithCallback); @SneakyThrows @Override void remove(AbsoluteLocation location); @Override boolean objectExists(AbsoluteLocation location); }
FileSystemStorageService implements StorageService { @SneakyThrows @Override public Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path) { log.debug("List file request: {}", path.location()); Path filePath = resolve(path.location().getRawPath(), false); if (!filePath.toFile().exists()) { return Stream.empty(); } boolean shouldReturnDir = shouldReturnDir(path); return Files.walk(filePath) .filter(it -> (shouldReturnDir && allowableDir(it)) || !it.toFile().isDirectory()) .map(it -> new AbsoluteLocation<>( new BaseResolvedResource( new BasePrivateResource( new Uri(URI.create(UriEncoderDecoder.decodeAndDropAuthority(it.toUri()))) ), Instant.ofEpochMilli(it.toFile().lastModified())) ) ); } FileSystemStorageService(Path dir); @SneakyThrows @Override Stream<AbsoluteLocation<ResolvedResource>> list(AbsoluteLocation path); @SneakyThrows @Override InputStream read(AbsoluteLocation path); @SneakyThrows @Override OutputStream write(WithCallback<AbsoluteLocation, ? extends ResourceWriteCallback> locationWithCallback); @SneakyThrows @Override void remove(AbsoluteLocation location); @Override boolean objectExists(AbsoluteLocation location);  }