Cleanup implementation of REST views
- specify return type if possible - remove unnecessary throw declarations - convert some of the thrown exceptions to RestExceptions - do not throw Exception but specific exceptions - sort throw declarations (first RestExceptions, then other exceptions) Having explicit return types and exceptions makes it easier to programatically invoke the REST views, e.g. if a plugin wants to add a REST view that wraps a Gerrit core REST view. Change-Id: I5c59553b6cfad457f7ec037cceb08936247bf8e8 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -19,11 +19,14 @@ 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.server.project.SetDashboard.Input;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
class SetDashboard implements RestModifyView<DashboardResource, Input> {
|
||||
static class Input {
|
||||
@DefaultInput
|
||||
@@ -41,7 +44,7 @@ class SetDashboard implements RestModifyView<DashboardResource, Input> {
|
||||
@Override
|
||||
public Object apply(DashboardResource resource, Input input)
|
||||
throws AuthException, BadRequestException, ResourceConflictException,
|
||||
Exception {
|
||||
MethodNotAllowedException, ResourceNotFoundException, IOException {
|
||||
if (resource.isProjectDefault()) {
|
||||
return defaultSetter.get().apply(resource, input);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user