@Test public void testNoLocalInOptionsDownload() throws Exception { final CommandLineParser parser = new PosixParser(); final CommandLine input = parser.parse(TerminalOptionsBuilder.options(), new String[]{"--download", "rackspace: final Set<TransferItem> found = new GlobTransferItemFinder().find(input, TerminalAction.download, new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file))); assertFalse(found.isEmpty()); assertEquals(new TransferItem(new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file)), LocalFactory.get(System.getProperty("user.dir") + "/remote")), found.iterator().next()); }
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if(input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; if(StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", PathNormalizer.name(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for(Local file : directory.list(new NullFilter<String>() { @Override public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch(InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }
GlobTransferItemFinder implements TransferItemFinder { @Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if(input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; if(StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", PathNormalizer.name(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for(Local file : directory.list(new NullFilter<String>() { @Override public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch(InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); } }
GlobTransferItemFinder implements TransferItemFinder { @Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if(input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; if(StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", PathNormalizer.name(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for(Local file : directory.list(new NullFilter<String>() { @Override public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch(InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }  }
GlobTransferItemFinder implements TransferItemFinder { @Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if(input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; if(StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", PathNormalizer.name(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for(Local file : directory.list(new NullFilter<String>() { @Override public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch(InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }  @Override Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote); }
GlobTransferItemFinder implements TransferItemFinder { @Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) throws AccessDeniedException { if(input.getOptionValues(action.name()).length == 2) { final String path = input.getOptionValues(action.name())[1]; if(StringUtils.containsAny(path, '*', '?')) { final Local directory = LocalFactory.get(FilenameUtils.getFullPath(path)); if(directory.isDirectory()) { final PathMatcher matcher = FileSystems.getDefault().getPathMatcher(String.format("glob:%s", PathNormalizer.name(path))); final Set<TransferItem> items = new HashSet<TransferItem>(); for(Local file : directory.list(new NullFilter<String>() { @Override public boolean accept(final String file) { try { return matcher.matches(Paths.get(file)); } catch(InvalidPathException e) { log.warn(String.format("Failure obtaining path for file %s", file)); } return false; } })) { items.add(new TransferItem(new Path(remote, file.getName(), EnumSet.of(Path.Type.file)), file)); } return items; } } } return new SingleTransferItemFinder().find(input, action, remote); }  @Override Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote);  }