Return specific types from REST API implementations where possible
Change-Id: I0e5d44ecd44dd1fba751030506e05d35ee63f862
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.extensions.api.accounts.AccountInput;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -23,7 +25,7 @@ import com.google.inject.Singleton;
|
||||
public class PutAccount
|
||||
implements RestModifyView<AccountResource, AccountInput> {
|
||||
@Override
|
||||
public Object apply(AccountResource resource, AccountInput input)
|
||||
public Response<AccountInfo> apply(AccountResource resource, AccountInput input)
|
||||
throws ResourceConflictException {
|
||||
throw new ResourceConflictException("account exists");
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.gerrit.extensions.restapi.AuthException;
|
||||
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.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -68,7 +69,7 @@ public class PutAgreement
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(AccountResource resource, AgreementInput input)
|
||||
public Response<String> apply(AccountResource resource, AgreementInput input)
|
||||
throws IOException, OrmException, RestApiException {
|
||||
if (!agreementsEnabled) {
|
||||
throw new MethodNotAllowedException("contributor agreements disabled");
|
||||
@@ -103,7 +104,7 @@ public class PutAgreement
|
||||
addMembers.addMembers(group.getId(), ImmutableList.of(account.getId()));
|
||||
agreementSignup.fire(account, agreementName);
|
||||
|
||||
return agreementName;
|
||||
return Response.ok(agreementName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.gerrit.extensions.api.projects.BranchInfo;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
@@ -23,7 +24,7 @@ import com.google.inject.Singleton;
|
||||
public class PutBranch implements RestModifyView<BranchResource, BranchInput> {
|
||||
|
||||
@Override
|
||||
public Object apply(BranchResource rsrc, BranchInput input)
|
||||
public BranchInfo apply(BranchResource rsrc, BranchInput input)
|
||||
throws ResourceConflictException {
|
||||
throw new ResourceConflictException("Branch \"" + rsrc.getBranchInfo().ref
|
||||
+ "\" already exists");
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
@@ -21,7 +22,7 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
public class PutTag implements RestModifyView<TagResource, TagInput> {
|
||||
|
||||
@Override
|
||||
public Object apply(TagResource resource, TagInput input)
|
||||
public TagInfo apply(TagResource resource, TagInput input)
|
||||
throws ResourceConflictException {
|
||||
throw new ResourceConflictException("Tag \"" + resource.getTagInfo().ref
|
||||
+ "\" already exists");
|
||||
|
||||
@@ -20,7 +20,9 @@ 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.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.project.DashboardsCollection.DashboardInfo;
|
||||
import com.google.gerrit.server.project.SetDashboard.Input;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -44,7 +46,7 @@ class SetDashboard implements RestModifyView<DashboardResource, Input> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(DashboardResource resource, Input input)
|
||||
public Response<DashboardInfo> apply(DashboardResource resource, Input input)
|
||||
throws AuthException, BadRequestException, ResourceConflictException,
|
||||
MethodNotAllowedException, ResourceNotFoundException, IOException {
|
||||
if (resource.isProjectDefault()) {
|
||||
|
||||
Reference in New Issue
Block a user