@Test public void testCreate() throws Exception { final CommandLineParser parser = new PosixParser(); final Transfer transfer = new TerminalTransferFactory().create(parser.parse(TerminalOptionsBuilder.options(), new String[]{"--download", "rackspace: new Host(new SwiftProtocol()), new Path("/remote", EnumSet.of(Path.Type.directory)), Collections.<TransferItem>emptyList()); assertEquals(Transfer.Type.download, transfer.getType()); }
public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items) throws BackgroundException { final Transfer transfer; final TerminalAction type = TerminalActionFinder.get(input); if(null == type) { throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type"); } switch(type) { case download: if(StringUtils.containsAny(remote.getName(), '*')) { transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName())); } else { transfer = new DownloadTransfer(host, items); } if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final DownloadFilterOptions options = new DownloadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((DownloadTransfer) transfer).withOptions(options); } break; case upload: transfer = new UploadTransfer(host, items); if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final UploadFilterOptions options = new UploadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((UploadTransfer) transfer).withOptions(options); } break; case synchronize: transfer = new SyncTransfer(host, items.iterator().next()); break; default: throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Unknown transfer type %s", type.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) { try { transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name()))); } catch(NumberFormatException ignore) { } } return transfer; }
TerminalTransferFactory { public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items) throws BackgroundException { final Transfer transfer; final TerminalAction type = TerminalActionFinder.get(input); if(null == type) { throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type"); } switch(type) { case download: if(StringUtils.containsAny(remote.getName(), '*')) { transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName())); } else { transfer = new DownloadTransfer(host, items); } if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final DownloadFilterOptions options = new DownloadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((DownloadTransfer) transfer).withOptions(options); } break; case upload: transfer = new UploadTransfer(host, items); if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final UploadFilterOptions options = new UploadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((UploadTransfer) transfer).withOptions(options); } break; case synchronize: transfer = new SyncTransfer(host, items.iterator().next()); break; default: throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Unknown transfer type %s", type.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) { try { transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name()))); } catch(NumberFormatException ignore) { } } return transfer; } }
TerminalTransferFactory { public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items) throws BackgroundException { final Transfer transfer; final TerminalAction type = TerminalActionFinder.get(input); if(null == type) { throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type"); } switch(type) { case download: if(StringUtils.containsAny(remote.getName(), '*')) { transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName())); } else { transfer = new DownloadTransfer(host, items); } if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final DownloadFilterOptions options = new DownloadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((DownloadTransfer) transfer).withOptions(options); } break; case upload: transfer = new UploadTransfer(host, items); if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final UploadFilterOptions options = new UploadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((UploadTransfer) transfer).withOptions(options); } break; case synchronize: transfer = new SyncTransfer(host, items.iterator().next()); break; default: throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Unknown transfer type %s", type.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) { try { transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name()))); } catch(NumberFormatException ignore) { } } return transfer; }  }
TerminalTransferFactory { public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items) throws BackgroundException { final Transfer transfer; final TerminalAction type = TerminalActionFinder.get(input); if(null == type) { throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type"); } switch(type) { case download: if(StringUtils.containsAny(remote.getName(), '*')) { transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName())); } else { transfer = new DownloadTransfer(host, items); } if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final DownloadFilterOptions options = new DownloadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((DownloadTransfer) transfer).withOptions(options); } break; case upload: transfer = new UploadTransfer(host, items); if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final UploadFilterOptions options = new UploadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((UploadTransfer) transfer).withOptions(options); } break; case synchronize: transfer = new SyncTransfer(host, items.iterator().next()); break; default: throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Unknown transfer type %s", type.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) { try { transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name()))); } catch(NumberFormatException ignore) { } } return transfer; }  Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items); }
TerminalTransferFactory { public Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items) throws BackgroundException { final Transfer transfer; final TerminalAction type = TerminalActionFinder.get(input); if(null == type) { throw new BackgroundException(LocaleFactory.localizedString("Unknown"), "Unknown transfer type"); } switch(type) { case download: if(StringUtils.containsAny(remote.getName(), '*')) { transfer = new DownloadTransfer(host, items, new DownloadGlobFilter(remote.getName())); } else { transfer = new DownloadTransfer(host, items); } if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final DownloadFilterOptions options = new DownloadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((DownloadTransfer) transfer).withOptions(options); } break; case upload: transfer = new UploadTransfer(host, items); if(input.hasOption(TerminalOptionsBuilder.Params.nochecksum.name())) { final UploadFilterOptions options = new UploadFilterOptions(); options.checksum = Boolean.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.nochecksum.name())); ((UploadTransfer) transfer).withOptions(options); } break; case synchronize: transfer = new SyncTransfer(host, items.iterator().next()); break; default: throw new BackgroundException(LocaleFactory.localizedString("Unknown"), String.format("Unknown transfer type %s", type.name())); } if(input.hasOption(TerminalOptionsBuilder.Params.throttle.name())) { try { transfer.setBandwidth(Float.valueOf(input.getOptionValue(TerminalOptionsBuilder.Params.throttle.name()))); } catch(NumberFormatException ignore) { } } return transfer; }  Transfer create(final CommandLine input, final Host host, final Path remote, final List<TransferItem> items);  }