@Test public void testParse8006() throws Exception { final List<String> lines = Arrays.asList( "212-Status of /cgi-bin:", " drwxr-xr-x 3 1564466 15000 4 Jan 19 19:56 .", " drwxr-x--- 13 1564466 15000 44 Jun 13 18:36 ..", " drwxr-xr-x 2 1564466 15000 2 May 25 2009 tmp", " End of status", "212 -rw-r--r-- 1 1564466 15000 9859 Jan 19 19:56 adoptees.php"); final FTPFileEntryParser parser = new UnixFTPEntryParser(); final List<String> list = new FTPStatListService(null, parser).parse( 212, lines.toArray(new String[lines.size()])); assertEquals(6, list.size()); final Path parent = new Path("/cgi-bin", EnumSet.of(Path.Type.directory)); final AttributedList<Path> parsed = new FTPListResponseReader(parser, true).read( parent, list, new DisabledListProgressListener() ); assertEquals(2, parsed.size()); assertTrue(parsed.contains(new Path(parent, "tmp", EnumSet.of(Path.Type.directory)))); assertTrue(parsed.contains(new Path(parent, "adoptees.php", EnumSet.of(Path.Type.file)))); }
protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for(final String line : reply) { if(line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped); } catch(IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; }
FTPStatListService implements ListService { protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for(final String line : reply) { if(line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped); } catch(IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; } }
FTPStatListService implements ListService { protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for(final String line : reply) { if(line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped); } catch(IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; } FTPStatListService(final FTPSession session, final FTPFileEntryParser parser); }
FTPStatListService implements ListService { protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for(final String line : reply) { if(line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped); } catch(IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; } FTPStatListService(final FTPSession session, final FTPFileEntryParser parser); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener); }
FTPStatListService implements ListService { protected List<String> parse(final int response, final String[] reply) { final List<String> result = new ArrayList<String>(reply.length); for(final String line : reply) { if(line.startsWith(String.valueOf(response))) { try { String stripped = line; stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(String.format("%d-", response)))); stripped = StringUtils.strip(StringUtils.removeStart(stripped, String.valueOf(response))); result.add(stripped); } catch(IndexOutOfBoundsException e) { log.error(String.format("Failed parsing line %s", line), e); } } else { result.add(StringUtils.strip(line)); } } return result; } FTPStatListService(final FTPSession session, final FTPFileEntryParser parser); @Override AttributedList<Path> list(final Path directory, final ListProgressListener listener);  }