use of com.google.gerrit.server.group.db.InternalGroupCreation in project gerrit by GerritCodeReview.
the class GroupOperationsImpl method createNewGroup.
private AccountGroup.UUID createNewGroup(TestGroupCreation groupCreation) throws ConfigInvalidException, IOException {
InternalGroupCreation internalGroupCreation = toInternalGroupCreation(groupCreation);
GroupDelta groupDelta = toGroupDelta(groupCreation);
InternalGroup internalGroup = groupsUpdate.createGroup(internalGroupCreation, groupDelta);
return internalGroup.getGroupUUID();
}
use of com.google.gerrit.server.group.db.InternalGroupCreation in project gerrit by GerritCodeReview.
the class GroupsUpdateIT method groupCreationIsRetriedWhenFailedDueToConcurrentNameModification.
@Test
public void groupCreationIsRetriedWhenFailedDueToConcurrentNameModification() throws Exception {
InternalGroupCreation groupCreation = getGroupCreation("users", "users-UUID");
GroupDelta groupDelta = GroupDelta.builder().setMemberModification(new CreateAnotherGroupOnceAsSideEffectOfMemberModification("verifiers")).build();
createGroup(groupCreation, groupDelta);
Stream<String> allGroupNames = getAllGroupNames();
assertThat(allGroupNames).containsAtLeast("users", "verifiers");
}
use of com.google.gerrit.server.group.db.InternalGroupCreation in project gerrit by GerritCodeReview.
the class SchemaCreatorImpl method createBatchUsersGroup.
private void createBatchUsersGroup(Sequences seqs, Repository allUsersRepo, GroupReference groupReference, AccountGroup.UUID adminsGroupUuid) throws IOException, ConfigInvalidException {
InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference);
GroupDelta groupDelta = GroupDelta.builder().setDescription("Users who perform batch actions on Gerrit").setOwnerGroupUUID(adminsGroupUuid).build();
createGroup(allUsersRepo, groupCreation, groupDelta);
}
use of com.google.gerrit.server.group.db.InternalGroupCreation in project gerrit by GerritCodeReview.
the class CreateGroup method createGroup.
private InternalGroup createGroup(CreateGroupArgs createGroupArgs) throws ResourceConflictException, IOException, ConfigInvalidException {
String nameLower = createGroupArgs.getGroupName().toLowerCase(Locale.US);
for (String name : systemGroupBackend.getNames()) {
if (name.toLowerCase(Locale.US).equals(nameLower)) {
throw new ResourceConflictException("group '" + name + "' already exists");
}
}
for (String name : systemGroupBackend.getReservedNames()) {
if (name.toLowerCase(Locale.US).equals(nameLower)) {
throw new ResourceConflictException("group name '" + name + "' is reserved");
}
}
AccountGroup.Id groupId = AccountGroup.id(sequences.nextGroupId());
AccountGroup.UUID uuid = MoreObjects.firstNonNull(createGroupArgs.uuid, GroupUuid.make(createGroupArgs.getGroupName(), self.get().newCommitterIdent(TimeUtil.now(), serverTimeZone)));
InternalGroupCreation groupCreation = InternalGroupCreation.builder().setGroupUUID(uuid).setNameKey(createGroupArgs.getGroup()).setId(groupId).build();
GroupDelta.Builder groupDeltaBuilder = GroupDelta.builder().setVisibleToAll(createGroupArgs.visibleToAll);
if (createGroupArgs.ownerGroupUuid != null) {
Optional<InternalGroup> ownerGroup = groupCache.get(createGroupArgs.ownerGroupUuid);
ownerGroup.map(InternalGroup::getGroupUUID).ifPresent(groupDeltaBuilder::setOwnerGroupUUID);
}
if (createGroupArgs.groupDescription != null) {
groupDeltaBuilder.setDescription(createGroupArgs.groupDescription);
}
groupDeltaBuilder.setMemberModification(members -> ImmutableSet.copyOf(createGroupArgs.initialMembers));
try {
return groupsUpdateProvider.get().createGroup(groupCreation, groupDeltaBuilder.build());
} catch (DuplicateKeyException e) {
throw new ResourceConflictException("group '" + createGroupArgs.getGroupName() + "' already exists", e);
}
}
use of com.google.gerrit.server.group.db.InternalGroupCreation in project gerrit by GerritCodeReview.
the class SchemaCreatorImpl method createAdminsGroup.
private void createAdminsGroup(Sequences seqs, Repository allUsersRepo, GroupReference groupReference) throws IOException, ConfigInvalidException {
InternalGroupCreation groupCreation = getGroupCreation(seqs, groupReference);
GroupDelta groupDelta = GroupDelta.builder().setDescription("Gerrit Site Administrators").build();
createGroup(allUsersRepo, groupCreation, groupDelta);
}
Aggregations