use of com.google.gerrit.server.update.BatchUpdate in project gerrit by GerritCodeReview.
the class DraftChangeIT method markChangeAsDraft.
private void markChangeAsDraft(Change.Id id) throws Exception {
try (BatchUpdate batchUpdate = batchUpdateFactory.create(db, project, atrScope.get().getUser(), TimeUtil.nowTs())) {
batchUpdate.addOp(id, new MarkChangeAsDraftUpdateOp());
batchUpdate.execute();
}
ChangeStatus changeStatus = gApi.changes().id(id.get()).get().status;
assertThat(changeStatus).isEqualTo(ChangeStatus.DRAFT);
}
use of com.google.gerrit.server.update.BatchUpdate in project gerrit by GerritCodeReview.
the class GetRelatedIT method clearGroups.
private void clearGroups(final PatchSet.Id psId) throws Exception {
try (BatchUpdate bu = batchUpdateFactory.create(db, project, user(user), TimeUtil.nowTs())) {
bu.addOp(psId.getParentKey(), new BatchUpdateOp() {
@Override
public boolean updateChange(ChangeContext ctx) throws OrmException {
PatchSet ps = psUtil.get(ctx.getDb(), ctx.getNotes(), psId);
psUtil.setGroups(ctx.getDb(), ctx.getUpdate(psId), ps, ImmutableList.<String>of());
ctx.dontBumpLastUpdatedOn();
return true;
}
});
bu.execute();
}
}
use of com.google.gerrit.server.update.BatchUpdate in project gerrit by GerritCodeReview.
the class ConsistencyCheckerIT method incrementPatchSet.
private ChangeControl incrementPatchSet(ChangeControl ctl, RevCommit commit) throws Exception {
PatchSetInserter ins;
try (BatchUpdate bu = newUpdate(ctl.getChange().getOwner())) {
ins = patchSetInserterFactory.create(ctl, nextPatchSetId(ctl), commit).setValidate(false).setFireRevisionCreated(false).setNotify(NotifyHandling.NONE);
bu.addOp(ctl.getId(), ins).execute();
}
return reload(ctl);
}
use of com.google.gerrit.server.update.BatchUpdate in project gerrit by GerritCodeReview.
the class PostHashtags method applyImpl.
@Override
protected Response<ImmutableSortedSet<String>> applyImpl(BatchUpdate.Factory updateFactory, ChangeResource req, HashtagsInput input) throws RestApiException, UpdateException, PermissionBackendException {
req.permissions().check(ChangePermission.EDIT_HASHTAGS);
try (BatchUpdate bu = updateFactory.create(db.get(), req.getChange().getProject(), req.getControl().getUser(), TimeUtil.nowTs())) {
SetHashtagsOp op = hashtagsFactory.create(input);
bu.addOp(req.getId(), op);
bu.execute();
return Response.<ImmutableSortedSet<String>>ok(op.getUpdatedHashtags());
}
}
use of com.google.gerrit.server.update.BatchUpdate in project gerrit by GerritCodeReview.
the class PostPrivate method applyImpl.
@Override
public Response<String> applyImpl(BatchUpdate.Factory updateFactory, ChangeResource rsrc, SetPrivateOp.Input input) throws RestApiException, UpdateException {
if (!canSetPrivate(rsrc)) {
throw new AuthException("not allowed to mark private");
}
if (rsrc.getChange().isPrivate()) {
return Response.ok("");
}
ChangeControl control = rsrc.getControl();
SetPrivateOp op = new SetPrivateOp(cmUtil, true, input);
try (BatchUpdate u = updateFactory.create(dbProvider.get(), control.getProject().getNameKey(), control.getUser(), TimeUtil.nowTs())) {
u.addOp(control.getId(), op).execute();
}
return Response.created("");
}
Aggregations