Search in sources :

Example 6 with AddCommentRequest

use of org.sonarqube.ws.client.issue.AddCommentRequest in project sonarqube by SonarSource.

the class AddCommentAction method handle.

@Override
public void handle(Request request, Response response) {
    userSession.checkLoggedIn();
    AddCommentRequest wsRequest = toWsRequest(request);
    try (DbSession dbSession = dbClient.openSession(false)) {
        IssueDto issueDto = issueFinder.getByKey(dbSession, wsRequest.getIssue());
        IssueChangeContext context = IssueChangeContext.createUser(new Date(system2.now()), userSession.getLogin());
        DefaultIssue defaultIssue = issueDto.toDefaultIssue();
        issueFieldsSetter.addComment(defaultIssue, wsRequest.getText(), context);
        issueUpdater.saveIssue(dbSession, defaultIssue, context, wsRequest.getText());
        responseWriter.write(defaultIssue.key(), request, response);
    }
}
Also used : AddCommentRequest(org.sonarqube.ws.client.issue.AddCommentRequest) DbSession(org.sonar.db.DbSession) IssueChangeContext(org.sonar.core.issue.IssueChangeContext) IssueDto(org.sonar.db.issue.IssueDto) DefaultIssue(org.sonar.core.issue.DefaultIssue) Date(java.util.Date)

Aggregations

AddCommentRequest (org.sonarqube.ws.client.issue.AddCommentRequest)6 Test (org.junit.Test)4 Issue (org.sonarqube.ws.Issues.Issue)4 Issues (org.sonarqube.ws.Issues)3 Date (java.util.Date)1 DefaultIssue (org.sonar.core.issue.DefaultIssue)1 IssueChangeContext (org.sonar.core.issue.IssueChangeContext)1 DbSession (org.sonar.db.DbSession)1 IssueDto (org.sonar.db.issue.IssueDto)1 EditCommentRequest (org.sonarqube.ws.client.issue.EditCommentRequest)1