Search in sources :

Example 1 with SettingData

use of org.sonar.server.setting.ws.SettingValidations.SettingData in project sonarqube by SonarSource.

the class ResetAction method handle.

@Override
public void handle(Request request, Response response) throws Exception {
    try (DbSession dbSession = dbClient.openSession(false)) {
        ResetRequest resetRequest = toWsRequest(request);
        Optional<ComponentDto> component = getComponent(dbSession, resetRequest);
        checkPermissions(component);
        resetRequest.getKeys().forEach(key -> {
            SettingData data = new SettingData(key, emptyList(), component.orElse(null));
            ImmutableList.of(validations.scope(), validations.qualifier()).forEach(validation -> validation.accept(data));
        });
        List<String> keys = getKeys(resetRequest);
        if (component.isPresent()) {
            settingsUpdater.deleteComponentSettings(dbSession, component.get(), keys);
        } else {
            settingsUpdater.deleteGlobalSettings(dbSession, keys);
        }
        dbSession.commit();
        response.noContent();
    }
}
Also used : DbSession(org.sonar.db.DbSession) SettingData(org.sonar.server.setting.ws.SettingValidations.SettingData) ComponentDto(org.sonar.db.component.ComponentDto) ResetRequest(org.sonarqube.ws.client.setting.ResetRequest)

Example 2 with SettingData

use of org.sonar.server.setting.ws.SettingValidations.SettingData in project sonarqube by SonarSource.

the class SetAction method commonChecks.

private void commonChecks(SetRequest request, Optional<ComponentDto> component) {
    checkValueIsSet(request);
    SettingData settingData = new SettingData(request.getKey(), valuesFromRequest(request), component.orElse(null));
    ImmutableList.of(validations.scope(), validations.qualifier(), validations.valueType()).forEach(validation -> validation.accept(settingData));
}
Also used : SettingData(org.sonar.server.setting.ws.SettingValidations.SettingData)

Aggregations

SettingData (org.sonar.server.setting.ws.SettingValidations.SettingData)2 DbSession (org.sonar.db.DbSession)1 ComponentDto (org.sonar.db.component.ComponentDto)1 ResetRequest (org.sonarqube.ws.client.setting.ResetRequest)1