use of com.google.gerrit.sshd.BaseCommand.UnloggedFailure in project gerrit by GerritCodeReview.
the class ChangeArgumentParser method addChange.
public void addChange(String id, Map<Change.Id, ChangeResource> changes, ProjectControl projectControl, boolean useIndex) throws UnloggedFailure, OrmException {
List<ChangeControl> matched = useIndex ? changeFinder.find(id, currentUser) : changeFromNotesFactory(id, currentUser);
List<ChangeControl> toAdd = new ArrayList<>(changes.size());
boolean canMaintainServer;
try {
permissionBackend.user(currentUser).check(GlobalPermission.MAINTAIN_SERVER);
canMaintainServer = true;
} catch (AuthException | PermissionBackendException e) {
canMaintainServer = false;
}
for (ChangeControl ctl : matched) {
if (!changes.containsKey(ctl.getId()) && inProject(projectControl, ctl.getProject()) && (canMaintainServer || ctl.isVisible(db))) {
toAdd.add(ctl);
}
}
if (toAdd.isEmpty()) {
throw new UnloggedFailure(1, "\"" + id + "\" no such change");
} else if (toAdd.size() > 1) {
throw new UnloggedFailure(1, "\"" + id + "\" matches multiple changes");
}
ChangeControl ctl = toAdd.get(0);
changes.put(ctl.getId(), changesCollection.parse(ctl));
}
Aggregations