use of com.google.gerrit.entities.AccountGroup in project gerrit by GerritCodeReview.
the class GroupsOnInit method getExistingGroup.
/**
* Returns the {@code AccountGroup} for the specified {@code GroupReference}.
*
* @param groupReference the {@code GroupReference} of the group
* @return the {@code InternalGroup} represented by the {@code GroupReference}
* @throws IOException if an error occurs while reading from NoteDb
* @throws ConfigInvalidException if the data in NoteDb is in an incorrect format
* @throws NoSuchGroupException if a group with such a name doesn't exist
*/
public InternalGroup getExistingGroup(GroupReference groupReference) throws NoSuchGroupException, IOException, ConfigInvalidException {
File allUsersRepoPath = getPathToAllUsersRepository();
if (allUsersRepoPath != null) {
try (Repository allUsersRepo = new FileRepository(allUsersRepoPath)) {
AccountGroup.UUID groupUuid = groupReference.getUUID();
GroupConfig groupConfig = GroupConfig.loadForGroup(allUsers, allUsersRepo, groupUuid);
return groupConfig.getLoadedGroup().orElseThrow(() -> new NoSuchGroupException(groupReference.getUUID()));
}
}
throw new NoSuchGroupException(groupReference.getUUID());
}
Aggregations