diff --git a/Documentation/rest-api-groups.txt b/Documentation/rest-api-groups.txt index 657f4987f2..7eac992371 100644 --- a/Documentation/rest-api-groups.txt +++ b/Documentation/rest-api-groups.txt @@ -116,7 +116,7 @@ client so they are generally disabled by default. Optional fields are: [[includes]] -- -* `INCLUDES`: include list of directly included groups. +* `INCLUDES`: include list of direct subgroups. -- [[members]] @@ -1129,13 +1129,13 @@ already a member of the group. ] ---- -[[delete-group-member]] -=== Delete Group Member +[[remove-group-member]] +=== Remove Group Member -- 'DELETE /groups/link:#group-id[\{group-id\}]/members/link:rest-api-accounts.html#account-id[\{account-id\}]' -- -Deletes a user from a Gerrit internal group. +Removes a user from a Gerrit internal group. .Request ---- @@ -1147,15 +1147,15 @@ Deletes a user from a Gerrit internal group. HTTP/1.1 204 No Content ---- -[[delete-group-members]] -=== Delete Group Members +[[remove-group-members]] +=== Remove Group Members -- 'POST /groups/link:#group-id[\{group-id\}]/members.delete' -- -Delete one or several users from a Gerrit internal group. +Removes one or several users from a Gerrit internal group. -The users to be deleted from the group must be provided in the request +The users to be removed from the group must be provided in the request body as a link:#members-input[MembersInput] entity. .Request @@ -1176,16 +1176,16 @@ body as a link:#members-input[MembersInput] entity. HTTP/1.1 204 No Content ---- -[[group-include-endpoints]] -== Group Include Endpoints +[[subgroup-endpoints]] +== Subgroup Endpoints -[[included-groups]] -=== List Included Groups +[[list-subgroups]] +=== List Subgroups -- 'GET /groups/link:#group-id[\{group-id\}]/groups/' -- -Lists the directly included groups of a group. +Lists the direct subgroups of a group. As result a list of link:#group-info[GroupInfo] entries is returned. The entries in the list are sorted by group name and UUID. @@ -1217,13 +1217,13 @@ The entries in the list are sorted by group name and UUID. ] ---- -[[get-included-group]] -=== Get Included Group +[[get-subgroup]] +=== Get Subgroup -- 'GET /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]' -- -Retrieves an included group. +Retrieves a subgroup. .Request ---- @@ -1231,7 +1231,7 @@ Retrieves an included group. ---- As response a link:#group-info[GroupInfo] entity is returned that -describes the included group. +describes the subgroup. .Response ---- @@ -1253,13 +1253,13 @@ describes the included group. } ---- -[[include-group]] -=== Include Group +[[add-subgroup]] +=== Add Subgroup -- 'PUT /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]' -- -Includes an internal or external group into a Gerrit internal group. +Adds an internal or external group as subgroup to a Gerrit internal group. External groups must be specified using the UUID. .Request @@ -1268,7 +1268,7 @@ External groups must be specified using the UUID. ---- As response a link:#group-info[GroupInfo] entity is returned that -describes the included group. +describes the subgroup. .Response ---- @@ -1290,11 +1290,11 @@ describes the included group. } ---- -The request also succeeds if the group is already included in this -group, but then the HTTP response code is `200 OK`. +The request also succeeds if the group is already a subgroup of this +group. -[[include-groups]] -=== Include Groups +[[add-subgroups]] +=== Add Subgroups -- 'POST /groups/link:#group-id[\{group-id\}]/groups' -- @@ -1305,10 +1305,10 @@ OR 'POST /groups/link:#group-id[\{group-id\}]/groups.add' -- -Includes one or several groups into a Gerrit internal group. +Adds one or several groups as subgroups to a Gerrit internal group. -The groups to be included into the group must be provided in the -request body as a link:#groups-input[GroupsInput] entity. +The subgroups to be added must be provided in the request body as a +link:#groups-input[GroupsInput] entity. .Request ---- @@ -1327,8 +1327,8 @@ As response a list of link:#group-info[GroupInfo] entities is returned that describes the groups that were specified in the link:#groups-input[GroupsInput]. A link:#group-info[GroupInfo] entity is returned for each group specified in the input, independently of -whether the group was newly included into the group or whether the -group was already included in the group. +whether the group was newly added as subgroup or whether the +group was already a subgroup of the group. .Response ---- @@ -1363,13 +1363,13 @@ group was already included in the group. ] ---- -[[delete-included-group]] -=== Delete Included Group +[[remove-subgroup]] +=== Remove Subgroup -- 'DELETE /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]' -- -Deletes an included group from a Gerrit internal group. +Removes a subgroup from a Gerrit internal group. .Request ---- @@ -1381,16 +1381,16 @@ Deletes an included group from a Gerrit internal group. HTTP/1.1 204 No Content ---- -[[delete-included-groups]] -=== Delete Included Groups +[[remove-subgroups]] +=== Remove Subgroups -- 'POST /groups/link:#group-id[\{group-id\}]/groups.delete' -- -Delete one or several included groups from a Gerrit internal group. +Removes one or several subgroups from a Gerrit internal group. -The groups to be deleted from the group must be provided in the request -body as a link:#groups-input[GroupsInput] entity. +The subgroups to be removed must be provided in the request body as a +link:#groups-input[GroupsInput] entity. .Request ---- @@ -1495,9 +1495,9 @@ A list of link:rest-api-accounts.html#account-info[AccountInfo] entities describing the direct members. + Only set if link:#members[members] are requested. |`includes` |optional, only for internal groups| -A list of link:#group-info[GroupInfo] entities describing the directly -included groups. + -Only set if link:#includes[included groups] are requested. +A list of link:#group-info[GroupInfo] entities describing the direct +subgroups. + +Only set if link:#includes[subgroups] are requested. |=========================== The type of a group can be deduced from the group's UUID: diff --git a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/groups/GroupApi.java b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/groups/GroupApi.java index 0d4742b647..fe85eaadca 100644 --- a/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/groups/GroupApi.java +++ b/gerrit-extension-api/src/main/java/com/google/gerrit/extensions/api/groups/GroupApi.java @@ -109,15 +109,15 @@ public interface GroupApi { void removeMembers(String... members) throws RestApiException; /** - * List included groups. + * Lists the subgroups of this group. * - * @return included groups. + * @return the found subgroups * @throws RestApiException */ List includedGroups() throws RestApiException; /** - * Add groups to be included in this one. + * Adds subgroups to this group. * * @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)} * @throws RestApiException @@ -125,7 +125,7 @@ public interface GroupApi { void addGroups(String... groups) throws RestApiException; /** - * Remove included groups from this one. + * Removes subgroups from this group. * * @param groups list of group identifiers, in any format accepted by {@link Groups#id(String)} * @throws RestApiException diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupCacheImpl.java index b5674094e9..29015013e8 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupCacheImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupCacheImpl.java @@ -239,9 +239,9 @@ public class GroupCacheImpl implements GroupCache { ImmutableSet members = groups.getMembers(db, groupUuid).collect(toImmutableSet()); - ImmutableSet includes = - groups.getIncludes(db, groupUuid).collect(toImmutableSet()); - return accountGroup.map(group -> InternalGroup.create(group, members, includes)); + ImmutableSet subgroups = + groups.getSubgroups(db, groupUuid).collect(toImmutableSet()); + return accountGroup.map(group -> InternalGroup.create(group, members, subgroups)); } } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java index 0d453978f1..10c002c01f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupIncludeCacheImpl.java @@ -150,7 +150,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache { public ImmutableList load(AccountGroup.UUID key) throws OrmException, NoSuchGroupException { try (ReviewDb db = schema.open()) { - return groups.getIncludes(db, key).collect(toImmutableList()); + return groups.getSubgroups(db, key).collect(toImmutableList()); } } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupMembers.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupMembers.java index 496b364112..4dc960d323 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupMembers.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/GroupMembers.java @@ -117,7 +117,7 @@ public class GroupMembers { Set indirectMembers = new HashSet<>(); if (groupControl.canSeeGroup()) { - for (AccountGroup.UUID subgroupUuid : group.getIncludes()) { + for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) { if (!seen.contains(subgroupUuid)) { indirectMembers.addAll(listAccounts(subgroupUuid, project, seen)); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/IncludingGroupMembership.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/IncludingGroupMembership.java index 87871d0096..ae28e1c3b9 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/IncludingGroupMembership.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/IncludingGroupMembership.java @@ -97,7 +97,7 @@ public class IncludingGroupMembership implements GroupMembership { if (!group.isPresent()) { continue; } - if (search(group.get().getIncludes())) { + if (search(group.get().getSubgroups())) { memberOf.put(id, true); return true; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/api/groups/GroupApiImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/api/groups/GroupApiImpl.java index 84f4535202..42213f739e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/api/groups/GroupApiImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/api/groups/GroupApiImpl.java @@ -22,10 +22,10 @@ import com.google.gerrit.extensions.common.GroupAuditEventInfo; import com.google.gerrit.extensions.common.GroupInfo; import com.google.gerrit.extensions.common.GroupOptionsInfo; import com.google.gerrit.extensions.restapi.RestApiException; -import com.google.gerrit.server.group.AddIncludedGroups; import com.google.gerrit.server.group.AddMembers; -import com.google.gerrit.server.group.DeleteIncludedGroups; +import com.google.gerrit.server.group.AddSubgroups; import com.google.gerrit.server.group.DeleteMembers; +import com.google.gerrit.server.group.DeleteSubgroups; import com.google.gerrit.server.group.GetAuditLog; import com.google.gerrit.server.group.GetDescription; import com.google.gerrit.server.group.GetDetail; @@ -35,8 +35,8 @@ import com.google.gerrit.server.group.GetOptions; import com.google.gerrit.server.group.GetOwner; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.Index; -import com.google.gerrit.server.group.ListIncludedGroups; import com.google.gerrit.server.group.ListMembers; +import com.google.gerrit.server.group.ListSubgroups; import com.google.gerrit.server.group.PutDescription; import com.google.gerrit.server.group.PutName; import com.google.gerrit.server.group.PutOptions; @@ -64,9 +64,9 @@ class GroupApiImpl implements GroupApi { private final ListMembers listMembers; private final AddMembers addMembers; private final DeleteMembers deleteMembers; - private final ListIncludedGroups listGroups; - private final AddIncludedGroups addGroups; - private final DeleteIncludedGroups deleteGroups; + private final ListSubgroups listSubgroups; + private final AddSubgroups addSubgroups; + private final DeleteSubgroups deleteSubgroups; private final GetAuditLog getAuditLog; private final GroupResource rsrc; private final Index index; @@ -86,9 +86,9 @@ class GroupApiImpl implements GroupApi { ListMembers listMembers, AddMembers addMembers, DeleteMembers deleteMembers, - ListIncludedGroups listGroups, - AddIncludedGroups addGroups, - DeleteIncludedGroups deleteGroups, + ListSubgroups listSubgroups, + AddSubgroups addSubgroups, + DeleteSubgroups deleteSubgroups, GetAuditLog getAuditLog, Index index, @Assisted GroupResource rsrc) { @@ -105,9 +105,9 @@ class GroupApiImpl implements GroupApi { this.listMembers = listMembers; this.addMembers = addMembers; this.deleteMembers = deleteMembers; - this.listGroups = listGroups; - this.addGroups = addGroups; - this.deleteGroups = deleteGroups; + this.listSubgroups = listSubgroups; + this.addSubgroups = addSubgroups; + this.deleteSubgroups = deleteSubgroups; this.getAuditLog = getAuditLog; this.index = index; this.rsrc = rsrc; @@ -233,27 +233,27 @@ class GroupApiImpl implements GroupApi { @Override public List includedGroups() throws RestApiException { try { - return listGroups.apply(rsrc); + return listSubgroups.apply(rsrc); } catch (Exception e) { - throw asRestApiException("Cannot list included groups", e); + throw asRestApiException("Cannot list subgroups", e); } } @Override public void addGroups(String... groups) throws RestApiException { try { - addGroups.apply(rsrc, AddIncludedGroups.Input.fromGroups(Arrays.asList(groups))); + addSubgroups.apply(rsrc, AddSubgroups.Input.fromGroups(Arrays.asList(groups))); } catch (Exception e) { - throw asRestApiException("Cannot add group members", e); + throw asRestApiException("Cannot add subgroups", e); } } @Override public void removeGroups(String... groups) throws RestApiException { try { - deleteGroups.apply(rsrc, AddIncludedGroups.Input.fromGroups(Arrays.asList(groups))); + deleteSubgroups.apply(rsrc, AddSubgroups.Input.fromGroups(Arrays.asList(groups))); } catch (Exception e) { - throw asRestApiException("Cannot remove group members", e); + throw asRestApiException("Cannot remove subgroups", e); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/AddIncludedGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/AddSubgroups.java similarity index 78% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/AddIncludedGroups.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/AddSubgroups.java index d77724477d..2ce168fbbb 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/AddIncludedGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/AddSubgroups.java @@ -29,7 +29,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.account.GroupControl; -import com.google.gerrit.server.group.AddIncludedGroups.Input; +import com.google.gerrit.server.group.AddSubgroups.Input; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; @@ -41,7 +41,7 @@ import java.util.List; import java.util.Set; @Singleton -public class AddIncludedGroups implements RestModifyView { +public class AddSubgroups implements RestModifyView { public static class Input { @DefaultInput String _oneGroup; @@ -73,7 +73,7 @@ public class AddIncludedGroups implements RestModifyView { private final GroupJson json; @Inject - public AddIncludedGroups( + public AddSubgroups( GroupsCollection groupsCollection, Provider db, @UserInitiated Provider groupsUpdateProvider, @@ -98,30 +98,30 @@ public class AddIncludedGroups implements RestModifyView { } List result = new ArrayList<>(); - Set includedGroupUuids = new HashSet<>(); - for (String includedGroup : input.groups) { - GroupDescription.Basic d = groupsCollection.parse(includedGroup); - includedGroupUuids.add(d.getGroupUUID()); - result.add(json.format(d)); + Set subgroupUuids = new HashSet<>(); + for (String subgroupIdentifier : input.groups) { + GroupDescription.Basic subgroup = groupsCollection.parse(subgroupIdentifier); + subgroupUuids.add(subgroup.getGroupUUID()); + result.add(json.format(subgroup)); } AccountGroup.UUID groupUuid = group.getGroupUUID(); try { - groupsUpdateProvider.get().addIncludedGroups(db.get(), groupUuid, includedGroupUuids); + groupsUpdateProvider.get().addSubgroups(db.get(), groupUuid, subgroupUuids); } catch (NoSuchGroupException e) { throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid)); } return result; } - static class PutIncludedGroup implements RestModifyView { + static class PutSubgroup implements RestModifyView { static class Input {} - private final AddIncludedGroups put; + private final AddSubgroups addSubgroups; private final String id; - PutIncludedGroup(AddIncludedGroups put, String id) { - this.put = put; + PutSubgroup(AddSubgroups addSubgroups, String id) { + this.addSubgroups = addSubgroups; this.id = id; } @@ -129,10 +129,10 @@ public class AddIncludedGroups implements RestModifyView { public GroupInfo apply(GroupResource resource, Input input) throws AuthException, MethodNotAllowedException, ResourceNotFoundException, OrmException, IOException { - AddIncludedGroups.Input in = new AddIncludedGroups.Input(); + AddSubgroups.Input in = new AddSubgroups.Input(); in.groups = ImmutableList.of(id); try { - List list = put.apply(resource, in); + List list = addSubgroups.apply(resource, in); if (list.size() == 1) { return list.get(0); } @@ -144,18 +144,16 @@ public class AddIncludedGroups implements RestModifyView { } @Singleton - static class UpdateIncludedGroup - implements RestModifyView { - private final Provider get; + static class UpdateSubgroup implements RestModifyView { + private final Provider get; @Inject - UpdateIncludedGroup(Provider get) { + UpdateSubgroup(Provider get) { this.get = get; } @Override - public GroupInfo apply(IncludedGroupResource resource, PutIncludedGroup.Input input) - throws OrmException { + public GroupInfo apply(SubgroupResource resource, PutSubgroup.Input input) throws OrmException { // Do nothing, the group is already included. return get.get().apply(resource); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteIncludedGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteSubgroups.java similarity index 78% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteIncludedGroups.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteSubgroups.java index 9d296dbb76..14df51b9d1 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteIncludedGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/DeleteSubgroups.java @@ -26,7 +26,7 @@ import com.google.gerrit.extensions.restapi.UnprocessableEntityException; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.server.ReviewDb; import com.google.gerrit.server.account.GroupControl; -import com.google.gerrit.server.group.AddIncludedGroups.Input; +import com.google.gerrit.server.group.AddSubgroups.Input; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; @@ -36,13 +36,13 @@ import java.util.HashSet; import java.util.Set; @Singleton -public class DeleteIncludedGroups implements RestModifyView { +public class DeleteSubgroups implements RestModifyView { private final GroupsCollection groupsCollection; private final Provider db; private final Provider groupsUpdateProvider; @Inject - DeleteIncludedGroups( + DeleteSubgroups( GroupsCollection groupsCollection, Provider db, @UserInitiated Provider groupsUpdateProvider) { @@ -65,15 +65,15 @@ public class DeleteIncludedGroups implements RestModifyView internalGroupsToRemove = new HashSet<>(); - for (String includedGroup : input.groups) { - GroupDescription.Basic d = groupsCollection.parse(includedGroup); - internalGroupsToRemove.add(d.getGroupUUID()); + Set subgroupsToRemove = new HashSet<>(); + for (String subgroupIdentifier : input.groups) { + GroupDescription.Basic subgroup = groupsCollection.parse(subgroupIdentifier); + subgroupsToRemove.add(subgroup.getGroupUUID()); } AccountGroup.UUID groupUuid = internalGroup.getGroupUUID(); try { - groupsUpdateProvider.get().deleteIncludedGroups(db.get(), groupUuid, internalGroupsToRemove); + groupsUpdateProvider.get().removeSubgroups(db.get(), groupUuid, subgroupsToRemove); } catch (NoSuchGroupException e) { throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid)); } @@ -82,22 +82,21 @@ public class DeleteIncludedGroups implements RestModifyView { + static class DeleteSubgroup implements RestModifyView { static class Input {} - private final Provider delete; + private final Provider delete; @Inject - DeleteIncludedGroup(Provider delete) { + DeleteSubgroup(Provider delete) { this.delete = delete; } @Override - public Response apply(IncludedGroupResource resource, Input input) + public Response apply(SubgroupResource resource, Input input) throws AuthException, MethodNotAllowedException, UnprocessableEntityException, OrmException, ResourceNotFoundException, IOException { - AddIncludedGroups.Input in = new AddIncludedGroups.Input(); + AddSubgroups.Input in = new AddSubgroups.Input(); in.groups = ImmutableList.of(resource.getMember().get()); return delete.get().apply(resource, in); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/GetIncludedGroup.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/GetSubgroup.java similarity index 84% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/GetIncludedGroup.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/GetSubgroup.java index 4cf0cb2671..a71018853f 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/GetIncludedGroup.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/GetSubgroup.java @@ -21,16 +21,16 @@ import com.google.inject.Inject; import com.google.inject.Singleton; @Singleton -public class GetIncludedGroup implements RestReadView { +public class GetSubgroup implements RestReadView { private final GroupJson json; @Inject - GetIncludedGroup(GroupJson json) { + GetSubgroup(GroupJson json) { this.json = json; } @Override - public GroupInfo apply(IncludedGroupResource rsrc) throws OrmException { + public GroupInfo apply(SubgroupResource rsrc) throws OrmException { return json.format(rsrc.getMemberDescription()); } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupJson.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupJson.java index 639ee55379..85be5c4c88 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupJson.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupJson.java @@ -45,7 +45,7 @@ public class GroupJson { private final GroupBackend groupBackend; private final GroupControl.Factory groupControlFactory; private final Provider listMembers; - private final Provider listIncludes; + private final Provider listSubgroups; private EnumSet options; @Inject @@ -53,11 +53,11 @@ public class GroupJson { GroupBackend groupBackend, GroupControl.Factory groupControlFactory, Provider listMembers, - Provider listIncludes) { + Provider listSubgroups) { this.groupBackend = groupBackend; this.groupControlFactory = groupControlFactory; this.listMembers = listMembers; - this.listIncludes = listIncludes; + this.listSubgroups = listSubgroups; options = EnumSet.noneOf(ListGroupsOption.class); } @@ -74,7 +74,7 @@ public class GroupJson { public GroupInfo format(GroupResource rsrc) throws OrmException { GroupInfo info = init(rsrc.getGroup()); - initMembersAndIncludes(rsrc, info); + initMembersAndSubgroups(rsrc, info); return info; } @@ -82,7 +82,7 @@ public class GroupJson { GroupInfo info = init(group); if (options.contains(MEMBERS) || options.contains(INCLUDES)) { GroupResource rsrc = new GroupResource(groupControlFactory.controlFor(group)); - initMembersAndIncludes(rsrc, info); + initMembersAndSubgroups(rsrc, info); } return info; } @@ -116,7 +116,8 @@ public class GroupJson { return group instanceof GroupDescription.Internal; } - private GroupInfo initMembersAndIncludes(GroupResource rsrc, GroupInfo info) throws OrmException { + private GroupInfo initMembersAndSubgroups(GroupResource rsrc, GroupInfo info) + throws OrmException { if (!rsrc.isInternalGroup()) { return info; } @@ -126,7 +127,7 @@ public class GroupJson { } if (options.contains(INCLUDES)) { - info.includes = listIncludes.get().apply(rsrc); + info.includes = listSubgroups.get().apply(rsrc); } return info; } catch (MethodNotAllowedException e) { diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/Groups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/Groups.java index 9f840eee57..b835d220ec 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/Groups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/Groups.java @@ -145,16 +145,16 @@ public class Groups { * * @param db the {@code ReviewDb} instance to use for lookups * @param parentGroupUuid the UUID of the parent group - * @param includedGroupUuid the UUID of the subgroup + * @param subgroupUuid the UUID of the subgroup * @return {@code true} if the group is a subgroup of the other group, or else {@code false} * @throws OrmException if an error occurs while reading from ReviewDb * @throws NoSuchGroupException if the specified parent group doesn't exist */ - public boolean isIncluded( - ReviewDb db, AccountGroup.UUID parentGroupUuid, AccountGroup.UUID includedGroupUuid) + public boolean isSubgroup( + ReviewDb db, AccountGroup.UUID parentGroupUuid, AccountGroup.UUID subgroupUuid) throws OrmException, NoSuchGroupException { AccountGroup parentGroup = getExistingGroup(db, parentGroupUuid); - AccountGroupById.Key key = new AccountGroupById.Key(parentGroup.getId(), includedGroupUuid); + AccountGroupById.Key key = new AccountGroupById.Key(parentGroup.getId(), subgroupUuid); return db.accountGroupById().get(key) != null; } @@ -191,7 +191,7 @@ public class Groups { * @throws OrmException if an error occurs while reading from ReviewDb * @throws NoSuchGroupException if the specified parent group doesn't exist */ - public Stream getIncludes(ReviewDb db, AccountGroup.UUID groupUuid) + public Stream getSubgroups(ReviewDb db, AccountGroup.UUID groupUuid) throws OrmException, NoSuchGroupException { AccountGroup group = getExistingGroup(db, groupUuid); ResultSet accountGroupByIds = db.accountGroupById().byGroup(group.getId()); @@ -226,14 +226,14 @@ public class Groups { * exist. This method doesn't check whether the parent groups exist. * * @param db the {@code ReviewDb} instance to use for lookups - * @param includedGroupUuid the UUID of the subgroup + * @param subgroupUuid the UUID of the subgroup * @return a stream of the IDs of the parent groups * @throws OrmException if an error occurs while reading from ReviewDb */ - public Stream getParentGroups(ReviewDb db, AccountGroup.UUID includedGroupUuid) + public Stream getParentGroups(ReviewDb db, AccountGroup.UUID subgroupUuid) throws OrmException { ResultSet accountGroupByIds = - db.accountGroupById().byIncludeUUID(includedGroupUuid); + db.accountGroupById().byIncludeUUID(subgroupUuid); return Streams.stream(accountGroupByIds).map(AccountGroupById::getGroupId); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupsUpdate.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupsUpdate.java index a55850a1a6..d688e4c92a 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupsUpdate.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/GroupsUpdate.java @@ -349,35 +349,35 @@ public class GroupsUpdate { * * @param db the {@code ReviewDb} instance to update * @param parentGroupUuid the UUID of the parent group - * @param includedGroupUuids a set of IDs of the groups to add as subgroups + * @param subgroupUuids a set of IDs of the groups to add as subgroups * @throws OrmException if an error occurs while reading/writing from/to ReviewDb * @throws IOException if the parent group couldn't be indexed * @throws NoSuchGroupException if the specified parent group doesn't exist */ - public void addIncludedGroups( - ReviewDb db, AccountGroup.UUID parentGroupUuid, Set includedGroupUuids) + public void addSubgroups( + ReviewDb db, AccountGroup.UUID parentGroupUuid, Set subgroupUuids) throws OrmException, NoSuchGroupException, IOException { AccountGroup parentGroup = groups.getExistingGroup(db, parentGroupUuid); AccountGroup.Id parentGroupId = parentGroup.getId(); - Set newIncludedGroups = new HashSet<>(); - for (AccountGroup.UUID includedGroupUuid : includedGroupUuids) { - boolean isIncluded = groups.isIncluded(db, parentGroupUuid, includedGroupUuid); - if (!isIncluded) { + Set newSubgroups = new HashSet<>(); + for (AccountGroup.UUID includedGroupUuid : subgroupUuids) { + boolean isSubgroup = groups.isSubgroup(db, parentGroupUuid, includedGroupUuid); + if (!isSubgroup) { AccountGroupById.Key key = new AccountGroupById.Key(parentGroupId, includedGroupUuid); - newIncludedGroups.add(new AccountGroupById(key)); + newSubgroups.add(new AccountGroupById(key)); } } - if (newIncludedGroups.isEmpty()) { + if (newSubgroups.isEmpty()) { return; } if (currentUser != null) { - auditService.dispatchAddGroupsToGroup(currentUser.getAccountId(), newIncludedGroups); + auditService.dispatchAddGroupsToGroup(currentUser.getAccountId(), newSubgroups); } - db.accountGroupById().insert(newIncludedGroups); + db.accountGroupById().insert(newSubgroups); groupCache.evict(parentGroup.getGroupUUID(), parentGroup.getId(), parentGroup.getNameKey()); - for (AccountGroupById newIncludedGroup : newIncludedGroups) { + for (AccountGroupById newIncludedGroup : newSubgroups) { groupIncludeCache.evictParentGroupsOf(newIncludedGroup.getIncludeUUID()); } groupIncludeCache.evictSubgroupsOf(parentGroupUuid); @@ -392,36 +392,35 @@ public class GroupsUpdate { * * @param db the {@code ReviewDb} instance to update * @param parentGroupUuid the UUID of the parent group - * @param includedGroupUuids a set of IDs of the subgroups to remove from the parent group + * @param subgroupUuids a set of IDs of the subgroups to remove from the parent group * @throws OrmException if an error occurs while reading/writing from/to ReviewDb * @throws IOException if the parent group couldn't be indexed * @throws NoSuchGroupException if the specified parent group doesn't exist */ - public void deleteIncludedGroups( - ReviewDb db, AccountGroup.UUID parentGroupUuid, Set includedGroupUuids) + public void removeSubgroups( + ReviewDb db, AccountGroup.UUID parentGroupUuid, Set subgroupUuids) throws OrmException, NoSuchGroupException, IOException { AccountGroup parentGroup = groups.getExistingGroup(db, parentGroupUuid); AccountGroup.Id parentGroupId = parentGroup.getId(); - Set includedGroupsToRemove = new HashSet<>(); - for (AccountGroup.UUID includedGroupUuid : includedGroupUuids) { - boolean isIncluded = groups.isIncluded(db, parentGroupUuid, includedGroupUuid); - if (isIncluded) { - AccountGroupById.Key key = new AccountGroupById.Key(parentGroupId, includedGroupUuid); - includedGroupsToRemove.add(new AccountGroupById(key)); + Set subgroupsToRemove = new HashSet<>(); + for (AccountGroup.UUID subgroupUuid : subgroupUuids) { + boolean isSubgroup = groups.isSubgroup(db, parentGroupUuid, subgroupUuid); + if (isSubgroup) { + AccountGroupById.Key key = new AccountGroupById.Key(parentGroupId, subgroupUuid); + subgroupsToRemove.add(new AccountGroupById(key)); } } - if (includedGroupsToRemove.isEmpty()) { + if (subgroupsToRemove.isEmpty()) { return; } if (currentUser != null) { - auditService.dispatchDeleteGroupsFromGroup( - currentUser.getAccountId(), includedGroupsToRemove); + auditService.dispatchDeleteGroupsFromGroup(currentUser.getAccountId(), subgroupsToRemove); } - db.accountGroupById().delete(includedGroupsToRemove); + db.accountGroupById().delete(subgroupsToRemove); groupCache.evict(parentGroup.getGroupUUID(), parentGroup.getId(), parentGroup.getNameKey()); - for (AccountGroupById groupToRemove : includedGroupsToRemove) { + for (AccountGroupById groupToRemove : subgroupsToRemove) { groupIncludeCache.evictParentGroupsOf(groupToRemove.getIncludeUUID()); } groupIncludeCache.evictSubgroupsOf(parentGroupUuid); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/InternalGroup.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/InternalGroup.java index 6863b36c85..228d86f067 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/InternalGroup.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/InternalGroup.java @@ -27,7 +27,7 @@ public abstract class InternalGroup { public static InternalGroup create( AccountGroup accountGroup, ImmutableSet members, - ImmutableSet includes) { + ImmutableSet subgroups) { return new AutoValue_InternalGroup( accountGroup.getId(), accountGroup.getNameKey(), @@ -37,7 +37,7 @@ public abstract class InternalGroup { accountGroup.getGroupUUID(), accountGroup.getCreatedOn(), members, - includes); + subgroups); } public abstract AccountGroup.Id getId(); @@ -61,5 +61,5 @@ public abstract class InternalGroup { public abstract ImmutableSet getMembers(); - public abstract ImmutableSet getIncludes(); + public abstract ImmutableSet getSubgroups(); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java index b92962bfda..af988b8b16 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListMembers.java @@ -96,7 +96,7 @@ public class ListMembers implements RestReadView { Set indirectMembers = new HashSet<>(); if (recursive && groupControl.canSeeGroup()) { - for (AccountGroup.UUID subgroupUuid : group.getIncludes()) { + for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) { if (!seenGroups.contains(subgroupUuid)) { indirectMembers.addAll(getMembers(subgroupUuid, seenGroups)); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListIncludedGroups.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListSubgroups.java similarity index 86% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/ListIncludedGroups.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/ListSubgroups.java index 33d9b576c8..2000d66abd 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/ListIncludedGroups.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/ListSubgroups.java @@ -35,15 +35,15 @@ import java.util.List; import org.slf4j.Logger; @Singleton -public class ListIncludedGroups implements RestReadView { - private static final Logger log = org.slf4j.LoggerFactory.getLogger(ListIncludedGroups.class); +public class ListSubgroups implements RestReadView { + private static final Logger log = org.slf4j.LoggerFactory.getLogger(ListSubgroups.class); private final GroupControl.Factory controlFactory; private final GroupIncludeCache groupIncludeCache; private final GroupJson json; @Inject - ListIncludedGroups( + ListSubgroups( GroupControl.Factory controlFactory, GroupIncludeCache groupIncludeCache, GroupJson json) { this.controlFactory = controlFactory; this.groupIncludeCache = groupIncludeCache; @@ -57,19 +57,18 @@ public class ListIncludedGroups implements RestReadView { boolean ownerOfParent = rsrc.getControl().isOwner(); List included = new ArrayList<>(); - Collection includedGroupUuids = + Collection subgroupUuids = groupIncludeCache.subgroupsOf(group.getGroupUUID()); - for (AccountGroup.UUID includedGroupUuid : includedGroupUuids) { + for (AccountGroup.UUID subgroupUuid : subgroupUuids) { try { - GroupControl i = controlFactory.controlFor(includedGroupUuid); + GroupControl i = controlFactory.controlFor(subgroupUuid); if (ownerOfParent || i.isVisible()) { included.add(json.format(i.getGroup())); } } catch (NoSuchGroupException notFound) { log.warn( String.format( - "Group %s no longer available, included into %s", - includedGroupUuid, group.getName())); + "Group %s no longer available, subgroup of %s", subgroupUuid, group.getName())); continue; } } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/Module.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/Module.java index ef704848b4..5006914661 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/Module.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/Module.java @@ -15,18 +15,18 @@ package com.google.gerrit.server.group; import static com.google.gerrit.server.group.GroupResource.GROUP_KIND; -import static com.google.gerrit.server.group.IncludedGroupResource.INCLUDED_GROUP_KIND; import static com.google.gerrit.server.group.MemberResource.MEMBER_KIND; +import static com.google.gerrit.server.group.SubgroupResource.SUBGROUP_KIND; import com.google.gerrit.audit.GroupMemberAuditListener; import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.extensions.restapi.RestApiModule; import com.google.gerrit.server.IdentifiedUser; -import com.google.gerrit.server.group.AddIncludedGroups.UpdateIncludedGroup; import com.google.gerrit.server.group.AddMembers.UpdateMember; -import com.google.gerrit.server.group.DeleteIncludedGroups.DeleteIncludedGroup; +import com.google.gerrit.server.group.AddSubgroups.UpdateSubgroup; import com.google.gerrit.server.group.DeleteMembers.DeleteMember; +import com.google.gerrit.server.group.DeleteSubgroups.DeleteSubgroup; import com.google.inject.Provides; public class Module extends RestApiModule { @@ -36,7 +36,7 @@ public class Module extends RestApiModule { DynamicMap.mapOf(binder(), GROUP_KIND); DynamicMap.mapOf(binder(), MEMBER_KIND); - DynamicMap.mapOf(binder(), INCLUDED_GROUP_KIND); + DynamicMap.mapOf(binder(), SUBGROUP_KIND); get(GROUP_KIND).to(GetGroup.class); put(GROUP_KIND).to(PutGroup.class); @@ -45,9 +45,9 @@ public class Module extends RestApiModule { post(GROUP_KIND, "members").to(AddMembers.class); post(GROUP_KIND, "members.add").to(AddMembers.class); post(GROUP_KIND, "members.delete").to(DeleteMembers.class); - post(GROUP_KIND, "groups").to(AddIncludedGroups.class); - post(GROUP_KIND, "groups.add").to(AddIncludedGroups.class); - post(GROUP_KIND, "groups.delete").to(DeleteIncludedGroups.class); + post(GROUP_KIND, "groups").to(AddSubgroups.class); + post(GROUP_KIND, "groups.add").to(AddSubgroups.class); + post(GROUP_KIND, "groups.delete").to(DeleteSubgroups.class); get(GROUP_KIND, "description").to(GetDescription.class); put(GROUP_KIND, "description").to(PutDescription.class); delete(GROUP_KIND, "description").to(PutDescription.class); @@ -64,10 +64,10 @@ public class Module extends RestApiModule { put(MEMBER_KIND).to(UpdateMember.class); delete(MEMBER_KIND).to(DeleteMember.class); - child(GROUP_KIND, "groups").to(IncludedGroupsCollection.class); - get(INCLUDED_GROUP_KIND).to(GetIncludedGroup.class); - put(INCLUDED_GROUP_KIND).to(UpdateIncludedGroup.class); - delete(INCLUDED_GROUP_KIND).to(DeleteIncludedGroup.class); + child(GROUP_KIND, "groups").to(SubgroupsCollection.class); + get(SUBGROUP_KIND).to(GetSubgroup.class); + put(SUBGROUP_KIND).to(UpdateSubgroup.class); + delete(SUBGROUP_KIND).to(DeleteSubgroup.class); factory(CreateGroup.Factory.class); factory(GroupsUpdate.Factory.class); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupResource.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupResource.java similarity index 79% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupResource.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupResource.java index 467de4c572..50c769d4b1 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupResource.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupResource.java @@ -19,13 +19,13 @@ import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.inject.TypeLiteral; -public class IncludedGroupResource extends GroupResource { - public static final TypeLiteral> INCLUDED_GROUP_KIND = - new TypeLiteral>() {}; +public class SubgroupResource extends GroupResource { + public static final TypeLiteral> SUBGROUP_KIND = + new TypeLiteral>() {}; private final GroupDescription.Basic member; - public IncludedGroupResource(GroupResource group, GroupDescription.Basic member) { + public SubgroupResource(GroupResource group, GroupDescription.Basic member) { super(group); this.member = member; } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupsCollection.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupsCollection.java similarity index 71% rename from gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupsCollection.java rename to gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupsCollection.java index d48aceef4f..e2aacd6675 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/IncludedGroupsCollection.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/SubgroupsCollection.java @@ -26,36 +26,36 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.RestView; import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.reviewdb.server.ReviewDb; -import com.google.gerrit.server.group.AddIncludedGroups.PutIncludedGroup; +import com.google.gerrit.server.group.AddSubgroups.PutSubgroup; import com.google.gwtorm.server.OrmException; import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @Singleton -public class IncludedGroupsCollection - implements ChildCollection, AcceptsCreate { - private final DynamicMap> views; - private final ListIncludedGroups list; +public class SubgroupsCollection + implements ChildCollection, AcceptsCreate { + private final DynamicMap> views; + private final ListSubgroups list; private final GroupsCollection groupsCollection; private final Provider dbProvider; private final Groups groups; - private final AddIncludedGroups put; + private final AddSubgroups addSubgroups; @Inject - IncludedGroupsCollection( - DynamicMap> views, - ListIncludedGroups list, + SubgroupsCollection( + DynamicMap> views, + ListSubgroups list, GroupsCollection groupsCollection, Provider dbProvider, Groups groups, - AddIncludedGroups put) { + AddSubgroups addSubgroups) { this.views = views; this.list = list; this.groupsCollection = groupsCollection; this.dbProvider = dbProvider; this.groups = groups; - this.put = put; + this.addSubgroups = addSubgroups; } @Override @@ -64,23 +64,23 @@ public class IncludedGroupsCollection } @Override - public IncludedGroupResource parse(GroupResource resource, IdString id) + public SubgroupResource parse(GroupResource resource, IdString id) throws MethodNotAllowedException, AuthException, ResourceNotFoundException, OrmException { GroupDescription.Internal parent = resource.asInternalGroup().orElseThrow(MethodNotAllowedException::new); GroupDescription.Basic member = groupsCollection.parse(TopLevelResource.INSTANCE, id).getGroup(); - if (resource.getControl().canSeeGroup() && isMember(parent, member)) { - return new IncludedGroupResource(resource, member); + if (resource.getControl().canSeeGroup() && isSubgroup(parent, member)) { + return new SubgroupResource(resource, member); } throw new ResourceNotFoundException(id); } - private boolean isMember(GroupDescription.Internal parent, GroupDescription.Basic member) + private boolean isSubgroup(GroupDescription.Internal parent, GroupDescription.Basic member) throws OrmException, ResourceNotFoundException { try { - return groups.isIncluded(dbProvider.get(), parent.getGroupUUID(), member.getGroupUUID()); + return groups.isSubgroup(dbProvider.get(), parent.getGroupUUID(), member.getGroupUUID()); } catch (NoSuchGroupException e) { throw new ResourceNotFoundException( String.format("Group %s not found", parent.getGroupUUID())); @@ -89,12 +89,12 @@ public class IncludedGroupsCollection @SuppressWarnings("unchecked") @Override - public PutIncludedGroup create(GroupResource group, IdString id) { - return new PutIncludedGroup(put, id.get()); + public PutSubgroup create(GroupResource group, IdString id) { + return new PutSubgroup(addSubgroups, id.get()); } @Override - public DynamicMap> views() { + public DynamicMap> views() { return views; } } diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java index 5a8e4bb5c0..6b5d6323ed 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java @@ -25,8 +25,8 @@ import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; -import com.google.gerrit.server.group.AddIncludedGroups; import com.google.gerrit.server.group.AddMembers; +import com.google.gerrit.server.group.AddSubgroups; import com.google.gerrit.server.group.CreateGroup; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.GroupsCollection; @@ -101,7 +101,7 @@ final class CreateGroupCommand extends SshCommand { @Inject private AddMembers addMembers; - @Inject private AddIncludedGroups addIncludedGroups; + @Inject private AddSubgroups addSubgroups; @Override protected void run() throws Failure, OrmException, IOException, ConfigInvalidException { @@ -113,7 +113,7 @@ final class CreateGroupCommand extends SshCommand { } if (!initialGroups.isEmpty()) { - addIncludedGroups(rsrc); + addSubgroups(rsrc); } } catch (RestApiException e) { throw die(e); @@ -142,11 +142,10 @@ final class CreateGroupCommand extends SshCommand { addMembers.apply(rsrc, input); } - private void addIncludedGroups(GroupResource rsrc) - throws RestApiException, OrmException, IOException { - AddIncludedGroups.Input input = - AddIncludedGroups.Input.fromGroups( + private void addSubgroups(GroupResource rsrc) throws RestApiException, OrmException, IOException { + AddSubgroups.Input input = + AddSubgroups.Input.fromGroups( initialGroups.stream().map(AccountGroup.UUID::get).collect(toList())); - addIncludedGroups.apply(rsrc, input); + addSubgroups.apply(rsrc, input); } } diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetMembersCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetMembersCommand.java index a5ebaebd6c..9062b52eeb 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetMembersCommand.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/SetMembersCommand.java @@ -26,10 +26,10 @@ import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.server.account.AccountCache; import com.google.gerrit.server.account.GroupCache; -import com.google.gerrit.server.group.AddIncludedGroups; import com.google.gerrit.server.group.AddMembers; -import com.google.gerrit.server.group.DeleteIncludedGroups; +import com.google.gerrit.server.group.AddSubgroups; import com.google.gerrit.server.group.DeleteMembers; +import com.google.gerrit.server.group.DeleteSubgroups; import com.google.gerrit.server.group.GroupResource; import com.google.gerrit.server.group.GroupsCollection; import com.google.gerrit.server.group.InternalGroup; @@ -94,9 +94,9 @@ public class SetMembersCommand extends SshCommand { @Inject private DeleteMembers deleteMembers; - @Inject private AddIncludedGroups addIncludedGroups; + @Inject private AddSubgroups addSubgroups; - @Inject private DeleteIncludedGroups deleteIncludedGroups; + @Inject private DeleteSubgroups deleteSubgroups; @Inject private GroupsCollection groupsCollection; @@ -115,7 +115,7 @@ public class SetMembersCommand extends SshCommand { reportMembersAction("removed from", resource, accountsToRemove); } if (!groupsToRemove.isEmpty()) { - deleteIncludedGroups.apply(resource, fromGroups(groupsToRemove)); + deleteSubgroups.apply(resource, fromGroups(groupsToRemove)); reportGroupsAction("excluded from", resource, groupsToRemove); } if (!accountsToAdd.isEmpty()) { @@ -123,7 +123,7 @@ public class SetMembersCommand extends SshCommand { reportMembersAction("added to", resource, accountsToAdd); } if (!groupsToInclude.isEmpty()) { - addIncludedGroups.apply(resource, fromGroups(groupsToInclude)); + addSubgroups.apply(resource, fromGroups(groupsToInclude)); reportGroupsAction("included to", resource, groupsToInclude); } } @@ -160,9 +160,8 @@ public class SetMembersCommand extends SshCommand { String.format("Groups %s group %s: %s\n", action, group.getName(), names).getBytes(ENC)); } - private AddIncludedGroups.Input fromGroups(List accounts) { - return AddIncludedGroups.Input.fromGroups( - accounts.stream().map(Object::toString).collect(toList())); + private AddSubgroups.Input fromGroups(List accounts) { + return AddSubgroups.Input.fromGroups(accounts.stream().map(Object::toString).collect(toList())); } private AddMembers.Input fromMembers(List accounts) {