@Override
    public boolean find(final Path file, final ListProgressListener listener) throws BackgroundException {
        if(file.isRoot()) {
            return true;
        }
        try {
            if(containerService.isContainer(file)) {
                try {
                    if(log.isDebugEnabled()) {
                        log.debug(String.format("Test if bucket %s is accessible", file));
                    }
                    return session.getClient().isBucketAccessible(containerService.getContainer(file).getName());
                }
                catch(ServiceException e) {
                    throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, file);
                }
            }
            if(file.isFile() || file.isPlaceholder()) {
                attributes.find(file, listener);
                return true;
            }
            else {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Search for common prefix %s", file));
                }
                // Check for common prefix
                try {
                    new S3ObjectListService(session, acl).list(file, new CancellingListProgressListener(), String.valueOf(Path.DELIMITER), 1);
                    return true;
                }
                catch(ListCanceledException l) {
                    // Found common prefix
                    return true;
                }
                catch(NotfoundException e) {
                    throw e;
                }
            }
        }
        catch(NotfoundException e) {
            return false;
        }
        catch(RetriableAccessDeniedException e) {
            // Must fail with server error
            throw e;
        }
        catch(AccessDeniedException e) {
            // Object is inaccessible to current user, but does exist.
            return true;
        }
    }
@Test
    public void testFindCommonPrefix() throws Exception {
        final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
        assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(container));
        final String prefix = new AlphanumericRandomStringService().random();
        final Path test = new S3TouchFeature(session, new S3AccessControlListFeature(session)).touch(
                new Path(new Path(container, prefix, EnumSet.of(Path.Type.directory)),
                        new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
        assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(test));
        assertFalse(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(new Path(test.getAbsolute(), EnumSet.of(Path.Type.directory))));
        assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(new Path(container, prefix, EnumSet.of(Path.Type.directory))));
        assertTrue(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(new Path(container, prefix, EnumSet.of(Path.Type.directory, Path.Type.placeholder))));
        assertTrue(new S3ObjectListService(session, new S3AccessControlListFeature(session)).list(new Path(container, prefix, EnumSet.of(Path.Type.directory)),
                new DisabledListProgressListener()).contains(test));
        new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
        assertFalse(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(test));
        assertFalse(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(new Path(container, prefix, EnumSet.of(Path.Type.directory))));
        final PathCache cache = new PathCache(1);
        final Path directory = new Path(container, prefix, EnumSet.of(Path.Type.directory, Path.Type.placeholder));
        assertFalse(new CachingFindFeature(session, cache, new S3FindFeature(session, new S3AccessControlListFeature(session))).find(directory));
        assertFalse(cache.isCached(directory));
        assertFalse(new S3FindFeature(session, new S3AccessControlListFeature(session)).find(new Path(container, prefix, EnumSet.of(Path.Type.directory, Path.Type.placeholder))));
    }