use of com.google.gerrit.server.git.BanCommitResult in project gerrit by GerritCodeReview.
the class BanCommit method apply.
@Override
public BanResultInfo apply(ProjectResource rsrc, Input input) throws UnprocessableEntityException, AuthException, ResourceConflictException, IOException {
BanResultInfo r = new BanResultInfo();
if (input != null && input.commits != null && !input.commits.isEmpty()) {
List<ObjectId> commitsToBan = new ArrayList<>(input.commits.size());
for (String c : input.commits) {
try {
commitsToBan.add(ObjectId.fromString(c));
} catch (IllegalArgumentException e) {
throw new UnprocessableEntityException(e.getMessage());
}
}
try {
BanCommitResult result = banCommit.ban(rsrc.getControl(), commitsToBan, input.reason);
r.newlyBanned = transformCommits(result.getNewlyBannedCommits());
r.alreadyBanned = transformCommits(result.getAlreadyBannedCommits());
r.ignored = transformCommits(result.getIgnoredObjectIds());
} catch (PermissionDeniedException e) {
throw new AuthException(e.getMessage());
} catch (ConcurrentRefUpdateException e) {
throw new ResourceConflictException(e.getMessage(), e);
}
}
return r;
}
Aggregations