Search in sources :

Example 16 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class AlmConfigurationSection method toProtobuf.

@Override
public ProtobufSystemInfo.Section toProtobuf() {
    ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
    protobuf.setName("ALMs");
    try (DbSession dbSession = dbClient.openSession(false)) {
        List<AlmSettingDto> almSettingDtos = dbClient.almSettingDao().selectAll(dbSession);
        for (AlmSettingDto almSettingDto : almSettingDtos) {
            setAttribute(protobuf, almSettingDto.getKey(), buildValue(almSettingDto));
        }
    }
    return protobuf.build();
}
Also used : DbSession(org.sonar.db.DbSession) SystemInfoSection(org.sonar.process.systeminfo.SystemInfoSection) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto)

Example 17 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class AzureMetricsTask method run.

@Override
public void run() {
    try (DbSession dbSession = dbClient.openSession(false)) {
        List<AlmSettingDto> azureSettingsDtos = dbClient.almSettingDao().selectByAlm(dbSession, ALM.AZURE_DEVOPS);
        if (azureSettingsDtos.isEmpty()) {
            metrics.setAzureStatusToRed();
            return;
        }
        validate(azureSettingsDtos);
    }
}
Also used : DbSession(org.sonar.db.DbSession) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto)

Example 18 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class CountBindingAction method doHandle.

private CountBindingWsResponse doHandle(Request request) {
    String almSettingKey = request.mandatoryParam(PARAM_ALM_SETTING);
    try (DbSession dbSession = dbClient.openSession(false)) {
        AlmSettingDto almSetting = almSettingsSupport.getAlmSetting(dbSession, almSettingKey);
        int projectsBound = dbClient.projectAlmSettingDao().countByAlmSetting(dbSession, almSetting);
        return CountBindingWsResponse.newBuilder().setKey(almSetting.getKey()).setProjects(projectsBound).build();
    }
}
Also used : DbSession(org.sonar.db.DbSession) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto)

Example 19 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class CreateGithubAction method doHandle.

private void doHandle(Request request) {
    String key = request.mandatoryParam(PARAM_KEY);
    String url = request.mandatoryParam(PARAM_URL);
    String appId = request.mandatoryParam(PARAM_APP_ID);
    String clientId = request.mandatoryParam(PARAM_CLIENT_ID);
    String clientSecret = request.mandatoryParam(PARAM_CLIENT_SECRET);
    String privateKey = request.mandatoryParam(PARAM_PRIVATE_KEY);
    if (url.endsWith("/")) {
        url = url.substring(0, url.length() - 1);
    }
    try (DbSession dbSession = dbClient.openSession(false)) {
        almSettingsSupport.checkAlmMultipleFeatureEnabled(GITHUB);
        almSettingsSupport.checkAlmSettingDoesNotAlreadyExist(dbSession, key);
        dbClient.almSettingDao().insert(dbSession, new AlmSettingDto().setAlm(GITHUB).setKey(key).setUrl(url).setAppId(appId).setPrivateKey(privateKey).setClientId(clientId).setClientSecret(clientSecret));
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto)

Example 20 with AlmSettingDto

use of org.sonar.db.alm.setting.AlmSettingDto in project sonarqube by SonarSource.

the class DeleteAction method doHandle.

private void doHandle(Request request) {
    String key = request.mandatoryParam(PARAM_KEY);
    try (DbSession dbSession = dbClient.openSession(false)) {
        AlmSettingDto almSettingDto = almSettingsSupport.getAlmSetting(dbSession, key);
        dbClient.projectAlmSettingDao().deleteByAlmSetting(dbSession, almSettingDto);
        dbClient.almPatDao().deleteByAlmSetting(dbSession, almSettingDto);
        dbClient.almSettingDao().delete(dbSession, almSettingDto);
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) AlmSettingDto(org.sonar.db.alm.setting.AlmSettingDto)

Aggregations

AlmSettingDto (org.sonar.db.alm.setting.AlmSettingDto)217 Test (org.junit.Test)175 UserDto (org.sonar.db.user.UserDto)113 TestRequest (org.sonar.server.ws.TestRequest)48 ProjectDto (org.sonar.db.project.ProjectDto)40 NotFoundException (org.sonar.server.exceptions.NotFoundException)37 DbSession (org.sonar.db.DbSession)36 WebService (org.sonar.api.server.ws.WebService)31 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)28 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)28 Rule (org.junit.Rule)28 Mockito.mock (org.mockito.Mockito.mock)28 DbTester (org.sonar.db.DbTester)28 UserSessionRule (org.sonar.server.tester.UserSessionRule)28 WsActionTester (org.sonar.server.ws.WsActionTester)28 Encryption (org.sonar.api.config.internal.Encryption)27 ForbiddenException (org.sonar.server.exceptions.ForbiddenException)27 ComponentFinder (org.sonar.server.component.ComponentFinder)26 Tuple.tuple (org.assertj.core.groups.Tuple.tuple)25 ProjectAlmSettingDto (org.sonar.db.alm.setting.ProjectAlmSettingDto)25