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: Id8be7db496197598651775fa2c6458c83b9ca4b4 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
committed by
Shawn Pearce
parent
9169cb1a03
commit
e05ec7f9ff
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.group;
|
||||
|
||||
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.AccountGroup;
|
||||
@@ -36,10 +37,10 @@ public class GetOwner implements RestReadView<GroupResource> {
|
||||
|
||||
@Override
|
||||
public GroupInfo apply(GroupResource resource)
|
||||
throws ResourceNotFoundException, OrmException {
|
||||
throws MethodNotAllowedException, ResourceNotFoundException, OrmException {
|
||||
AccountGroup group = resource.toAccountGroup();
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
try {
|
||||
GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.restapi.AcceptsCreate;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
@@ -59,10 +60,11 @@ public class IncludedGroupsCollection implements
|
||||
|
||||
@Override
|
||||
public IncludedGroupResource parse(GroupResource resource, IdString id)
|
||||
throws AuthException, ResourceNotFoundException, OrmException {
|
||||
throws MethodNotAllowedException, AuthException,
|
||||
ResourceNotFoundException, OrmException {
|
||||
AccountGroup parent = resource.toAccountGroup();
|
||||
if (parent == null) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
|
||||
GroupDescription.Basic member =
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.gerrit.extensions.restapi.AcceptsCreate;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
@@ -61,9 +62,10 @@ public class MembersCollection implements
|
||||
|
||||
@Override
|
||||
public MemberResource parse(GroupResource parent, IdString id)
|
||||
throws AuthException, ResourceNotFoundException, OrmException {
|
||||
throws MethodNotAllowedException, AuthException,
|
||||
ResourceNotFoundException, OrmException {
|
||||
if (parent.toAccountGroup() == null) {
|
||||
throw new ResourceNotFoundException(id);
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
|
||||
IdentifiedUser user = accounts.get().parse(TopLevelResource.INSTANCE, id).getUser();
|
||||
|
||||
Reference in New Issue
Block a user