public AttributedList<Local> list(final String path, final Filter<String> filter) throws AccessDeniedException { final AttributedList<Local> children = new AttributedList<Local>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(path), new DirectoryStream.Filter<Path>() { @Override public boolean accept(final Path entry) { if(null == entry.getFileName()) { return false; } return filter.accept(entry.getFileName().toString()); } })) { for(Path entry : stream) { children.add(LocalFactory.get(entry.toString())); } } catch(IOException e) { throw new LocalAccessDeniedException(MessageFormat.format( LocaleFactory.localizedString("Listing directory {0} failed", "Error"), this.getName()), e); } return children; }
@Override public boolean accept(final Path file) { if(list.contains(file)) { return true; } for(Path f : list) { if(f.isChild(file)) { return true; } } return false; } }
@Override public AttributedList<Path> put(final Path folder, final AttributedList<Path> encrypted) { final AttributedList<Path> list = new AttributedList<>(); // Swap with decrypted paths for(int i = 0; i < encrypted.size(); i++) { final Path f = encrypted.get(i); list.add(i, this.toDecrypted(f)); } return delegate.put(this.toDecrypted(folder), list); }
@Override public void chunk(final Path folder, final AttributedList<Path> list) throws ConnectionCanceledException { int i = index; while(i < list.size()) { final int before = list.size(); this.visit(list, i, list.get(i)); if(list.size() == before) { i++; } // Else current item has been removed } index = list.size(); }
/** * @param comparator The comparator to use * @param filter Filter * @return Filtered list sorted with comparator */ public AttributedList<E> filter(final Comparator<E> comparator, final Filter<E> filter) { final AttributedList<E> filtered = new AttributedList<>(impl); if(null != comparator) { this.doSort(filtered.impl, comparator); } if(null != filter) { if(log.isDebugEnabled()) { log.debug(String.format("Filter list %s with filter %s", this, filter)); } filtered.impl.removeIf(new Predicate<E>() { @Override public boolean test(final E e) { return !filter.accept(e); } }); } return filtered; }
@Override public void cleanup(final List<TransferItem> list) { cache.put(directory, new AttributedList<TransferItem>(list)); filter(); } }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<Path>(); final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit"); String marker = null; .equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file); if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) { if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) { children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attr)); marker = object.getName();
/** * @param collection Default content */ public AttributedList(final Iterable<E> collection) { for(E e : collection) { this.add(e); } }
@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("List children for %s", directory)); } if(directory.isSymbolicLink() && new DownloadSymlinkResolver(roots).resolve(directory)) { if(log.isDebugEnabled()) { log.debug(String.format("Do not list children for symbolic link %s", directory)); } return Collections.emptyList(); } else { final AttributedList<Path> list; if(cache.isCached(directory)) { list = cache.get(directory); } else { list = session.getFeature(ListService.class).list(directory, listener); cache.put(directory, list); } final List<TransferItem> children = new ArrayList<TransferItem>(); // Return copy with filtered result only for(Path f : new AttributedList<Path>(list.filter(comparator, filter))) { children.add(new TransferItem(f, LocalFactory.get(local, f.getName()))); } return children; } }
final Path dataRoot = new Path(f, "d", f.getType()); if(find.find(dataRoot)) { for(Path d : session._getFeature(ListService.class).list(dataRoot, new DisabledListProgressListener()).toList()) { metadata.addAll(session._getFeature(ListService.class).list(d, new DisabledListProgressListener()).toList()); metadata.add(d); for(Path m : session._getFeature(ListService.class).list(metaRoot, new DisabledListProgressListener()).toList()) { for(Path m2 : session._getFeature(ListService.class).list(m, new DisabledListProgressListener()).toList()) { metadata.addAll(session._getFeature(ListService.class).list(m2, new DisabledListProgressListener()).toList()); metadata.add(m2);
protected Path search(final Path file) throws BackgroundException { final AttributedList<Path> list; if(!cache.isCached(file.getParent())) { // Do not decrypt filenames to match with input list = session._getFeature(ListService.class).list(file.getParent(), new CachingListProgressListener(cache)); } else { list = cache.get(file.getParent()); } // Search with specific version and region final Path path = list.find(new DefaultPathPredicate(file)); if(path != null) { return path; } // Try to match path only as the version might have changed in the meantime return list.find(session.getCase() == Session.Case.insensitive ? new CaseInsensitivePathPredicate(file) : new SimplePathPredicate(file)); }
@Override public NSObject outlineView_child_ofItem(final NSOutlineView view, final NSInteger index, final NSObject item) { final AttributedList<TransferItem> children = this.get(null == item ? null : cache.lookup(new NSObjectTransferItemReference(item))); return NSObjectPathReference.get(children.get(index.intValue()).remote); }
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } try { if(session.getClient().hasFeature(FTPCmd.MLST.getCommand())) { if(!FTPReply.isPositiveCompletion(session.getClient().sendCommand(FTPCmd.MLST, file.getAbsolute()))) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } final FTPDataResponseReader reader = new FTPMlsdListResponseReader(); final AttributedList<Path> attributes = reader.read(file.getParent(), Arrays.asList(session.getClient().getReplyStrings()), new DisabledListProgressListener()); if(attributes.contains(file)) { return attributes.get(attributes.indexOf(file)).attributes(); } } throw new InteroperabilityException("No support for MLST in reply to FEAT"); } catch(IOException e) { throw new FTPExceptionMappingService().map("Failure to read attributes of {0}", e, file); } } }
protected AttributedList<TransferItem> children(final TransferItem directory) { if(null == directory) { // Root if(!cache.isCached(null)) { cache.put(null, new AttributedList<TransferItem>(transfer.getRoots())); this.filter(); } } else if(!cache.isCached(directory)) { controller.background(new WorkerBackgroundAction<List<TransferItem>>(controller, source, new TransferPromptListWorker(transfer, directory.remote, directory.local, controller) { @Override public void cleanup(final List<TransferItem> list) { cache.put(directory, new AttributedList<TransferItem>(list)); filter(); } } )); } return this.get(directory); }
public boolean addAll(final Iterable<? extends E> c) { for(E file : c) { this.add(file); } return true; }
if(status.isAppend()) { existingSegments.addAll(listService.list(segmentService.getSegmentsDirectory(file, status.getOffset() + status.getLength()), new DisabledListProgressListener()).toList());
final Path found = list.find(new SimplePathPredicate(container)); if(null != found) { return Boolean.valueOf(found.attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED));
@Override public void tableView_setObjectValue_forTableColumn_row(final NSTableView view, final NSObject value, final NSTableColumn column, final NSInteger row) { super.setObjectValueForItem(this.get(controller.workdir()).get(row.intValue()), value, column.identifier()); }