@Test(expected = NotfoundException.class) public void testListFile() throws Exception { final Path home = new SFTPHomeDirectoryService(session).find(); final Path f = new Path(home, "test", EnumSet.of(Path.Type.directory)); final SFTPListService service = new SFTPListService(session); service.list(f, new DisabledListProgressListener()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final RemoteDirectory handle = session.sftp().openDir(directory.getAbsolute()); for(RemoteResourceInfo f : handle.scan(new RemoteResourceFilter() { @Override public boolean accept(RemoteResourceInfo remoteResourceInfo) { return true; } })) { final PathAttributes attr = attributes.toAttributes(f.getAttributes()); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(f.getAttributes().getType().equals(FileMode.Type.DIRECTORY)) { type.add(Path.Type.directory); } if(f.getAttributes().getType().equals(FileMode.Type.REGULAR)) { type.add(Path.Type.file); } if(f.getAttributes().getType().equals(FileMode.Type.SYMLINK)) { type.add(Path.Type.symboliclink); } final Path file = new Path(directory, f.getName(), type, attr); if(this.post(file)) { children.add(file); listener.chunk(directory, children); } } handle.close(); return children; } catch(IOException e) { throw new SFTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
SFTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final RemoteDirectory handle = session.sftp().openDir(directory.getAbsolute()); for(RemoteResourceInfo f : handle.scan(new RemoteResourceFilter() { @Override public boolean accept(RemoteResourceInfo remoteResourceInfo) { return true; } })) { final PathAttributes attr = attributes.toAttributes(f.getAttributes()); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(f.getAttributes().getType().equals(FileMode.Type.DIRECTORY)) { type.add(Path.Type.directory); } if(f.getAttributes().getType().equals(FileMode.Type.REGULAR)) { type.add(Path.Type.file); } if(f.getAttributes().getType().equals(FileMode.Type.SYMLINK)) { type.add(Path.Type.symboliclink); } final Path file = new Path(directory, f.getName(), type, attr); if(this.post(file)) { children.add(file); listener.chunk(directory, children); } } handle.close(); return children; } catch(IOException e) { throw new SFTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } }
SFTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final RemoteDirectory handle = session.sftp().openDir(directory.getAbsolute()); for(RemoteResourceInfo f : handle.scan(new RemoteResourceFilter() { @Override public boolean accept(RemoteResourceInfo remoteResourceInfo) { return true; } })) { final PathAttributes attr = attributes.toAttributes(f.getAttributes()); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(f.getAttributes().getType().equals(FileMode.Type.DIRECTORY)) { type.add(Path.Type.directory); } if(f.getAttributes().getType().equals(FileMode.Type.REGULAR)) { type.add(Path.Type.file); } if(f.getAttributes().getType().equals(FileMode.Type.SYMLINK)) { type.add(Path.Type.symboliclink); } final Path file = new Path(directory, f.getName(), type, attr); if(this.post(file)) { children.add(file); listener.chunk(directory, children); } } handle.close(); return children; } catch(IOException e) { throw new SFTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SFTPListService(final SFTPSession session); }
SFTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final RemoteDirectory handle = session.sftp().openDir(directory.getAbsolute()); for(RemoteResourceInfo f : handle.scan(new RemoteResourceFilter() { @Override public boolean accept(RemoteResourceInfo remoteResourceInfo) { return true; } })) { final PathAttributes attr = attributes.toAttributes(f.getAttributes()); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(f.getAttributes().getType().equals(FileMode.Type.DIRECTORY)) { type.add(Path.Type.directory); } if(f.getAttributes().getType().equals(FileMode.Type.REGULAR)) { type.add(Path.Type.file); } if(f.getAttributes().getType().equals(FileMode.Type.SYMLINK)) { type.add(Path.Type.symboliclink); } final Path file = new Path(directory, f.getName(), type, attr); if(this.post(file)) { children.add(file); listener.chunk(directory, children); } } handle.close(); return children; } catch(IOException e) { throw new SFTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SFTPListService(final SFTPSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); @Override ListService withCache(final Cache<Path> cache); }
SFTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final RemoteDirectory handle = session.sftp().openDir(directory.getAbsolute()); for(RemoteResourceInfo f : handle.scan(new RemoteResourceFilter() { @Override public boolean accept(RemoteResourceInfo remoteResourceInfo) { return true; } })) { final PathAttributes attr = attributes.toAttributes(f.getAttributes()); final EnumSet<Path.Type> type = EnumSet.noneOf(Path.Type.class); if(f.getAttributes().getType().equals(FileMode.Type.DIRECTORY)) { type.add(Path.Type.directory); } if(f.getAttributes().getType().equals(FileMode.Type.REGULAR)) { type.add(Path.Type.file); } if(f.getAttributes().getType().equals(FileMode.Type.SYMLINK)) { type.add(Path.Type.symboliclink); } final Path file = new Path(directory, f.getName(), type, attr); if(this.post(file)) { children.add(file); listener.chunk(directory, children); } } handle.close(); return children; } catch(IOException e) { throw new SFTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } SFTPListService(final SFTPSession session); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); @Override ListService withCache(final Cache<Path> cache);  }