@Test public void testSearchSameDirectory() throws Exception { Assume.assumeTrue(session.getClient().existsAndIsAccessible(testPathPrefix.getAbsolute())); final String newDirectoryName = new AlphanumericRandomStringService().random(); final Path newDirectory = new Path(testPathPrefix, newDirectoryName, TYPE_DIRECTORY); final String newFileName = new AlphanumericRandomStringService().random(); new MantaDirectoryFeature(session).mkdir(newDirectory, null, null); new MantaTouchFeature(session).touch(new Path(newDirectory, newFileName, TYPE_FILE), null); final MantaSearchFeature s = new MantaSearchFeature(session); final AttributedList<Path> search = s.search(newDirectory, new NullFilter<>(), new DisabledListProgressListener()); assertEquals(1, search.size()); assertEquals(newFileName, search.get(0).getName()); }
@Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); if(workdir.getParent().isRoot()) { final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o); final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate); cleanResults(homeFolderPaths, regex); addPaths(list, workdir, listener, homeFolderPaths); } else { final List<Path> foundPaths = findObjectsAsPaths(workdir, null); cleanResults(foundPaths, regex); addPaths(list, workdir, listener, foundPaths); } return list; }
MantaSearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); if(workdir.getParent().isRoot()) { final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o); final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate); cleanResults(homeFolderPaths, regex); addPaths(list, workdir, listener, homeFolderPaths); } else { final List<Path> foundPaths = findObjectsAsPaths(workdir, null); cleanResults(foundPaths, regex); addPaths(list, workdir, listener, foundPaths); } return list; } }
MantaSearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); if(workdir.getParent().isRoot()) { final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o); final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate); cleanResults(homeFolderPaths, regex); addPaths(list, workdir, listener, homeFolderPaths); } else { final List<Path> foundPaths = findObjectsAsPaths(workdir, null); cleanResults(foundPaths, regex); addPaths(list, workdir, listener, foundPaths); } return list; } MantaSearchFeature(final MantaSession session); }
MantaSearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); if(workdir.getParent().isRoot()) { final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o); final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate); cleanResults(homeFolderPaths, regex); addPaths(list, workdir, listener, homeFolderPaths); } else { final List<Path> foundPaths = findObjectsAsPaths(workdir, null); cleanResults(foundPaths, regex); addPaths(list, workdir, listener, foundPaths); } return list; } MantaSearchFeature(final MantaSession session); @Override AttributedList<Path> search(final Path workdir,
                                       final Filter<Path> regex,
                                       final ListProgressListener listener); @Override boolean isRecursive(); @Override Search withCache(final Cache<Path> cache); }
MantaSearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> list = new AttributedList<>(); if(workdir.getParent().isRoot()) { final Predicate<MantaObject> fastSearchPredicate = o -> session.isWorldReadable(o) || session.isUserWritable(o); final List<Path> homeFolderPaths = findObjectsAsPaths(workdir, fastSearchPredicate); cleanResults(homeFolderPaths, regex); addPaths(list, workdir, listener, homeFolderPaths); } else { final List<Path> foundPaths = findObjectsAsPaths(workdir, null); cleanResults(foundPaths, regex); addPaths(list, workdir, listener, foundPaths); } return list; } MantaSearchFeature(final MantaSession session); @Override AttributedList<Path> search(final Path workdir,
                                       final Filter<Path> regex,
                                       final ListProgressListener listener); @Override boolean isRecursive(); @Override Search withCache(final Cache<Path> cache);  }