class SwiftMetadataFeature implements Headers {

    @Override
    public void setMetadata(final Path file, final TransferStatus status) throws BackgroundException {
        try {
            if(containerService.isContainer(file)) {
                for(Map.Entry<String, String> entry : file.attributes().getMetadata().entrySet()) {
                    // Choose metadata values to remove
                    if(!status.getMetadata().containsKey(entry.getKey())) {
                        log.debug(String.format("Remove metadata with key %s", entry.getKey()));
                        status.getMetadata().put(entry.getKey(), StringUtils.EMPTY);
                    }
                }
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Write metadata %s for file %s", status, file));
                }
                session.getClient().updateContainerMetadata(regionService.lookup(file),
                    containerService.getContainer(file).getName(), status.getMetadata());
            }
            else {
                if(log.isDebugEnabled()) {
                    log.debug(String.format("Write metadata %s for file %s", status, file));
                }
                session.getClient().updateObjectMetadata(regionService.lookup(file),
                    containerService.getContainer(file).getName(), containerService.getKey(file), status.getMetadata());
            }
        }
        catch(GenericException e) {
            throw new SwiftExceptionMappingService().map("Failure to write attributes of {0}", e, file);
        }
        catch(IOException e) {
            throw new DefaultIOExceptionMappingService().map("Failure to write attributes of {0}", e, file);
        }
    }

    public  SwiftMetadataFeature(final SwiftSession session);
    public  SwiftMetadataFeature(final SwiftSession session, final SwiftRegionService regionService);

}