@Test public void testParseEgnyte() throws Exception { final List<String> lines = Arrays.asList( "200-drwx------ 0 - - 0 Jun 17 07:59 core", "200 -rw------- 0 David-Kocher - 529 Jun 17 07:59 App.config"); final FTPFileEntryParser parser = new LaxUnixFTPEntryParser(); final List<String> list = new FTPStatListService(null, parser).parse( 200, lines.toArray(new String[lines.size()])); assertEquals(2, list.size()); assertTrue(list.contains("drwx------ 0 - - 0 Jun 17 07:59 core")); assertTrue(list.contains("-rw------- 0 David-Kocher - 529 Jun 17 07:59 App.config")); final Path parent = new Path("/cyberduck", EnumSet.of(Path.Type.directory)); final AttributedList<Path> parsed = new FTPListResponseReader(parser, true).read( parent, list, new DisabledListProgressListener()); assertEquals(2, parsed.size()); }
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);  }