Merge "Remove old RPC for changing group description"

This commit is contained in:
David Pursehouse 2013-02-01 09:52:42 +00:00 committed by Gerrit Code Review
commit 57462b7766
2 changed files with 0 additions and 40 deletions

View File

@ -21,7 +21,6 @@ import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.RemoteJsonService;
import com.google.gwtjsonrpc.common.RpcImpl;
import com.google.gwtjsonrpc.common.RpcImpl.Version;
import com.google.gwtjsonrpc.common.VoidResult;
@RpcImpl(version = Version.V2_0)
public interface GroupAdminService extends RemoteJsonService {
@ -29,9 +28,4 @@ public interface GroupAdminService extends RemoteJsonService {
@SignInRequired
void groupDetail(AccountGroup.Id groupId, AccountGroup.UUID uuid,
AsyncCallback<GroupDetail> callback);
@Audit
@SignInRequired
void changeGroupDescription(AccountGroup.Id groupId, String description,
AsyncCallback<VoidResult> callback);
}

View File

@ -16,25 +16,18 @@ package com.google.gerrit.httpd.rpc.account;
import com.google.gerrit.common.data.GroupAdminService;
import com.google.gerrit.common.data.GroupDetail;
import com.google.gerrit.common.errors.NoSuchGroupException;
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupCache;
import com.google.gerrit.server.account.GroupControl;
import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.VoidResult;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import java.util.Collections;
class GroupAdminServiceImpl extends BaseServiceImplementation implements
GroupAdminService {
private final GroupCache groupCache;
private final GroupControl.Factory groupControlFactory;
private final GroupDetailHandler.Factory groupDetailFactory;
@ -42,11 +35,9 @@ class GroupAdminServiceImpl extends BaseServiceImplementation implements
GroupAdminServiceImpl(final Provider<ReviewDb> schema,
final Provider<IdentifiedUser> currentUser,
final GroupCache groupCache,
final GroupControl.Factory groupControlFactory,
final GroupDetailHandler.Factory groupDetailFactory) {
super(schema, currentUser);
this.groupCache = groupCache;
this.groupControlFactory = groupControlFactory;
this.groupDetailFactory = groupDetailFactory;
}
@ -60,29 +51,4 @@ class GroupAdminServiceImpl extends BaseServiceImplementation implements
}
groupDetailFactory.create(groupId).to(callback);
}
public void changeGroupDescription(final AccountGroup.Id groupId,
final String description, final AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>() {
public VoidResult run(final ReviewDb db) throws OrmException, Failure {
final AccountGroup group = db.accountGroups().get(groupId);
assertAmGroupOwner(db, group);
group.setDescription(description);
db.accountGroups().update(Collections.singleton(group));
groupCache.evict(group);
return VoidResult.INSTANCE;
}
});
}
private void assertAmGroupOwner(final ReviewDb db, final AccountGroup group)
throws Failure {
try {
if (!groupControlFactory.controlFor(group.getId()).isOwner()) {
throw new Failure(new NoSuchGroupException(group.getId()));
}
} catch (NoSuchGroupException e) {
throw new Failure(new NoSuchGroupException(group.getId()));
}
}
}