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:
Edwin Kempin
2013-03-06 15:00:54 +01:00
parent d4e95e31ff
commit 1f3fcf763b
2 changed files with 6 additions and 4 deletions

View File

@@ -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();

View File

@@ -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 =