Ignore unknown groups when listing groups for projects
Using the '--project' option when listing groups it is possible to list groups for which any permission is set on this project. If a permission is assigned to a group that cannot be found in Gerrit we currently fail with '404 Not Found'. Using '404 Not Found' seems incorrect since this status code should only be used when the resource that was specified in the URL was not found. Change-Id: I5cef033c97618f03181d2c4aedfc3e8ad80d8c0c Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:

committed by
Gerrit Code Review

parent
e05ec7f9ff
commit
6f074f6523
@@ -26,7 +26,6 @@ import com.google.gerrit.common.groups.ListGroupsOption;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.gerrit.extensions.restapi.Url;
|
||||
@@ -146,7 +145,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
|
||||
new TypeToken<Map<String, GroupInfo>>() {}.getType());
|
||||
}
|
||||
|
||||
public List<GroupInfo> get() throws ResourceNotFoundException, OrmException {
|
||||
public List<GroupInfo> get() throws OrmException {
|
||||
List<GroupInfo> groupInfos;
|
||||
if (user != null) {
|
||||
if (owned) {
|
||||
@@ -166,10 +165,9 @@ public class ListGroups implements RestReadView<TopLevelResource> {
|
||||
final Set<GroupReference> groupsRefs = projectControl.getAllGroups();
|
||||
for (final GroupReference groupRef : groupsRefs) {
|
||||
final AccountGroup group = groupCache.get(groupRef.getUUID());
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException(groupRef.getUUID().get());
|
||||
if (group != null) {
|
||||
groups.put(group.getGroupUUID(), group);
|
||||
}
|
||||
groups.put(group.getGroupUUID(), group);
|
||||
}
|
||||
}
|
||||
groupList = filterGroups(groups.values());
|
||||
|
Reference in New Issue
Block a user