class SwiftLocationFeature implements Location {

    @Override
    public Name getLocation(final Path file) throws BackgroundException {
        final Path container = containerService.getContainer(file);
        if(container.isRoot()) {
            return unknown;
        }
        if(cache.containsKey(container)) {
            return cache.get(container);
        }
        if(Location.unknown.equals(new SwiftRegion(container.attributes().getRegion()))) {
            final SwiftRegion region = new SwiftRegion(session.getHost().getRegion());
            if(Location.unknown.equals(region)) {
                final Client client = session.getClient();
                for(Region r : client.getRegions()) {
                    try {
                        cache.put(container, new SwiftRegion(
                            client.getContainerInfo(r, container.getName()).getRegion().getRegionId())
                        );
                    }
                    catch(ContainerNotFoundException | AuthorizationException e) {
                        log.warn(String.format("Failure finding container %s in region %s", container, r.getRegionId()));
                    }
                    catch(IOException e) {
                        throw new DefaultIOExceptionMappingService().map(e);
                    }
                }
                if(!cache.containsKey(container)) {
                    throw new NotfoundException(container.getAbsolute());
                }
            }
            else {
                cache.put(container, region);
            }
        }
        else {
            final SwiftRegion r = new SwiftRegion(container.attributes().getRegion());
            cache.put(container, r);
        }
        return cache.get(container);
    }

    public  SwiftLocationFeature(final SwiftSession session);

}