MergeValidators: Don't assume submitter record exists

Since submit and merge now happens in a single update, there is no
submitter record during MergeOp#validateChangeList where this is
called, so this check will never find a submitter. Instead, just check
if the caller is an administrator; this is the same identity that
would eventually get written to the submitter record later in the
process.

Change-Id: I7e3e20a0db74aba18e7957a349c183dd01af07a6
This commit is contained in:
Dave Borowitz
2016-02-12 11:07:09 -05:00
parent df50b2327f
commit 8e3e0f73cc

View File

@@ -99,7 +99,6 @@ public class MergeValidators {
private final AllProjectsName allProjectsName;
private final ReviewDb db;
private final ProjectCache projectCache;
private final IdentifiedUser.GenericFactory identifiedUserFactory;
private final ApprovalsUtil approvalsUtil;
private final DynamicMap<ProjectConfigEntry> pluginConfigEntries;
@@ -110,13 +109,11 @@ public class MergeValidators {
@Inject
public ProjectConfigValidator(AllProjectsName allProjectsName,
ReviewDb db, ProjectCache projectCache,
IdentifiedUser.GenericFactory iuf,
ApprovalsUtil approvalsUtil,
DynamicMap<ProjectConfigEntry> pluginConfigEntries) {
this.allProjectsName = allProjectsName;
this.db = db;
this.projectCache = projectCache;
this.identifiedUserFactory = iuf;
this.approvalsUtil = approvalsUtil;
this.pluginConfigEntries = pluginConfigEntries;
}
@@ -150,9 +147,7 @@ public class MergeValidators {
if (psa == null) {
throw new MergeValidationException(SET_BY_ADMIN);
}
final IdentifiedUser submitter =
identifiedUserFactory.create(psa.getAccountId());
if (!submitter.getCapabilities().canAdministrateServer()) {
if (!caller.getCapabilities().canAdministrateServer()) {
throw new MergeValidationException(SET_BY_ADMIN);
}