@Test public void testList() throws Exception { final ListService service = new FTPListService(session, null, TimeZone.getDefault()); final Path directory = new FTPWorkdirService(session).find(); final Path file = new Path(directory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new FTPTouchFeature(session).touch(file, new TransferStatus()); final Permission permission = new Permission(Permission.Action.read_write, Permission.Action.read_write, Permission.Action.read_write); final AttributedList<Path> list = service.list(directory, new DisabledListProgressListener() { @Override public void chunk(final Path parent, AttributedList<Path> list) { assertFalse(list.isEmpty()); } }); assertTrue(list.contains(file)); new FTPDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { if(implementations.containsKey(Command.mlsd)) { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { try { return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); } catch(InteroperabilityException | FTPInvalidListException e) { this.remove(Command.mlsd); } } else { this.remove(Command.mlsd); } } if(implementations.containsKey(Command.stat)) { try { return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); } catch(FTPInvalidListException | InteroperabilityException | AccessDeniedException | NotfoundException e) { this.remove(Command.stat); } } if(implementations.containsKey(Command.lista)) { try { return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); } catch(InteroperabilityException e) { this.remove(Command.lista); } catch(FTPInvalidListException e) { } } try { return this.post(directory, implementations.get(Command.list).list(directory, listener), listener); } catch(FTPInvalidListException f) { return this.post(directory, f.getParsed(), listener); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
FTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { if(implementations.containsKey(Command.mlsd)) { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { try { return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); } catch(InteroperabilityException | FTPInvalidListException e) { this.remove(Command.mlsd); } } else { this.remove(Command.mlsd); } } if(implementations.containsKey(Command.stat)) { try { return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); } catch(FTPInvalidListException | InteroperabilityException | AccessDeniedException | NotfoundException e) { this.remove(Command.stat); } } if(implementations.containsKey(Command.lista)) { try { return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); } catch(InteroperabilityException e) { this.remove(Command.lista); } catch(FTPInvalidListException e) { } } try { return this.post(directory, implementations.get(Command.list).list(directory, listener), listener); } catch(FTPInvalidListException f) { return this.post(directory, f.getParsed(), listener); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } }
FTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { if(implementations.containsKey(Command.mlsd)) { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { try { return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); } catch(InteroperabilityException | FTPInvalidListException e) { this.remove(Command.mlsd); } } else { this.remove(Command.mlsd); } } if(implementations.containsKey(Command.stat)) { try { return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); } catch(FTPInvalidListException | InteroperabilityException | AccessDeniedException | NotfoundException e) { this.remove(Command.stat); } } if(implementations.containsKey(Command.lista)) { try { return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); } catch(InteroperabilityException e) { this.remove(Command.lista); } catch(FTPInvalidListException e) { } } try { return this.post(directory, implementations.get(Command.list).list(directory, listener), listener); } catch(FTPInvalidListException f) { return this.post(directory, f.getParsed(), listener); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } FTPListService(final FTPSession session, final String system, final TimeZone zone); }
FTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { if(implementations.containsKey(Command.mlsd)) { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { try { return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); } catch(InteroperabilityException | FTPInvalidListException e) { this.remove(Command.mlsd); } } else { this.remove(Command.mlsd); } } if(implementations.containsKey(Command.stat)) { try { return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); } catch(FTPInvalidListException | InteroperabilityException | AccessDeniedException | NotfoundException e) { this.remove(Command.stat); } } if(implementations.containsKey(Command.lista)) { try { return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); } catch(InteroperabilityException e) { this.remove(Command.lista); } catch(FTPInvalidListException e) { } } try { return this.post(directory, implementations.get(Command.list).list(directory, listener), listener); } catch(FTPInvalidListException f) { return this.post(directory, f.getParsed(), listener); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } FTPListService(final FTPSession session, final String system, final TimeZone zone); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
FTPListService implements ListService { @Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { if(implementations.containsKey(Command.mlsd)) { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { try { return this.post(directory, implementations.get(Command.mlsd).list(directory, listener), listener); } catch(InteroperabilityException | FTPInvalidListException e) { this.remove(Command.mlsd); } } else { this.remove(Command.mlsd); } } if(implementations.containsKey(Command.stat)) { try { return this.post(directory, implementations.get(Command.stat).list(directory, listener), listener); } catch(FTPInvalidListException | InteroperabilityException | AccessDeniedException | NotfoundException e) { this.remove(Command.stat); } } if(implementations.containsKey(Command.lista)) { try { return this.post(directory, implementations.get(Command.lista).list(directory, listener), listener); } catch(InteroperabilityException e) { this.remove(Command.lista); } catch(FTPInvalidListException e) { } } try { return this.post(directory, implementations.get(Command.list).list(directory, listener), listener); } catch(FTPInvalidListException f) { return this.post(directory, f.getParsed(), listener); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } } FTPListService(final FTPSession session, final String system, final TimeZone zone); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }