For external group fail with 405 if group endpoint expects internal group
Some group REST endpoints are only supported for internal groups. If such an endpoint is invoked for an external group always fail with '405 Method Not Allowed'. 405 makes sense since under /groups/<group-id> all groups are accessible and only some views under this URL are not supported for external groups. Change-Id: I9050fb46558e994f0700fe5095411d7beaae64d1 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.common.base.Strings.nullToEmpty;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroupIncludeByUuid;
|
||||
@@ -51,9 +52,9 @@ public class ListIncludedGroups implements RestReadView<GroupResource> {
|
||||
|
||||
@Override
|
||||
public List<GroupInfo> apply(GroupResource rsrc)
|
||||
throws ResourceNotFoundException, OrmException {
|
||||
throws MethodNotAllowedException, ResourceNotFoundException, OrmException {
|
||||
if (rsrc.toAccountGroup() == null) {
|
||||
throw new ResourceNotFoundException(rsrc.getGroupUUID().get());
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
|
||||
boolean ownerOfParent = rsrc.getControl().isOwner();
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.data.GroupDetail;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -59,9 +60,9 @@ public class ListMembers implements RestReadView<GroupResource> {
|
||||
|
||||
@Override
|
||||
public List<AccountInfo> apply(final GroupResource resource)
|
||||
throws ResourceNotFoundException, OrmException {
|
||||
throws MethodNotAllowedException, ResourceNotFoundException, OrmException {
|
||||
if (resource.toAccountGroup() == null) {
|
||||
throw new ResourceNotFoundException(resource.getGroupUUID().get());
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
try {
|
||||
final Map<Account.Id, AccountInfo> members =
|
||||
|
||||
Reference in New Issue
Block a user