@Test public void testChildrenRemoteAndLocalExist() throws Exception { final NullLocal directory = new NullLocal(System.getProperty("java.io.tmpdir"), "t") { @Override public AttributedList<Local> list() { final AttributedList<Local> list = new AttributedList<Local>(); list.add(new NullLocal(this, "a")); return list; } }; final Path root = new Path("t", EnumSet.of(Path.Type.directory)); final Path remote = new Path(root, "a", EnumSet.of(Path.Type.file)); final NullSession session = new NullSession(new Host(new TestProtocol())) { @Override public AttributedList<Path> list(final Path file, final ListProgressListener listener) { final AttributedList<Path> list = new AttributedList<Path>(); if(file.equals(root.getParent())) { list.add(root); } else { list.add(remote); } return list; } }; new DefaultLocalDirectoryFeature().mkdir(directory); Transfer t = new SyncTransfer(new Host(new TestProtocol()), new TransferItem(root, directory)); final List<TransferItem> list = t.list(session, root, directory, new DisabledListProgressListener()); assertEquals(1, list.size()); }
@Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); }
SyncTransfer extends Transfer { @Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); } }
SyncTransfer extends Transfer { @Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); } SyncTransfer(final Host host, final TransferItem item);  SyncTransfer(final Host host, final TransferItem item, final TransferAction action); }
SyncTransfer extends Transfer { @Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); } SyncTransfer(final Host host, final TransferItem item);  SyncTransfer(final Host host, final TransferItem item, final TransferAction action); @Override Transfer withCache(final Cache<Path> cache); @Override T serialize(final Serializer dict); @Override Type getType(); @Override void setBandwidth(float bytesPerSecond); @Override String getName(); @Override Long getTransferred(); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @Override TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override void transfer(final Session<?> source, final Session<?> destination, final Path file, final Local local,
                         final TransferOptions options, final TransferStatus status, final ConnectionCallback connectionCallback,
                         final ProgressListener progressListener, final StreamListener streamListener); Comparison compare(final TransferItem item); @Override void start(); @Override void stop(); @Override void reset(); @Override void normalize(); @Override String toString(); }
SyncTransfer extends Transfer { @Override public List<TransferItem> list(final Session<?> session, final Path directory, final Local local, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Children for %s", directory)); } final Set<TransferItem> children = new HashSet<TransferItem>(); final Find finder = session.getFeature(Find.class, new DefaultFindFeature(session)).withCache(cache); if(finder.find(directory)) { children.addAll(download.list(session, directory, local, listener)); } if(local.exists()) { children.addAll(upload.list(session, directory, local, listener)); } return new ArrayList<TransferItem>(children); } SyncTransfer(final Host host, final TransferItem item);  SyncTransfer(final Host host, final TransferItem item, final TransferAction action); @Override Transfer withCache(final Cache<Path> cache); @Override T serialize(final Serializer dict); @Override Type getType(); @Override void setBandwidth(float bytesPerSecond); @Override String getName(); @Override Long getTransferred(); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @Override TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override void transfer(final Session<?> source, final Session<?> destination, final Path file, final Local local,
                         final TransferOptions options, final TransferStatus status, final ConnectionCallback connectionCallback,
                         final ProgressListener progressListener, final StreamListener streamListener); Comparison compare(final TransferItem item); @Override void start(); @Override void stop(); @Override void reset(); @Override void normalize(); @Override String toString();  }