@Test public void testSearchInBucket() throws Exception { final String name = new AlphanumericRandomStringService().random(); final Path bucket = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path file = new S3TouchFeature(session).touch(new Path(bucket, name, EnumSet.of(Path.Type.file)), new TransferStatus()); final S3SearchFeature feature = new S3SearchFeature(session); assertNotNull(feature.search(bucket, new SearchFilter(name), new DisabledListProgressListener()).find(new SimplePathPredicate(file))); assertNotNull(feature.search(bucket, new SearchFilter(StringUtils.substring(name, 2)), new DisabledListProgressListener()).find(new SimplePathPredicate(file))); assertNotNull(feature.search(bucket, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)), new DisabledListProgressListener()).find(new SimplePathPredicate(file))); final Path subdir = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); assertNull(feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()).find(new SimplePathPredicate(file))); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> objects; try { objects = new S3ObjectListService(session).list(workdir, listener, null, PreferencesFactory.get().getInteger("s3.listing.chunksize")); } catch(NotfoundException e) { return AttributedList.emptyList(); } final Set<Path> removal = new HashSet<>(); for(final Path f : objects) { if(!f.getName().contains(regex.toPattern().pattern())) { removal.add(f); } } objects.removeAll(removal); return objects; }
S3SearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> objects; try { objects = new S3ObjectListService(session).list(workdir, listener, null, PreferencesFactory.get().getInteger("s3.listing.chunksize")); } catch(NotfoundException e) { return AttributedList.emptyList(); } final Set<Path> removal = new HashSet<>(); for(final Path f : objects) { if(!f.getName().contains(regex.toPattern().pattern())) { removal.add(f); } } objects.removeAll(removal); return objects; } }
S3SearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> objects; try { objects = new S3ObjectListService(session).list(workdir, listener, null, PreferencesFactory.get().getInteger("s3.listing.chunksize")); } catch(NotfoundException e) { return AttributedList.emptyList(); } final Set<Path> removal = new HashSet<>(); for(final Path f : objects) { if(!f.getName().contains(regex.toPattern().pattern())) { removal.add(f); } } objects.removeAll(removal); return objects; } S3SearchFeature(final S3Session session); }
S3SearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> objects; try { objects = new S3ObjectListService(session).list(workdir, listener, null, PreferencesFactory.get().getInteger("s3.listing.chunksize")); } catch(NotfoundException e) { return AttributedList.emptyList(); } final Set<Path> removal = new HashSet<>(); for(final Path f : objects) { if(!f.getName().contains(regex.toPattern().pattern())) { removal.add(f); } } objects.removeAll(removal); return objects; } S3SearchFeature(final S3Session 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); }
S3SearchFeature implements Search { @Override public AttributedList<Path> search(final Path workdir, final Filter<Path> regex, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> objects; try { objects = new S3ObjectListService(session).list(workdir, listener, null, PreferencesFactory.get().getInteger("s3.listing.chunksize")); } catch(NotfoundException e) { return AttributedList.emptyList(); } final Set<Path> removal = new HashSet<>(); for(final Path f : objects) { if(!f.getName().contains(regex.toPattern().pattern())) { removal.add(f); } } objects.removeAll(removal); return objects; } S3SearchFeature(final S3Session 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);  }