use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class UpdateGithubAction method doHandle.
private void doHandle(Request request) {
String key = request.mandatoryParam(PARAM_KEY);
String newKey = request.param(PARAM_NEW_KEY);
String url = request.mandatoryParam(PARAM_URL);
String appId = request.mandatoryParam(PARAM_APP_ID);
String clientId = request.mandatoryParam(PARAM_CLIENT_ID);
String clientSecret = request.param(PARAM_CLIENT_SECRET);
String privateKey = request.param(PARAM_PRIVATE_KEY);
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
try (DbSession dbSession = dbClient.openSession(false)) {
AlmSettingDto almSettingDto = almSettingsSupport.getAlmSetting(dbSession, key);
if (isNotBlank(newKey) && !newKey.equals(key)) {
almSettingsSupport.checkAlmSettingDoesNotAlreadyExist(dbSession, newKey);
}
if (isNotBlank(privateKey)) {
almSettingDto.setPrivateKey(privateKey);
}
if (isNotBlank(clientSecret)) {
almSettingDto.setClientSecret(clientSecret);
}
dbClient.almSettingDao().update(dbSession, almSettingDto.setKey(isNotBlank(newKey) ? newKey : key).setUrl(url).setAppId(appId).setClientId(clientId), clientSecret != null || privateKey != null);
dbSession.commit();
}
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class UpdateAzureAction method doHandle.
private void doHandle(Request request) {
String key = request.mandatoryParam(PARAM_KEY);
String newKey = request.param(PARAM_NEW_KEY);
String pat = request.param(PARAM_PERSONAL_ACCESS_TOKEN);
String url = request.mandatoryParam(PARAM_URL);
try (DbSession dbSession = dbClient.openSession(false)) {
AlmSettingDto almSettingDto = almSettingsSupport.getAlmSetting(dbSession, key);
if (isNotBlank(newKey) && !newKey.equals(key)) {
almSettingsSupport.checkAlmSettingDoesNotAlreadyExist(dbSession, newKey);
}
if (isNotBlank(pat)) {
almSettingDto.setPersonalAccessToken(pat);
}
dbClient.almSettingDao().update(dbSession, almSettingDto.setKey(isNotBlank(newKey) ? newKey : key).setUrl(url), pat != null);
dbSession.commit();
}
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class UpdateBitbucketCloudAction method doHandle.
private void doHandle(Request request) {
String key = request.mandatoryParam(PARAM_KEY);
String newKey = request.param(PARAM_NEW_KEY);
String workspace = request.mandatoryParam(PARAM_WORKSPACE);
String clientId = request.mandatoryParam(PARAM_CLIENT_ID);
String clientSecret = request.param(PARAM_CLIENT_SECRET);
try (DbSession dbSession = dbClient.openSession(false)) {
AlmSettingDto almSettingDto = almSettingsSupport.getAlmSetting(dbSession, key);
if (isNotBlank(newKey) && !newKey.equals(key)) {
almSettingsSupport.checkAlmSettingDoesNotAlreadyExist(dbSession, newKey);
}
if (isNotBlank(clientSecret)) {
almSettingDto.setClientSecret(clientSecret);
}
dbClient.almSettingDao().update(dbSession, almSettingDto.setKey(isNotBlank(newKey) ? newKey : key).setClientId(clientId).setAppId(workspace), clientSecret != null);
dbSession.commit();
}
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class UpdateGitlabAction method doHandle.
private void doHandle(Request request) {
String key = request.mandatoryParam(PARAM_KEY);
String newKey = request.param(PARAM_NEW_KEY);
String url = StringUtils.trim(request.mandatoryParam(PARAM_URL));
String pat = request.param(PARAM_PERSONAL_ACCESS_TOKEN);
try (DbSession dbSession = dbClient.openSession(false)) {
AlmSettingDto almSettingDto = almSettingsSupport.getAlmSetting(dbSession, key);
if (isNotBlank(newKey) && !newKey.equals(key)) {
almSettingsSupport.checkAlmSettingDoesNotAlreadyExist(dbSession, newKey);
}
if (isNotBlank(pat)) {
almSettingDto.setPersonalAccessToken(pat);
}
dbClient.almSettingDao().update(dbSession, almSettingDto.setKey(isNotBlank(newKey) ? newKey : key).setUrl(url), pat != null);
dbSession.commit();
}
}
use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.
the class AlmConfigurationSectionTest method null_url_are_ignored.
@Test
public void null_url_are_ignored() {
AlmSettingDto azure = db.almSettings().insertAzureAlmSetting(a -> a.setUrl(null));
ProtobufSystemInfo.Section section = underTest.toProtobuf();
assertThat(section.getAttributesList()).hasSize(1);
assertThat(section.getAttributesList()).extracting(Attribute::getKey, Attribute::getStringValue).containsExactlyInAnyOrder(tuple(azure.getKey(), String.format("Alm:%s", azure.getRawAlm())));
}
Aggregations