Search in sources :

Example 1 with ReactivationException

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

the class CreateAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    String customKey = request.mandatoryParam(PARAM_CUSTOM_KEY);
    try (DbSession dbSession = dbClient.openSession(false)) {
        try {
            NewCustomRule newRule = NewCustomRule.createForCustomRule(customKey, RuleKey.parse(request.mandatoryParam(PARAM_TEMPLATE_KEY))).setName(request.mandatoryParam(PARAM_NAME)).setMarkdownDescription(request.mandatoryParam(PARAM_DESCRIPTION)).setSeverity(request.mandatoryParam(PARAM_SEVERITY)).setStatus(RuleStatus.valueOf(request.mandatoryParam(PARAM_STATUS))).setPreventReactivation(request.mandatoryParamAsBoolean(PARAM_PREVENT_REACTIVATION));
            String params = request.param(PARAMS);
            if (!isNullOrEmpty(params)) {
                newRule.setParameters(KeyValueFormat.parse(params));
            }
            writeResponse(dbSession, request, response, ruleCreator.create(newRule));
        } catch (ReactivationException e) {
            write409(dbSession, request, response, e.ruleKey());
        }
    }
}
Also used : DbSession(org.sonar.db.DbSession) NewCustomRule(org.sonar.server.rule.NewCustomRule) ReactivationException(org.sonar.server.rule.ReactivationException)

Aggregations

DbSession (org.sonar.db.DbSession)1 NewCustomRule (org.sonar.server.rule.NewCustomRule)1 ReactivationException (org.sonar.server.rule.ReactivationException)1