@Test public void testActionDirectoryExistsTrue() throws Exception { final Path root = new Path("t", EnumSet.of(Path.Type.directory)); final Transfer t = new DownloadTransfer(new Host(new TestProtocol()), root, new NullLocal("p", "t") { @Override public boolean exists() { return true; } @Override public AttributedList<Local> list() { return new AttributedList<Local>(Collections.singletonList(new NullLocal("p", "a"))); } }); final AtomicBoolean prompt = new AtomicBoolean(); final NullSession session = new NullSession(new Host(new TestProtocol())); assertEquals(TransferAction.callback, t.action(session, null, false, false, new DisabledTransferPrompt() { @Override public TransferAction prompt(final TransferItem file) { prompt.set(true); return TransferAction.callback; } }, new DisabledListProgressListener())); assertTrue(prompt.get()); }
@Override public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Find transfer action for Resume=%s,Reload=%s", resumeRequested, reloadRequested)); } if(resumeRequested) { return TransferAction.resume; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem download : roots) { final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) { continue; } } if(local.isFile()) { if(local.attributes().getSize() == 0) { continue; } } return prompt.prompt(download); } } return TransferAction.overwrite; } return action; }
DownloadTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Find transfer action for Resume=%s,Reload=%s", resumeRequested, reloadRequested)); } if(resumeRequested) { return TransferAction.resume; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem download : roots) { final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) { continue; } } if(local.isFile()) { if(local.attributes().getSize() == 0) { continue; } } return prompt.prompt(download); } } return TransferAction.overwrite; } return action; } }
DownloadTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Find transfer action for Resume=%s,Reload=%s", resumeRequested, reloadRequested)); } if(resumeRequested) { return TransferAction.resume; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem download : roots) { final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) { continue; } } if(local.isFile()) { if(local.attributes().getSize() == 0) { continue; } } return prompt.prompt(download); } } return TransferAction.overwrite; } return action; } DownloadTransfer(final Host host, final Path root, final Local local);  DownloadTransfer(final Host host, final Path root, final Local local, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f, final Comparator<Path> comparator); }
DownloadTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Find transfer action for Resume=%s,Reload=%s", resumeRequested, reloadRequested)); } if(resumeRequested) { return TransferAction.resume; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem download : roots) { final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) { continue; } } if(local.isFile()) { if(local.attributes().getSize() == 0) { continue; } } return prompt.prompt(download); } } return TransferAction.overwrite; } return action; } DownloadTransfer(final Host host, final Path root, final Local local);  DownloadTransfer(final Host host, final Path root, final Local local, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f, final Comparator<Path> comparator); @Override DownloadTransfer withCache(final Cache<Path> cache); Transfer withOptions(final DownloadFilterOptions options); @Override Type getType(); @Override List<TransferItem> list(final Session<?> session, final Path directory,
                                   final Local local, final ListProgressListener listener); @Override AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override void stop(); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void post(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @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 listener, final StreamListener streamListener); @Override void normalize(); }
DownloadTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested, final TransferPrompt prompt, final ListProgressListener listener) throws BackgroundException { if(log.isDebugEnabled()) { log.debug(String.format("Find transfer action for Resume=%s,Reload=%s", resumeRequested, reloadRequested)); } if(resumeRequested) { return TransferAction.resume; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.download.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem download : roots) { final Local local = download.local; if(local.exists()) { if(local.isDirectory()) { if(local.list().isEmpty()) { continue; } } if(local.isFile()) { if(local.attributes().getSize() == 0) { continue; } } return prompt.prompt(download); } } return TransferAction.overwrite; } return action; } DownloadTransfer(final Host host, final Path root, final Local local);  DownloadTransfer(final Host host, final Path root, final Local local, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f);  DownloadTransfer(final Host host, final List<TransferItem> roots, final Filter<Path> f, final Comparator<Path> comparator); @Override DownloadTransfer withCache(final Cache<Path> cache); Transfer withOptions(final DownloadFilterOptions options); @Override Type getType(); @Override List<TransferItem> list(final Session<?> session, final Path directory,
                                   final Local local, final ListProgressListener listener); @Override AbstractDownloadFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override TransferAction action(final Session<?> source, final Session<?> destination, final boolean resumeRequested, final boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override void stop(); @Override void pre(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @Override void post(final Session<?> source, final Session<?> destination, final Map<TransferItem, TransferStatus> files, final ConnectionCallback callback); @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 listener, final StreamListener streamListener); @Override void normalize();  }