use of org.sonarqube.ws.client.setting.ResetRequest in project sonarqube by SonarSource.
the class WebhooksTest method setProperty.
private void setProperty(@Nullable String componentKey, String key, @Nullable String value) {
if (value == null) {
ResetRequest req = ResetRequest.builder().setKeys(key).setComponent(componentKey).build();
adminWs.settingsService().reset(req);
} else {
SetRequest req = SetRequest.builder().setKey(key).setValue(value).setComponent(componentKey).build();
adminWs.settingsService().set(req);
}
}
use of org.sonarqube.ws.client.setting.ResetRequest 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();
}
}
Aggregations