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

@@ -19,26 +19,29 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.server.account.GroupControl;
import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.inject.Inject;
public class GetOwner implements RestReadView<GroupResource> {
private final GroupControl.Factory controlFactory;
private final GroupJson json;
@Inject
GetOwner(GroupControl.Factory controlFactory) {
GetOwner(GroupControl.Factory controlFactory, GroupJson json) {
this.controlFactory = controlFactory;
this.json = json;
}
@Override
public Object apply(GroupResource resource) throws ResourceNotFoundException {
public GroupInfo apply(GroupResource resource) throws ResourceNotFoundException {
AccountGroup group = resource.toAccountGroup();
if (group == null) {
throw new ResourceNotFoundException();
}
try {
GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
return new GroupInfo(c.getGroup());
return json.format(c.getGroup());
} catch (NoSuchGroupException e) {
throw new ResourceNotFoundException();
}