use of com.google.gerrit.server.change.AddToAttentionSetOp in project gerrit by GerritCodeReview.
the class ReplyAttentionSetUpdates method addToAttentionSet.
/**
* Adds the user to the attention set
*
* @param bu BatchUpdate to perform the updates to the attention set
* @param changeNotes current change
* @param user user to add to the attention set
* @param reason reason for adding
* @param notify whether or not to notify about this addition
*/
private void addToAttentionSet(BatchUpdate bu, ChangeNotes changeNotes, Account.Id user, String reason, boolean notify) {
AddToAttentionSetOp addOwnerToAttentionSet = addToAttentionSetOpFactory.create(user, reason, notify);
bu.addOp(changeNotes.getChangeId(), addOwnerToAttentionSet);
}
use of com.google.gerrit.server.change.AddToAttentionSetOp in project gerrit by GerritCodeReview.
the class AddToAttentionSet method apply.
@Override
public Response<AccountInfo> apply(ChangeResource changeResource, AttentionSetInput input) throws Exception {
AttentionSetUtil.validateInput(input);
Account.Id attentionUserId = AttentionSetUtil.resolveAccount(accountResolver, changeResource.getNotes(), input.user);
if (serviceUserClassifier.isServiceUser(attentionUserId)) {
throw new BadRequestException(String.format("%s is a robot, and robots can't be added to the attention set.", input.user));
}
try {
permissionBackend.absentUser(attentionUserId).change(changeResource.getNotes()).check(ChangePermission.READ);
} catch (AuthException e) {
throw new AuthException("read not permitted for " + attentionUserId, e);
}
try (BatchUpdate bu = updateFactory.create(changeResource.getChange().getProject(), changeResource.getUser(), TimeUtil.now())) {
AddToAttentionSetOp op = opFactory.create(attentionUserId, input.reason, true);
bu.addOp(changeResource.getId(), op);
NotifyHandling notify = input.notify == null ? NotifyHandling.OWNER : input.notify;
NotifyResolver.Result notifyResult = notifyResolver.resolve(notify, input.notifyDetails);
bu.setNotify(notifyResult);
bu.execute();
return Response.ok(accountLoaderFactory.create(true).fillOne(attentionUserId));
}
}
Aggregations