class ArchiveReferentialRepository {

    public Optional<TapeArchiveReferentialEntity> find(String archiveId)
        throws ArchiveReferentialException {

        Document document;

        try {
            document = collection.find(
                Filters.eq(TapeArchiveReferentialEntity.ID, archiveId))
                .first();
        } catch (MongoException ex) {
            throw new ArchiveReferentialException("Could not find storage location by id " + archiveId, ex);
        }

        if (document == null) {
            return Optional.empty();
        }

        try {
            return Optional.of(fromBson(document, TapeArchiveReferentialEntity.class));
        } catch (InvalidParseOperationException e) {
            throw new IllegalStateException("Could not parse document from DB " + BsonHelper.stringify(document), e);
        }
    }

    public  ArchiveReferentialRepository(MongoCollection<Document> collection);

}