public class GroupsUpdate
extends java.lang.Object
All calls which write group related details to the database (either ReviewDb or NoteDb) are
gathered here. Other classes should always use this class instead of accessing the database
directly. There are a few exceptions though: schema classes, wrapper classes, and classes
executed during init. The latter ones should use GroupsOnInit
instead.
If not explicitly stated, all methods of this class refer to internal groups.
Modifier and Type | Class and Description |
---|---|
static interface |
GroupsUpdate.Factory |
Modifier and Type | Method and Description |
---|---|
void |
addGroup(ReviewDb db,
AccountGroup group,
java.util.Set<Account.Id> memberIds)
Adds/Creates the specified group for the specified members (accounts).
|
void |
addGroupMember(ReviewDb db,
AccountGroup.UUID groupUuid,
Account.Id accountId)
Adds an account as member to a group.
|
void |
addGroupMembers(ReviewDb db,
AccountGroup.UUID groupUuid,
java.util.Set<Account.Id> accountIds)
Adds several accounts as members to a group.
|
static void |
addNewGroup(ReviewDb db,
AccountGroup group)
Adds the specified group.
|
void |
addSubgroups(ReviewDb db,
AccountGroup.UUID parentGroupUuid,
java.util.Set<AccountGroup.UUID> subgroupUuids)
Adds several groups as subgroups to a group.
|
void |
removeGroupMembers(ReviewDb db,
AccountGroup.UUID groupUuid,
java.util.Set<Account.Id> accountIds)
Removes several members (accounts) from a group.
|
void |
removeSubgroups(ReviewDb db,
AccountGroup.UUID parentGroupUuid,
java.util.Set<AccountGroup.UUID> subgroupUuids)
Removes several subgroups from a parent group.
|
void |
renameGroup(ReviewDb db,
AccountGroup.UUID groupUuid,
AccountGroup.NameKey newName)
Renames the specified group.
|
void |
updateGroup(ReviewDb db,
AccountGroup.UUID groupUuid,
java.util.function.Consumer<AccountGroup> groupConsumer)
Updates the specified group.
|
AccountGroup |
updateGroupInDb(ReviewDb db,
AccountGroup.UUID groupUuid,
java.util.function.Consumer<AccountGroup> groupConsumer) |
public void addGroup(ReviewDb db, AccountGroup group, java.util.Set<Account.Id> memberIds) throws com.google.gwtorm.server.OrmException, java.io.IOException
db
- the ReviewDb
instance to updategroup
- the group to addmemberIds
- the IDs of the accounts which should be members of the created groupcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the cache entry of one of the new members couldn't be invalidated, or
the new group couldn't be indexedpublic static void addNewGroup(ReviewDb db, AccountGroup group) throws com.google.gwtorm.server.OrmException
Note: This method doesn't update the index! It just adds the group to the database. Use this method with care.
db
- the ReviewDb
instance to updategroup
- the group to addcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbpublic void updateGroup(ReviewDb db, AccountGroup.UUID groupUuid, java.util.function.Consumer<AccountGroup> groupConsumer) throws com.google.gwtorm.server.OrmException, java.io.IOException, NoSuchGroupException
db
- the ReviewDb
instance to updategroupUuid
- the UUID of the group to updategroupConsumer
- a Consumer
which performs the desired updates on the groupcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the cache entry for the group couldn't be invalidatedNoSuchGroupException
- if the specified group doesn't existpublic AccountGroup updateGroupInDb(ReviewDb db, AccountGroup.UUID groupUuid, java.util.function.Consumer<AccountGroup> groupConsumer) throws com.google.gwtorm.server.OrmException, NoSuchGroupException
com.google.gwtorm.server.OrmException
NoSuchGroupException
public void renameGroup(ReviewDb db, AccountGroup.UUID groupUuid, AccountGroup.NameKey newName) throws com.google.gwtorm.server.OrmException, java.io.IOException, NameAlreadyUsedException, NoSuchGroupException
db
- the ReviewDb
instance to updategroupUuid
- the UUID of the group to renamenewName
- the new name of the groupcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the cache entry for the group couldn't be invalidatedNoSuchGroupException
- if the specified group doesn't existNameAlreadyUsedException
- if another group has the name newName
public void addGroupMember(ReviewDb db, AccountGroup.UUID groupUuid, Account.Id accountId) throws com.google.gwtorm.server.OrmException, java.io.IOException, NoSuchGroupException
Note: This method doesn't check whether the account exists!
db
- the ReviewDb
instance to updategroupUuid
- the UUID of the groupaccountId
- the ID of the account to addcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the cache entry of the new member couldn't be invalidatedNoSuchGroupException
- if the specified group doesn't existpublic void addGroupMembers(ReviewDb db, AccountGroup.UUID groupUuid, java.util.Set<Account.Id> accountIds) throws com.google.gwtorm.server.OrmException, java.io.IOException, NoSuchGroupException
Note: This method doesn't check whether the accounts exist!
db
- the ReviewDb
instance to updategroupUuid
- the UUID of the groupaccountIds
- a set of IDs of accounts to addcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the group or one of the new members couldn't be indexedNoSuchGroupException
- if the specified group doesn't existpublic void removeGroupMembers(ReviewDb db, AccountGroup.UUID groupUuid, java.util.Set<Account.Id> accountIds) throws com.google.gwtorm.server.OrmException, java.io.IOException, NoSuchGroupException
db
- the ReviewDb
instance to updategroupUuid
- the UUID of the groupaccountIds
- a set of IDs of accounts to removecom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the group or one of the removed members couldn't be indexedNoSuchGroupException
- if the specified group doesn't existpublic void addSubgroups(ReviewDb db, AccountGroup.UUID parentGroupUuid, java.util.Set<AccountGroup.UUID> subgroupUuids) throws com.google.gwtorm.server.OrmException, NoSuchGroupException, java.io.IOException
The parent group must be an internal group whereas the subgroups can either be internal or external groups.
Note: This method doesn't check whether the subgroups exist!
db
- the ReviewDb
instance to updateparentGroupUuid
- the UUID of the parent groupsubgroupUuids
- a set of IDs of the groups to add as subgroupscom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the parent group couldn't be indexedNoSuchGroupException
- if the specified parent group doesn't existpublic void removeSubgroups(ReviewDb db, AccountGroup.UUID parentGroupUuid, java.util.Set<AccountGroup.UUID> subgroupUuids) throws com.google.gwtorm.server.OrmException, NoSuchGroupException, java.io.IOException
The parent group must be an internal group whereas the subgroups can either be internal or external groups.
db
- the ReviewDb
instance to updateparentGroupUuid
- the UUID of the parent groupsubgroupUuids
- a set of IDs of the subgroups to remove from the parent groupcom.google.gwtorm.server.OrmException
- if an error occurs while reading/writing from/to ReviewDbjava.io.IOException
- if the parent group couldn't be indexedNoSuchGroupException
- if the specified parent group doesn't exist