Remove unneeded exception declarations from REST handlers

Change-Id: I75a166d332aa153843fa363f9f54002e15f448bb
This commit is contained in:
David Ostrovsky 2015-10-10 10:10:23 +02:00
parent 6692661def
commit fb1ede5305
18 changed files with 29 additions and 52 deletions

View File

@ -20,7 +20,6 @@ import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.common.data.PermissionRule;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestApiException;
@ -172,7 +171,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
AddReviewerInput input = new AddReviewerInput();
input.reviewer = projectOwners;
reviewersProvider.get().apply(rsrc, input);
} catch (IOException | OrmException | RestApiException | EmailException e) {
} catch (IOException | OrmException | RestApiException e) {
// one of the owner groups is not visible to the user and this it why it
// can't be added as reviewer
}
@ -188,7 +187,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
AddReviewerInput input = new AddReviewerInput();
input.reviewer = r.getGroup().getUUID().get();
reviewersProvider.get().apply(rsrc, input);
} catch (IOException | OrmException | RestApiException | EmailException e) {
} catch (IOException | OrmException | RestApiException e) {
// ignore
}
}

View File

@ -14,7 +14,6 @@
package com.google.gerrit.server.api.changes;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.AbandonInput;
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.api.changes.ChangeApi;
@ -51,7 +50,6 @@ import com.google.gerrit.server.change.Revisions;
import com.google.gerrit.server.change.SubmittedTogether;
import com.google.gerrit.server.change.SuggestReviewers;
import com.google.gerrit.server.git.UpdateException;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
@ -180,7 +178,7 @@ class ChangeApiImpl implements ChangeApi {
public void restore(RestoreInput in) throws RestApiException {
try {
restore.apply(change, in);
} catch (OrmException | IOException | UpdateException e) {
} catch (OrmException | UpdateException e) {
throw new RestApiException("Cannot restore change", e);
}
}
@ -194,7 +192,7 @@ class ChangeApiImpl implements ChangeApi {
public ChangeApi revert(RevertInput in) throws RestApiException {
try {
return changeApi.id(revert.apply(change, in)._number);
} catch (OrmException | EmailException | IOException | UpdateException e) {
} catch (OrmException | IOException | UpdateException e) {
throw new RestApiException("Cannot revert change", e);
}
}
@ -219,7 +217,7 @@ class ChangeApiImpl implements ChangeApi {
in.topic = topic;
try {
putTopic.apply(change, in);
} catch (OrmException | IOException | UpdateException e) {
} catch (UpdateException e) {
throw new RestApiException("Cannot set topic", e);
}
}
@ -235,7 +233,7 @@ class ChangeApiImpl implements ChangeApi {
public void addReviewer(AddReviewerInput in) throws RestApiException {
try {
postReviewers.apply(change, in);
} catch (OrmException | EmailException | IOException e) {
} catch (OrmException | IOException e) {
throw new RestApiException("Cannot add change reviewer", e);
}
}
@ -292,7 +290,7 @@ class ChangeApiImpl implements ChangeApi {
try {
Response<EditInfo> edit = editDetail.apply(change);
return edit.isNone() ? null : edit.value();
} catch (IOException | OrmException | InvalidChangeOperationException e) {
} catch (IOException | OrmException e) {
throw new RestApiException("Cannot retrieve change edit", e);
}
}

View File

@ -212,7 +212,7 @@ class RevisionApiImpl implements RevisionApi {
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
try {
return changes.id(cherryPick.apply(revision, in)._number);
} catch (OrmException | EmailException | IOException | UpdateException e) {
} catch (OrmException | IOException | UpdateException e) {
throw new RestApiException("Cannot cherry pick", e);
}
}

View File

@ -272,8 +272,7 @@ public class ChangeEdits implements
@Override
public Response<EditInfo> apply(ChangeResource rsrc) throws AuthException,
IOException, InvalidChangeOperationException,
ResourceNotFoundException, OrmException {
IOException, ResourceNotFoundException, OrmException {
Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
if (!edit.isPresent()) {
return Response.none();
@ -382,7 +381,7 @@ public class ChangeEdits implements
@Override
public Response<?> apply(ChangeEditResource rsrc, Input input)
throws AuthException, ResourceConflictException, IOException {
throws AuthException, ResourceConflictException {
String path = rsrc.getPath();
if (Strings.isNullOrEmpty(path) || path.charAt(0) == '/') {
throw new ResourceConflictException("Invalid path: " + path);
@ -442,7 +441,7 @@ public class ChangeEdits implements
@Override
public Response<?> apply(ChangeEditResource rsrc)
throws ResourceNotFoundException, IOException {
throws IOException {
try {
return Response.ok(fileContentUtil.getContent(
rsrc.getControl().getProjectControl().getProjectState(),

View File

@ -14,7 +14,6 @@
package com.google.gerrit.server.change;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.CherryPickInput;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.restapi.AuthException;
@ -57,8 +56,7 @@ public class CherryPick implements RestModifyView<RevisionResource, CherryPickIn
@Override
public ChangeInfo apply(RevisionResource revision, CherryPickInput input)
throws OrmException, IOException, EmailException, UpdateException,
RestApiException {
throws OrmException, IOException, UpdateException, RestApiException {
final ChangeControl control = revision.getControl();
if (input.message == null || input.message.trim().isEmpty()) {

View File

@ -109,10 +109,9 @@ public class CreateChange implements
}
@Override
public Response<ChangeInfo> apply(TopLevelResource parent,
ChangeInfo input)
throws AuthException, OrmException, IOException,
InvalidChangeOperationException, RestApiException, UpdateException {
public Response<ChangeInfo> apply(TopLevelResource parent, ChangeInfo input)
throws OrmException, IOException, InvalidChangeOperationException,
RestApiException, UpdateException {
if (Strings.isNullOrEmpty(input.project)) {
throw new BadRequestException("project must be non-empty");
}

View File

@ -22,7 +22,6 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.server.change.DeleteChangeEdit.Input;
import com.google.gerrit.server.edit.ChangeEdit;
import com.google.gerrit.server.edit.ChangeEditUtil;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@ -42,8 +41,7 @@ public class DeleteChangeEdit implements RestModifyView<ChangeResource, Input> {
@Override
public Response<?> apply(ChangeResource rsrc, Input input)
throws AuthException, ResourceNotFoundException, IOException,
InvalidChangeOperationException {
throws AuthException, ResourceNotFoundException, IOException {
Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getChange());
if (edit.isPresent()) {
editUtil.delete(edit.get());

View File

@ -21,7 +21,6 @@ import com.google.common.collect.Maps;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.data.GroupDescription;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
import com.google.gerrit.extensions.restapi.AuthException;
@ -129,7 +128,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
@Override
public PostResult apply(ChangeResource rsrc, AddReviewerInput input)
throws AuthException, BadRequestException, UnprocessableEntityException,
OrmException, EmailException, IOException {
OrmException, IOException {
if (input.reviewer == null) {
throw new BadRequestException("missing reviewer field");
}

View File

@ -30,7 +30,6 @@ import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.server.edit.ChangeEdit;
import com.google.gerrit.server.edit.ChangeEditUtil;
import com.google.gerrit.server.git.UpdateException;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@ -85,8 +84,7 @@ public class PublishChangeEdit implements
@Override
public Response<?> apply(ChangeResource rsrc, Publish.Input in)
throws NoSuchProjectException,
IOException, InvalidChangeOperationException, OrmException,
throws NoSuchProjectException, IOException, OrmException,
RestApiException, UpdateException {
Capable r =
rsrc.getControl().getProjectControl().canPushToAtLeastOneRef();

View File

@ -40,7 +40,6 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.io.IOException;
import java.util.Collections;
@Singleton
@ -69,8 +68,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
@Override
public Response<String> apply(ChangeResource req, Input input)
throws AuthException, UpdateException, RestApiException, OrmException,
IOException {
throws UpdateException, RestApiException {
ChangeControl ctl = req.getControl();
if (!ctl.canEditTopicName()) {
throw new AuthException("changing topic not permitted");

View File

@ -47,7 +47,6 @@ import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
@Singleton
@ -78,9 +77,8 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>,
}
@Override
public ChangeInfo apply(ChangeResource req, final RestoreInput input)
throws AuthException, RestApiException, UpdateException, OrmException,
IOException {
public ChangeInfo apply(ChangeResource req, RestoreInput input)
throws RestApiException, UpdateException, OrmException {
ChangeControl ctl = req.getControl();
if (!ctl.canRestore()) {
throw new AuthException("restore not permitted");

View File

@ -16,7 +16,6 @@ package com.google.gerrit.server.change;
import com.google.common.base.Strings;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.errors.EmailException;
import com.google.gerrit.extensions.api.changes.RevertInput;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.restapi.AuthException;
@ -58,7 +57,7 @@ public class Revert implements RestModifyView<ChangeResource, RevertInput>,
@Override
public ChangeInfo apply(ChangeResource req, RevertInput input)
throws IOException, OrmException, EmailException, RestApiException,
throws IOException, OrmException, RestApiException,
UpdateException {
ChangeControl control = req.getControl();
Change change = req.getChange();

View File

@ -20,7 +20,6 @@ import com.google.common.collect.Maps;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.server.ReviewDb;
@ -70,7 +69,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
@Override
public List<Record> apply(RevisionResource rsrc, Input input)
throws AuthException, BadRequestException, OrmException {
throws AuthException, OrmException {
if (input == null) {
input = new Input();
}

View File

@ -22,7 +22,6 @@ import com.google.gerrit.extensions.annotations.RequiresAnyCapability;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
@ -68,9 +67,8 @@ public class PostCaches implements RestModifyView<ConfigResource, Input> {
}
@Override
public Object apply(ConfigResource rsrc, Input input) throws AuthException,
ResourceNotFoundException, BadRequestException,
UnprocessableEntityException {
public Object apply(ConfigResource rsrc, Input input)
throws AuthException, BadRequestException, UnprocessableEntityException {
if (input == null || input.operation == null) {
throw new BadRequestException("operation must be specified");
}

View File

@ -23,7 +23,6 @@ import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.groups.GroupInput;
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.RestModifyView;
@ -96,7 +95,7 @@ public class CreateGroup implements RestModifyView<TopLevelResource, GroupInput>
@Override
public GroupInfo apply(TopLevelResource resource, GroupInput input)
throws AuthException, BadRequestException, UnprocessableEntityException,
throws BadRequestException, UnprocessableEntityException,
ResourceConflictException, OrmException {
if (input == null) {
input = new GroupInput();

View File

@ -22,7 +22,6 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.DefaultInput;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.RestModifyView;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.AccountGroupName;
@ -71,8 +70,7 @@ public class PutName implements RestModifyView<GroupResource, Input> {
@Override
public String apply(GroupResource rsrc, Input input)
throws MethodNotAllowedException, AuthException, BadRequestException,
ResourceNotFoundException, ResourceConflictException, OrmException,
NoSuchGroupException {
ResourceConflictException, OrmException, NoSuchGroupException {
if (rsrc.toAccountGroup() == null) {
throw new MethodNotAllowedException();
} else if (!rsrc.getControl().isOwner()) {

View File

@ -60,7 +60,7 @@ public class BanCommit implements RestModifyView<ProjectResource, Input> {
@Override
public BanResultInfo apply(ProjectResource rsrc, Input input)
throws UnprocessableEntityException, AuthException,
ResourceConflictException, IOException, InterruptedException {
ResourceConflictException, IOException {
BanResultInfo r = new BanResultInfo();
if (input != null && input.commits != null && !input.commits.isEmpty()) {
List<ObjectId> commitsToBan = new ArrayList<>(input.commits.size());

View File

@ -71,7 +71,7 @@ public class BanCommitCommand extends SshCommand {
printCommits(r.newlyBanned, "The following commits were banned");
printCommits(r.alreadyBanned, "The following commits were already banned");
printCommits(r.ignored, "The following ids do not represent commits and were ignored");
} catch (RestApiException | IOException | InterruptedException e) {
} catch (RestApiException | IOException e) {
throw die(e);
}
}