use of org.sonarqube.ws.AlmSettings.AlmSetting in project sonarqube by SonarSource.
the class ListAction method doHandle.
private ListWsResponse doHandle(Request request) {
try (DbSession dbSession = dbClient.openSession(false)) {
Request.StringParam projectKey = request.getParam(PARAM_PROJECT);
if (projectKey.isPresent()) {
ProjectDto project = componentFinder.getProjectByKey(dbSession, projectKey.getValue());
userSession.checkProjectPermission(ADMIN, project);
} else {
userSession.checkPermission(PROVISION_PROJECTS);
}
List<AlmSettingDto> settings = dbClient.almSettingDao().selectAll(dbSession);
List<AlmSetting> wsAlmSettings = settings.stream().sorted(Comparator.comparing(AlmSettingDto::getKey)).map(almSetting -> {
AlmSetting.Builder almSettingBuilder = AlmSetting.newBuilder().setKey(almSetting.getKey()).setAlm(AlmSettingsSupport.toAlmWs(almSetting.getAlm()));
if (almSetting.getAlm() == ALM.BITBUCKET_CLOUD) {
almSettingBuilder.setUrl(BITBUCKETCLOUD_ROOT_URL + almSetting.getAppId() + "/");
} else {
ofNullable(almSetting.getUrl()).ifPresent(almSettingBuilder::setUrl);
}
return almSettingBuilder.build();
}).collect(Collectors.toList());
return ListWsResponse.newBuilder().addAllAlmSettings(wsAlmSettings).build();
}
}
Aggregations