Search in sources :

Example 1 with AssigneeValidationListener

use of com.google.gerrit.server.validators.AssigneeValidationListener in project gerrit by GerritCodeReview.

the class SetAssigneeOp method updateChange.

@Override
public boolean updateChange(ChangeContext ctx) throws OrmException, RestApiException {
    change = ctx.getChange();
    if (newAssignee.getAccountId().equals(change.getAssignee())) {
        return false;
    }
    try {
        for (AssigneeValidationListener validator : validationListeners) {
            validator.validateAssignee(change, newAssignee.getAccount());
        }
    } catch (ValidationException e) {
        throw new ResourceConflictException(e.getMessage());
    }
    if (change.getAssignee() != null) {
        oldAssignee = userFactory.create(change.getAssignee());
    }
    ChangeUpdate update = ctx.getUpdate(change.currentPatchSetId());
    // notedb
    update.setAssignee(newAssignee.getAccountId());
    // reviewdb
    change.setAssignee(newAssignee.getAccountId());
    addMessage(ctx, update);
    return true;
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) ValidationException(com.google.gerrit.server.validators.ValidationException) AssigneeValidationListener(com.google.gerrit.server.validators.AssigneeValidationListener) ChangeUpdate(com.google.gerrit.server.notedb.ChangeUpdate)

Aggregations

ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 ChangeUpdate (com.google.gerrit.server.notedb.ChangeUpdate)1 AssigneeValidationListener (com.google.gerrit.server.validators.AssigneeValidationListener)1 ValidationException (com.google.gerrit.server.validators.ValidationException)1