use of com.google.gerrit.server.group.db.GroupDelta 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.GroupDelta in project gerrit by GerritCodeReview.
the class PutOptions method apply.
@Override
public Response<GroupOptionsInfo> apply(GroupResource resource, GroupOptionsInfo input) throws NotInternalGroupException, AuthException, BadRequestException, ResourceNotFoundException, IOException, ConfigInvalidException {
GroupDescription.Internal internalGroup = resource.asInternalGroup().orElseThrow(NotInternalGroupException::new);
if (!resource.getControl().isOwner()) {
throw new AuthException("Not group owner");
}
if (input == null) {
throw new BadRequestException("options are required");
}
if (input.visibleToAll == null) {
input.visibleToAll = false;
}
if (internalGroup.isVisibleToAll() != input.visibleToAll) {
AccountGroup.UUID groupUuid = internalGroup.getGroupUUID();
GroupDelta groupDelta = GroupDelta.builder().setVisibleToAll(input.visibleToAll).build();
try {
groupsUpdateProvider.get().updateGroup(groupUuid, groupDelta);
} catch (NoSuchGroupException e) {
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
}
}
GroupOptionsInfo options = new GroupOptionsInfo();
if (input.visibleToAll) {
options.visibleToAll = true;
}
return Response.ok(options);
}
use of com.google.gerrit.server.group.db.GroupDelta in project gerrit by GerritCodeReview.
the class PutName method renameGroup.
private void renameGroup(GroupDescription.Internal group, String newName) throws ResourceConflictException, ResourceNotFoundException, IOException, ConfigInvalidException {
AccountGroup.UUID groupUuid = group.getGroupUUID();
GroupDelta groupDelta = GroupDelta.builder().setName(AccountGroup.nameKey(newName)).build();
try {
groupsUpdateProvider.get().updateGroup(groupUuid, groupDelta);
} catch (NoSuchGroupException e) {
throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid), e);
} catch (DuplicateKeyException e) {
throw new ResourceConflictException("group with name " + newName + " already exists", e);
}
}
use of com.google.gerrit.server.group.db.GroupDelta in project gerrit by GerritCodeReview.
the class GroupsUpdateIT method groupUpdateFailsWithExceptionForNotExistingGroup.
@Test
public void groupUpdateFailsWithExceptionForNotExistingGroup() throws Exception {
GroupDelta groupDelta = GroupDelta.builder().setDescription("A description for the group").build();
assertThrows(NoSuchGroupException.class, () -> updateGroup(AccountGroup.uuid("nonexistent-group-UUID"), groupDelta));
}
use of com.google.gerrit.server.group.db.GroupDelta 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");
}
Aggregations