use of com.google.gerrit.server.change.RemoveFromAttentionSetOp in project gerrit by GerritCodeReview.
the class RemoveFromAttentionSet method apply.
@Override
public Response<Object> apply(AttentionSetEntryResource attentionResource, AttentionSetInput input) throws RestApiException, PermissionBackendException, IOException, ConfigInvalidException, UpdateException {
if (input == null) {
throw new BadRequestException("input may not be null");
}
input.reason = Strings.nullToEmpty(input.reason).trim();
if (input.reason.isEmpty()) {
throw new BadRequestException("missing field: reason");
}
input.user = Strings.nullToEmpty(input.user).trim();
if (!input.user.isEmpty()) {
Account.Id attentionUserId = AttentionSetUtil.resolveAccount(accountResolver, attentionResource.getChangeResource().getNotes(), input.user);
if (attentionUserId.get() != attentionResource.getAccountId().get()) {
throw new BadRequestException("The field \"user\" must be empty, or must match the user specified in the URL.");
}
}
ChangeResource changeResource = attentionResource.getChangeResource();
try (BatchUpdate bu = updateFactory.create(changeResource.getProject(), changeResource.getUser(), TimeUtil.now())) {
RemoveFromAttentionSetOp op = opFactory.create(attentionResource.getAccountId(), 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.none();
}
use of com.google.gerrit.server.change.RemoveFromAttentionSetOp in project gerrit by GerritCodeReview.
the class ReplyAttentionSetUpdates method removeFromAttentionSet.
/**
* Removes the user from the attention set
*
* @param bu BatchUpdate to perform the updates to the attention set.
* @param changeNotes current change.
* @param user user to add remove from the attention set.
* @param reason reason for removing.
* @param notify whether or not to notify about this removal.
*/
private void removeFromAttentionSet(BatchUpdate bu, ChangeNotes changeNotes, Account.Id user, String reason, boolean notify) {
RemoveFromAttentionSetOp removeFromAttentionSetOp = removeFromAttentionSetOpFactory.create(user, reason, notify);
bu.addOp(changeNotes.getChangeId(), removeFromAttentionSetOp);
}
Aggregations