@Test public void testActionPromptCancel() throws Exception { final Path test = new Path("t", EnumSet.of(Path.Type.file)); final Host target = new Host(new TestProtocol(), "t"); CopyTransfer t = new CopyTransfer(target, target, Collections.singletonMap(test, new Path("d", EnumSet.of(Path.Type.file))), new BandwidthThrottle(BandwidthThrottle.UNLIMITED)); assertEquals(TransferAction.cancel, t.action(new NullTransferSession(target), new NullTransferSession(target), false, true, new DisabledTransferPrompt(), new DisabledListProgressListener())); }
@Override public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, 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.comparison; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem upload : roots) { final Upload write = destination.getFeature(Upload.class); final Path copy = mapping.get(upload.remote); final Write.Append append = write.append(copy, upload.remote.attributes().getSize(), PathCache.empty()); if(append.override || append.append) { if(upload.remote.isDirectory()) { if(this.list(destination, copy, null, listener).isEmpty()) { continue; } } return prompt.prompt(upload); } } return TransferAction.overwrite; } return action; }
CopyTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, 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.comparison; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem upload : roots) { final Upload write = destination.getFeature(Upload.class); final Path copy = mapping.get(upload.remote); final Write.Append append = write.append(copy, upload.remote.attributes().getSize(), PathCache.empty()); if(append.override || append.append) { if(upload.remote.isDirectory()) { if(this.list(destination, copy, null, listener).isEmpty()) { continue; } } return prompt.prompt(upload); } } return TransferAction.overwrite; } return action; } }
CopyTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, 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.comparison; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem upload : roots) { final Upload write = destination.getFeature(Upload.class); final Path copy = mapping.get(upload.remote); final Write.Append append = write.append(copy, upload.remote.attributes().getSize(), PathCache.empty()); if(append.override || append.append) { if(upload.remote.isDirectory()) { if(this.list(destination, copy, null, listener).isEmpty()) { continue; } } return prompt.prompt(upload); } } return TransferAction.overwrite; } return action; } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); }
CopyTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, 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.comparison; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem upload : roots) { final Upload write = destination.getFeature(Upload.class); final Path copy = mapping.get(upload.remote); final Write.Append append = write.append(copy, upload.remote.attributes().getSize(), PathCache.empty()); if(append.override || append.append) { if(upload.remote.isDirectory()) { if(this.list(destination, copy, null, listener).isEmpty()) { continue; } } return prompt.prompt(upload); } } return TransferAction.overwrite; } return action; } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); @Override Transfer withCache(final Cache<Path> cache); @Override Type getType(); @Override Host getDestination(); @Override String getLocal(); @Override T serialize(final Serializer dict); @Override TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @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<?> session, final Session<?> destination, final Path source, final Local n,
                         final TransferOptions options, final TransferStatus status,
                         final ConnectionCallback connectionCallback,
                         final ProgressListener listener, final StreamListener streamListener); @Override void normalize(); }
CopyTransfer extends Transfer { @Override public TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, 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.comparison; } final TransferAction action; if(reloadRequested) { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.reload.action")); } else { action = TransferAction.forName( PreferencesFactory.get().getProperty("queue.copy.action")); } if(action.equals(TransferAction.callback)) { for(TransferItem upload : roots) { final Upload write = destination.getFeature(Upload.class); final Path copy = mapping.get(upload.remote); final Write.Append append = write.append(copy, upload.remote.attributes().getSize(), PathCache.empty()); if(append.override || append.append) { if(upload.remote.isDirectory()) { if(this.list(destination, copy, null, listener).isEmpty()) { continue; } } return prompt.prompt(upload); } } return TransferAction.overwrite; } return action; } CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected);  CopyTransfer(final Host source, final Host destination,
                        final Map<Path, Path> selected, final BandwidthThrottle bandwidth); @Override Transfer withCache(final Cache<Path> cache); @Override Type getType(); @Override Host getDestination(); @Override String getLocal(); @Override T serialize(final Serializer dict); @Override TransferAction action(final Session<?> source, final Session<?> destination, boolean resumeRequested, boolean reloadRequested,
                                 final TransferPrompt prompt, final ListProgressListener listener); @Override TransferPathFilter filter(final Session<?> source, final Session<?> destination, final TransferAction action, final ProgressListener listener); @Override List<TransferItem> list(final Session<?> session, final Path directory, final Local local,
                                   final ListProgressListener listener); @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<?> session, final Session<?> destination, final Path source, final Local n,
                         final TransferOptions options, final TransferStatus status,
                         final ConnectionCallback connectionCallback,
                         final ProgressListener listener, final StreamListener streamListener); @Override void normalize();  }