@Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        if(directory.isRoot()) {
            final String bucket = RequestEntityRestStorageService.findBucketInHostname(session.getHost());
            if(StringUtils.isEmpty(bucket)) {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("No bucket name in host %s", session.getHost().getHostname()));
                }
                // List all buckets
                try {
                    return new S3BucketListService(session).list(directory, listener);
                }
                catch(InteroperabilityException e) {
                    // Bucket set in hostname that leads to parser failure for XML reply
                    log.warn(String.format("Failure %s listing buckets", e));
                    try {
                        return this.listObjects(directory, listener);
                    }
                    catch(BackgroundException ignored) {
                        log.warn(String.format("Ignore failure %s listing objects", ignored));
                        // Throw original failure
                        throw e;
                    }
                }
            }
            // If bucket is specified in hostname, try to connect to this particular bucket only.
        }
        return this.listObjects(directory, listener);
    }
@Test
    public void testListBucketNameInHostname() throws Exception {
        new S3ListService(virtualhost, new S3AccessControlListFeature(virtualhost)).list(
                new Path("/", EnumSet.of(Path.Type.directory, Path.Type.volume)), new DisabledListProgressListener());
    }