Resolve non-internal group owners

When a group is owned by an external group the reference must be
resolved using a GroupBackend and not the GroupCache. This allows
the backend to supply the name for the UUID.

Change-Id: I2565357362b8295d2ae8fd3bf9a644f22ce896b2
This commit is contained in:
Shawn Pearce
2013-03-12 21:57:52 -07:00
parent 5c55655b09
commit c4bb89050a

View File

@@ -25,7 +25,7 @@ import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.AccountInfo; import com.google.gerrit.server.account.AccountInfo;
import com.google.gerrit.server.account.GroupCache; import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupControl; import com.google.gerrit.server.account.GroupControl;
import com.google.gwtorm.server.OrmException; import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject; import com.google.inject.Inject;
@@ -36,17 +36,18 @@ import java.util.EnumSet;
import java.util.List; import java.util.List;
public class GroupJson { public class GroupJson {
private final GroupCache groupCache; private final GroupBackend groupBackend;
private final GroupControl.Factory groupControlFactory; private final GroupControl.Factory groupControlFactory;
private final Provider<ListMembers> listMembers; private final Provider<ListMembers> listMembers;
private final Provider<ListIncludedGroups> listIncludes; private final Provider<ListIncludedGroups> listIncludes;
private EnumSet<ListGroupsOption> options; private EnumSet<ListGroupsOption> options;
@Inject @Inject
GroupJson(GroupCache groupCache, GroupControl.Factory groupControlFactory, GroupJson(GroupBackend groupBackend,
GroupControl.Factory groupControlFactory,
Provider<ListMembers> listMembers, Provider<ListMembers> listMembers,
Provider<ListIncludedGroups> listIncludes) { Provider<ListIncludedGroups> listIncludes) {
this.groupCache = groupCache; this.groupBackend = groupBackend;
this.groupControlFactory = groupControlFactory; this.groupControlFactory = groupControlFactory;
this.listMembers = listMembers; this.listMembers = listMembers;
this.listIncludes = listIncludes; this.listIncludes = listIncludes;
@@ -93,7 +94,7 @@ public class GroupJson {
info.groupId = g.getId().get(); info.groupId = g.getId().get();
if (g.getOwnerGroupUUID() != null) { if (g.getOwnerGroupUUID() != null) {
info.ownerId = Url.encode(g.getOwnerGroupUUID().get()); info.ownerId = Url.encode(g.getOwnerGroupUUID().get());
AccountGroup o = groupCache.get(g.getOwnerGroupUUID()); GroupDescription.Basic o = groupBackend.get(g.getOwnerGroupUUID());
if (o != null) { if (o != null) {
info.owner = o.getName(); info.owner = o.getName();
} }