ChangeUtil#findChanges: Use provided user for change controls

To instantiate the change controls for the found changes we should use
the user that was provided to the method, not the current user.

Change-Id: I882422f41c4e53335150afa22da6677d0dfb3adc
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-02-04 16:59:07 +01:00
parent f7ba00013d
commit f64480d28c

View File

@@ -351,7 +351,7 @@ public class ChangeUtil {
// Try isolated changeId // Try isolated changeId
if (!id.contains("~")) { if (!id.contains("~")) {
return asChangeControls(query.byKeyPrefix(id)); return asChangeControls(query.byKeyPrefix(id), user);
} }
// Try change triplet // Try change triplet
@@ -359,17 +359,18 @@ public class ChangeUtil {
if (triplet.isPresent()) { if (triplet.isPresent()) {
return asChangeControls(query.byBranchKey( return asChangeControls(query.byBranchKey(
triplet.get().branch(), triplet.get().branch(),
triplet.get().id())); triplet.get().id()),
user);
} }
return Collections.emptyList(); return Collections.emptyList();
} }
private List<ChangeControl> asChangeControls(List<ChangeData> cds) private List<ChangeControl> asChangeControls(List<ChangeData> cds,
throws OrmException { CurrentUser user) throws OrmException {
List<ChangeControl> ctls = new ArrayList<>(cds.size()); List<ChangeControl> ctls = new ArrayList<>(cds.size());
for (ChangeData cd : cds) { for (ChangeData cd : cds) {
ctls.add(cd.changeControl(user.get())); ctls.add(cd.changeControl(user));
} }
return ctls; return ctls;
} }