Fix compile errors caused by MethodNotAllowedException

Change-Id: I18ae7b5c13a10f13bfce6afbe3094280f6c5c386
This commit is contained in:
Shawn Pearce
2013-03-07 09:04:23 -08:00
parent 4abbb1a8ad
commit 2ba90497bc
10 changed files with 25 additions and 14 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.server.account;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.gerrit.common.errors.NoSuchGroupException; 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.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Account;
@@ -40,7 +41,7 @@ public class GetGroups implements RestReadView<AccountResource> {
@Override @Override
public List<GroupInfo> apply(AccountResource resource) public List<GroupInfo> apply(AccountResource resource)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
IdentifiedUser user = resource.getUser(); IdentifiedUser user = resource.getUser();
Account.Id userId = user.getAccountId(); Account.Id userId = user.getAccountId();
List<GroupInfo> groups = Lists.newArrayList(); List<GroupInfo> groups = Lists.newArrayList();

View File

@@ -179,7 +179,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
@Override @Override
public Object apply(IncludedGroupResource resource, public Object apply(IncludedGroupResource resource,
PutIncludedGroup.Input input) throws ResourceNotFoundException, PutIncludedGroup.Input input) throws ResourceNotFoundException,
OrmException { MethodNotAllowedException, OrmException {
// Do nothing, the group is already included. // Do nothing, the group is already included.
return get.get().apply(resource); return get.get().apply(resource);
} }

View File

@@ -24,6 +24,7 @@ import com.google.gerrit.common.errors.PermissionDeniedException;
import com.google.gerrit.extensions.annotations.RequiresCapability; import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView; import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.TopLevelResource; import com.google.gerrit.extensions.restapi.TopLevelResource;
@@ -79,7 +80,7 @@ class CreateGroup implements RestModifyView<TopLevelResource, Input> {
@Override @Override
public GroupInfo apply(TopLevelResource resource, Input input) public GroupInfo apply(TopLevelResource resource, Input input)
throws ResourceNotFoundException, AuthException, BadRequestException, throws ResourceNotFoundException, AuthException, BadRequestException,
OrmException, NameAlreadyUsedException { NameAlreadyUsedException, MethodNotAllowedException, OrmException {
if (input == null) { if (input == null) {
input = new Input(); input = new Input();
} }

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.gerrit.common.groups.ListGroupsOption; import com.google.gerrit.common.groups.ListGroupsOption;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
@@ -32,7 +33,7 @@ public class GetDetail implements RestReadView<GroupResource> {
@Override @Override
public GroupInfo apply(GroupResource rsrc) throws ResourceNotFoundException, public GroupInfo apply(GroupResource rsrc) throws ResourceNotFoundException,
OrmException { MethodNotAllowedException, OrmException {
return json.format(rsrc); return json.format(rsrc);
} }
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
@@ -30,7 +31,7 @@ class GetGroup implements RestReadView<GroupResource> {
@Override @Override
public GroupInfo apply(GroupResource resource) public GroupInfo apply(GroupResource resource)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
return json.format(resource.getGroup()); return json.format(resource.getGroup());
} }
} }

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.group.GroupJson.GroupInfo; import com.google.gerrit.server.group.GroupJson.GroupInfo;
@@ -30,7 +31,7 @@ public class GetIncludedGroup implements RestReadView<IncludedGroupResource> {
@Override @Override
public GroupInfo apply(IncludedGroupResource rsrc) public GroupInfo apply(IncludedGroupResource rsrc)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
return json.format(rsrc.getMemberDescription()); return json.format(rsrc.getMemberDescription());
} }
} }

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.group; package com.google.gerrit.server.group;
import com.google.gerrit.common.errors.NoSuchGroupException; 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.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -36,7 +37,7 @@ public class GetOwner implements RestReadView<GroupResource> {
@Override @Override
public GroupInfo apply(GroupResource resource) public GroupInfo apply(GroupResource resource)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
AccountGroup group = resource.toAccountGroup(); AccountGroup group = resource.toAccountGroup();
if (group == null) { if (group == null) {
throw new ResourceNotFoundException(); throw new ResourceNotFoundException();

View File

@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.data.GroupDescriptions; import com.google.gerrit.common.data.GroupDescriptions;
import com.google.gerrit.common.groups.ListGroupsOption; import com.google.gerrit.common.groups.ListGroupsOption;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -64,15 +65,15 @@ public class GroupJson {
return this; return this;
} }
public GroupInfo format(GroupResource rsrc) throws ResourceNotFoundException, public GroupInfo format(GroupResource rsrc)
OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
GroupInfo info = init(rsrc.getGroup()); GroupInfo info = init(rsrc.getGroup());
initMembersAndIncludes(rsrc, info); initMembersAndIncludes(rsrc, info);
return info; return info;
} }
public GroupInfo format(GroupDescription.Basic group) public GroupInfo format(GroupDescription.Basic group)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
GroupInfo info = init(group); GroupInfo info = init(group);
if (options.contains(MEMBERS) || options.contains(INCLUDES)) { if (options.contains(MEMBERS) || options.contains(INCLUDES)) {
GroupResource rsrc = GroupResource rsrc =
@@ -106,7 +107,7 @@ public class GroupJson {
} }
private GroupInfo initMembersAndIncludes(GroupResource rsrc, GroupInfo info) private GroupInfo initMembersAndIncludes(GroupResource rsrc, GroupInfo info)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
if (options.contains(MEMBERS)) { if (options.contains(MEMBERS)) {
info.members = listMembers.get().apply(rsrc); info.members = listMembers.get().apply(rsrc);
} }

View File

@@ -25,6 +25,7 @@ import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.common.groups.ListGroupsOption; import com.google.gerrit.common.groups.ListGroupsOption;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException; import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestReadView; import com.google.gerrit.extensions.restapi.RestReadView;
@@ -146,7 +147,8 @@ public class ListGroups implements RestReadView<TopLevelResource> {
new TypeToken<Map<String, GroupInfo>>() {}.getType()); new TypeToken<Map<String, GroupInfo>>() {}.getType());
} }
public List<GroupInfo> get() throws ResourceNotFoundException, OrmException { public List<GroupInfo> get() throws ResourceNotFoundException,
MethodNotAllowedException, OrmException {
List<GroupInfo> groupInfos; List<GroupInfo> groupInfos;
if (user != null) { if (user != null) {
if (owned) { if (owned) {
@@ -187,7 +189,7 @@ public class ListGroups implements RestReadView<TopLevelResource> {
} }
private List<GroupInfo> getGroupsOwnedBy(IdentifiedUser user) private List<GroupInfo> getGroupsOwnedBy(IdentifiedUser user)
throws ResourceNotFoundException, OrmException { throws ResourceNotFoundException, MethodNotAllowedException, OrmException {
List<GroupInfo> groups = Lists.newArrayList(); List<GroupInfo> groups = Lists.newArrayList();
for (AccountGroup g : filterGroups(groupCache.all())) { for (AccountGroup g : filterGroups(groupCache.all())) {
GroupControl ctl = groupControlFactory.controlFor(g); GroupControl ctl = groupControlFactory.controlFor(g);

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.sshd.commands;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException; import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Url; import com.google.gerrit.extensions.restapi.Url;
import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -81,7 +82,8 @@ public class ListGroupsCommand extends BaseCommand {
identifiedUser, userFactory, accountGetGroups, json); identifiedUser, userFactory, accountGetGroups, json);
} }
void display(final PrintWriter out) throws ResourceNotFoundException, OrmException { void display(final PrintWriter out) throws ResourceNotFoundException,
MethodNotAllowedException, OrmException {
final ColumnFormatter formatter = new ColumnFormatter(out, '\t'); final ColumnFormatter formatter = new ColumnFormatter(out, '\t');
for (final GroupInfo info : get()) { for (final GroupInfo info : get()) {
formatter.addColumn(Objects.firstNonNull(info.name, "n/a")); formatter.addColumn(Objects.firstNonNull(info.name, "n/a"));