class SwiftContainerListService implements RootListService {

    @Override
    public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
        if(log.isDebugEnabled()) {
            log.debug(String.format("List containers for %s", session));
        }
        try {
            final AttributedList<Path> containers = new AttributedList<Path>();
            final int limit = preferences.getInteger("openstack.list.container.limit");
            final Client client = session.getClient();
            for(final Region r : client.getRegions()) {
                if(region.getIdentifier() != null) {
                    if(!StringUtils.equals(r.getRegionId(), region.getIdentifier())) {
                        log.warn(String.format("Skip region %s", r));
                        continue;
                    }
                }
                // List all containers
                List<Container> chunk;
                String marker = null;
                do {
                    chunk = client.listContainers(r, limit, marker);
                    for(final Container f : chunk) {
                        final PathAttributes attributes = new PathAttributes();
                        attributes.setRegion(f.getRegion().getRegionId());
                        containers.add(new Path(String.format("/%s", f.getName()),
                                EnumSet.of(Path.Type.volume, Path.Type.directory), attributes));
                        marker = f.getName();
                    }
                    listener.chunk(directory, containers);
                }
                while(!chunk.isEmpty());
            }
            return containers;
        }
        catch(GenericException e) {
            throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory);
        }
        catch(IOException e) {
            throw new DefaultIOExceptionMappingService().map(e);
        }
    }

    public  SwiftContainerListService(final SwiftSession session, final SwiftLocationFeature.SwiftRegion region);

}