use of org.sonar.server.branch.pr.ws.PullRequestsWsParameters.PARAM_PULL_REQUEST in project sonarqube by SonarSource.
the class DeleteAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
String projectKey = request.mandatoryParam(PARAM_PROJECT);
String pullRequestId = request.mandatoryParam(PARAM_PULL_REQUEST);
try (DbSession dbSession = dbClient.openSession(false)) {
ProjectDto project = componentFinder.getProjectOrApplicationByKey(dbSession, projectKey);
checkPermission(project);
BranchDto pullRequest = dbClient.branchDao().selectByPullRequestKey(dbSession, project.getUuid(), pullRequestId).filter(branch -> branch.getBranchType() == PULL_REQUEST).orElseThrow(() -> new NotFoundException(String.format("Pull request '%s' is not found for project '%s'", pullRequestId, projectKey)));
componentCleanerService.deleteBranch(dbSession, pullRequest);
response.noContent();
}
}
Aggregations