class FileSystemDataSetMetadataRepository extends ObjectDataSetMetadataRepository {

    @Override
    public void save(DataSetMetadata metadata) {

        String id = metadata.getId();

        ReentrantReadWriteLock lock = locks.getLock(id);
        final File file = getFile(id);

        lock.writeLock().lock();
        try (GZIPOutputStream output = new GZIPOutputStream(new FileOutputStream(file))) {
            mapper.writer().writeValue(output, metadata);
        } catch (IOException e) {
            LOG.error("Error saving {}", metadata, e);
            throw new TDPException(DataSetErrorCodes.UNABLE_TO_STORE_DATASET_METADATA, e,
                    ExceptionContext.build().put("id", metadata.getId()));
        } finally {
            lock.writeLock().unlock();
        }
    }

}