Include name of owner group into GroupInfo

The GroupInfo only contained the UUID of the owner group. Now in
addition the name of the owner group is included. This saves one
request when displaying the group info in the UI since there is no
need to fetch the name of the owner group with an own request. This
also fixes a wrong message in the UI. When the owner group was not
visible the name of the owner group could not be looked up and the UI
told it's a deleted reference.

Change-Id: I36082fb693a5b83bae26232a5de606d27956e220
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-02-11 12:39:13 +01:00
parent f807bc3836
commit c6993fb005
16 changed files with 157 additions and 100 deletions

View File

@@ -23,6 +23,7 @@ import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.AccountGroupIncludeByUuid;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.account.GroupControl;
import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -38,12 +39,14 @@ public class ListIncludedGroups implements RestReadView<GroupResource> {
private final GroupControl.Factory controlFactory;
private final Provider<ReviewDb> dbProvider;
private final GroupJson json;
@Inject
ListIncludedGroups(GroupControl.Factory controlFactory,
Provider<ReviewDb> dbProvider) {
Provider<ReviewDb> dbProvider, GroupJson json) {
this.controlFactory = controlFactory;
this.dbProvider = dbProvider;
this.json = json;
}
@Override
@@ -61,7 +64,7 @@ public class ListIncludedGroups implements RestReadView<GroupResource> {
try {
GroupControl i = controlFactory.controlFor(u.getIncludeUUID());
if (ownerOfParent || i.isVisible()) {
included.add(new GroupInfo(i.getGroup()));
included.add(json.format(i.getGroup()));
}
} catch (NoSuchGroupException notFound) {
log.warn(String.format("Group %s no longer available, included into ",