List of usage examples for com.mongodb.client.model Updates pullAll
public static <TItem> Bson pullAll(final String fieldName, final List<TItem> values)
From source file:org.opencb.opencga.catalog.db.mongodb.CatalogMongoStudyDBAdaptor.java
License:Apache License
@Override public void removeUsersFromGroup(long studyId, String groupId, List<String> members) throws CatalogDBException { for (String member : members) { dbAdaptorFactory.getCatalogUserDBAdaptor().checkUserExists(member); }/*from w ww . j a v a2 s . co m*/ Bson and = Filters.and(Filters.eq(PRIVATE_ID, studyId), Filters.eq("groups.name", groupId)); Bson pull = Updates.pullAll("groups.$.userIds", members); QueryResult<UpdateResult> update = studyCollection.update(and, pull, null); if (update.first().getModifiedCount() != 1) { throw new CatalogDBException("Unable to remove members from group " + groupId); } }
From source file:org.opencb.opencga.catalog.db.mongodb.MongoDBUtils.java
License:Apache License
static void removeAclsFromMember(long id, String member, List<String> permissions, MongoDBCollection collection) throws CatalogDBException { Document query = new Document().append(PRIVATE_ID, id).append(FileDBAdaptor.QueryParams.ACL_MEMBER.key(), member);/*from w w w .j ava 2 s .c o m*/ Bson pull = Updates.pullAll("acl.$.permissions", permissions); QueryResult<UpdateResult> update = collection.update(query, pull, null); if (update.first().getModifiedCount() != 1) { throw new CatalogDBException("Unable to remove the permissions from " + member + ". Maybe it didn't have those permissions?"); } }
From source file:org.opencb.opencga.catalog.db.mongodb.StudyMongoDBAdaptor.java
License:Apache License
@Override public void removeUsersFromGroup(long studyId, String groupId, List<String> members) throws CatalogDBException { for (String member : members) { dbAdaptorFactory.getCatalogUserDBAdaptor().checkId(member); }//from w ww . ja v a 2 s . com Bson and = Filters.and(Filters.eq(PRIVATE_ID, studyId), Filters.eq("groups.name", groupId)); Bson pull = Updates.pullAll("groups.$.userIds", members); QueryResult<UpdateResult> update = studyCollection.update(and, pull, null); if (update.first().getModifiedCount() != 1) { throw new CatalogDBException("Unable to remove members from group " + groupId); } }