class MongoDbAuthorityRepository implements AuthorityRepository {

    @Override
    public Authority save(Authority item) {
        Authority fromDb = getByAuthority(item.getAuthority());
        Authority save;
        if(fromDb == null) {
            save = converter.convert(item, Authority.class);
        } else {
            fromDb.setDefaultForNewUser(item.isDefaultForNewUser());
            save=fromDb;
        }
        template.save(save, AUTHORITY_COLLECTION);
        return save;
    }

}