Add direct members and directly included groups to GroupInfo

When listing groups it is now possible to request that the direct group
members and the directly included groups are included into the returned
GroupInfos. This is done by setting the options 'o=MEMBERS' and
'o=INCLUDES'.

In addition there is a new REST endpoint '/groups/<group-id>/detail' by
which a group with its direct members and directly included groups can
be retrieved.

This new endpoint is used to retrieve the group for populating the
AccountGroupMembersScreen. By this 2 requests are saved which would
otherwise be needed to fetch the direct group members and the directly
included groups.

Change-Id: Ib94e5c01cc0880aa508f703f4156ac7fe627d742
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2013-02-11 15:30:19 +01:00
parent 963dfd07d0
commit abaab54633
18 changed files with 331 additions and 55 deletions

View File

@@ -0,0 +1,38 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.group;
import com.google.gerrit.common.groups.ListGroupsOption;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.group.GroupJson.GroupInfo;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
public class GetDetail implements RestReadView<GroupResource> {
private final GroupJson json;
@Inject
GetDetail(GroupJson json) {
this.json = json.addOption(ListGroupsOption.MEMBERS)
.addOption(ListGroupsOption.INCLUDES);
}
@Override
public GroupInfo apply(GroupResource rsrc) throws ResourceNotFoundException,
OrmException {
return json.format(rsrc);
}
}