Replace account.AccountInfo with extensions.common.AccountInfo

These have identical public fields; the only difference is that
AccountInfo.Loader was using the transient _id field store the ID
before filling in values. We can instead reuse the Integer _accountId
field for this purpose. This may incur an additional boxing or so per
account per request, but that cost should be negligible given how
many allocations we do per request already.

AccountInfoMapper is no longer required, so remove that entirely.

We are now enforcing that AccountInfos passed to the loader have an
_accountId. Since by default the old account.AccountInfo worked
without an _accountId, add this as a separate FillOption and clear it
if that option is not set. To verify this, check the owner fields in
ChangeIT#get.

Change-Id: Ied01750485cc728e91e585a31f3db8863bae7e40
This commit is contained in:
Dave Borowitz
2014-11-25 14:41:05 -05:00
parent 5df54ae192
commit 54ba43a51d
34 changed files with 259 additions and 272 deletions

View File

@@ -23,12 +23,13 @@ import com.google.gerrit.common.data.LabelTypes;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.common.data.PermissionRange;
import com.google.gerrit.common.data.SubmitRecord;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.PatchSetApproval;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.account.AccountInfo;
import com.google.gerrit.server.account.AccountLoader;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.SubmitRuleEvaluator;
import com.google.gerrit.server.query.change.ChangeData;
@@ -47,13 +48,13 @@ public class ReviewerJson {
private final Provider<ReviewDb> db;
private final ChangeData.Factory changeDataFactory;
private final ApprovalsUtil approvalsUtil;
private final AccountInfo.Loader.Factory accountLoaderFactory;
private final AccountLoader.Factory accountLoaderFactory;
@Inject
ReviewerJson(Provider<ReviewDb> db,
ChangeData.Factory changeDataFactory,
ApprovalsUtil approvalsUtil,
AccountInfo.Loader.Factory accountLoaderFactory) {
AccountLoader.Factory accountLoaderFactory) {
this.db = db;
this.changeDataFactory = changeDataFactory;
this.approvalsUtil = approvalsUtil;
@@ -63,7 +64,7 @@ public class ReviewerJson {
public List<ReviewerInfo> format(Collection<ReviewerResource> rsrcs)
throws OrmException {
List<ReviewerInfo> infos = Lists.newArrayListWithCapacity(rsrcs.size());
AccountInfo.Loader loader = accountLoaderFactory.create(true);
AccountLoader loader = accountLoaderFactory.create(true);
for (ReviewerResource rsrc : rsrcs) {
ReviewerInfo info = format(new ReviewerInfo(
rsrc.getUser().getAccountId()),
@@ -82,7 +83,8 @@ public class ReviewerJson {
public ReviewerInfo format(ReviewerInfo out, ChangeControl ctl) throws OrmException {
PatchSet.Id psId = ctl.getChange().currentPatchSetId();
return format(out, ctl,
approvalsUtil.byPatchSetUser(db.get(), ctl, psId, out._id));
approvalsUtil.byPatchSetUser(db.get(), ctl, psId,
new Account.Id(out._accountId)));
}
public ReviewerInfo format(ReviewerInfo out, ChangeControl ctl,
@@ -136,7 +138,7 @@ public class ReviewerJson {
Map<String, String> approvals;
protected ReviewerInfo(Account.Id id) {
super(id);
super(id.get());
}
}