Search in sources :

Example 1 with RuleUpdate

use of org.sonar.server.rule.RuleUpdate in project sonarqube by SonarSource.

the class UpdateAction method readRequest.

private RuleUpdate readRequest(DbSession dbSession, Request request) {
    RuleKey key = RuleKey.parse(request.mandatoryParam(PARAM_KEY));
    RuleUpdate update = createRuleUpdate(dbSession, key);
    readTags(request, update);
    readMarkdownNote(request, update);
    readDebt(request, update);
    String name = request.param(PARAM_NAME);
    if (name != null) {
        update.setName(name);
    }
    String description = request.param(PARAM_DESCRIPTION);
    if (description != null) {
        update.setMarkdownDescription(description);
    }
    String severity = request.param(PARAM_SEVERITY);
    if (severity != null) {
        update.setSeverity(severity);
    }
    String status = request.param(PARAM_STATUS);
    if (status != null) {
        update.setStatus(RuleStatus.valueOf(status));
    }
    String params = request.param(PARAMS);
    if (params != null) {
        update.setParameters(KeyValueFormat.parse(params));
    }
    return update;
}
Also used : RuleUpdate(org.sonar.server.rule.RuleUpdate) RuleKey(org.sonar.api.rule.RuleKey)

Example 2 with RuleUpdate

use of org.sonar.server.rule.RuleUpdate in project sonarqube by SonarSource.

the class UpdateAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    ruleWsSupport.checkQProfileAdminPermission();
    try (DbSession dbSession = dbClient.openSession(false)) {
        RuleUpdate update = readRequest(dbSession, request);
        ruleUpdater.update(dbSession, update, userSession);
        UpdateResponse updateResponse = buildResponse(dbSession, update.getRuleKey());
        writeProtobuf(updateResponse, request, response);
    }
}
Also used : DbSession(org.sonar.db.DbSession) UpdateResponse(org.sonarqube.ws.Rules.UpdateResponse) RuleUpdate(org.sonar.server.rule.RuleUpdate)

Aggregations

RuleUpdate (org.sonar.server.rule.RuleUpdate)2 RuleKey (org.sonar.api.rule.RuleKey)1 DbSession (org.sonar.db.DbSession)1 UpdateResponse (org.sonarqube.ws.Rules.UpdateResponse)1