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: I912e56c2c2548303e3128ab4041072d51d388b46 Signe-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -15,16 +15,16 @@
|
||||
package com.google.gerrit.server.group;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
|
||||
class GetDescription implements RestReadView<GroupResource> {
|
||||
@Override
|
||||
public String apply(GroupResource resource) throws ResourceNotFoundException {
|
||||
public String apply(GroupResource resource) throws MethodNotAllowedException {
|
||||
AccountGroup group = resource.toAccountGroup();
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
return Strings.nullToEmpty(group.getDescription());
|
||||
}
|
||||
|
Reference in New Issue
Block a user