use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class LoadQualityGateStep method executeForProject.
private void executeForProject(Component project) {
String projectKey = project.getKey();
Settings settings = settingsRepository.getSettings(project);
String qualityGateSetting = settings.getString(PROPERTY_QUALITY_GATE);
if (qualityGateSetting == null || StringUtils.isBlank(qualityGateSetting)) {
LOGGER.debug("No quality gate is configured for project " + projectKey);
qualityGateHolder.setNoQualityGate();
return;
}
try {
long qualityGateId = Long.parseLong(qualityGateSetting);
Optional<QualityGate> qualityGate = qualityGateService.findById(qualityGateId);
if (qualityGate.isPresent()) {
qualityGateHolder.setQualityGate(qualityGate.get());
} else {
qualityGateHolder.setNoQualityGate();
}
} catch (NumberFormatException e) {
throw new IllegalStateException(String.format("Unsupported value (%s) in property %s", qualityGateSetting, PROPERTY_QUALITY_GATE), e);
}
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class EsClientProvider method provide.
public EsClient provide(Settings settings) {
if (cache == null) {
TransportClient nativeClient;
org.elasticsearch.common.settings.Settings.Builder esSettings = org.elasticsearch.common.settings.Settings.builder();
// mandatory property defined by bootstrap process
esSettings.put("cluster.name", settings.getString(ProcessProperties.CLUSTER_NAME));
boolean clusterEnabled = settings.getBoolean(ProcessProperties.CLUSTER_ENABLED);
if (clusterEnabled && settings.getBoolean(ProcessProperties.CLUSTER_SEARCH_DISABLED)) {
esSettings.put("client.transport.sniff", true);
nativeClient = TransportClient.builder().settings(esSettings).build();
Arrays.stream(settings.getStringArray(ProcessProperties.CLUSTER_SEARCH_HOSTS)).map(Host::parse).forEach(h -> h.addTo(nativeClient));
LOGGER.info("Connected to remote Elasticsearch: [{}]", displayedAddresses(nativeClient));
} else {
nativeClient = TransportClient.builder().settings(esSettings).build();
Host host = new Host(settings.getString(ProcessProperties.SEARCH_HOST), settings.getInt(ProcessProperties.SEARCH_PORT));
host.addTo(nativeClient);
LOGGER.info("Connected to local Elasticsearch: [{}]", displayedAddresses(nativeClient));
}
cache = new EsClient(nativeClient);
}
return cache;
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class WebhookPostTask method finished.
@Override
public void finished(ProjectAnalysis analysis) {
Settings settings = settingsRepository.getSettings(rootHolder.getRoot());
Iterable<String> webhookProps = Iterables.concat(getWebhookProperties(settings, WebhookProperties.GLOBAL_KEY), getWebhookProperties(settings, WebhookProperties.PROJECT_KEY));
if (!Iterables.isEmpty(webhookProps)) {
process(settings, analysis, webhookProps);
deliveryStorage.purge(analysis.getProject().getUuid());
}
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class UserUpdater method addDefaultGroup.
private void addDefaultGroup(DbSession dbSession, UserDto userDto) {
String defaultGroupName = settings.getString(CoreProperties.CORE_DEFAULT_GROUP);
if (defaultGroupName == null) {
return;
}
String defOrgUuid = defaultOrganizationProvider.get().getUuid();
List<GroupDto> userGroups = dbClient.groupDao().selectByUserLogin(dbSession, userDto.getLogin());
if (!userGroups.stream().anyMatch(g -> defOrgUuid.equals(g.getOrganizationUuid()) && g.getName().equals(defaultGroupName))) {
Optional<GroupDto> groupDto = dbClient.groupDao().selectByName(dbSession, defOrgUuid, defaultGroupName);
if (!groupDto.isPresent()) {
throw new ServerException(HttpURLConnection.HTTP_INTERNAL_ERROR, format("The default group '%s' for new users does not exist. Please update the general security settings to fix this issue.", defaultGroupName));
}
dbClient.userGroupDao().insert(dbSession, new UserGroupDto().setUserId(userDto.getId()).setGroupId(groupDto.get().getId()));
}
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class CeHttpClientTest method setUp.
@Before
public void setUp() throws Exception {
ipcSharedDir = temp.newFolder();
Settings settings = new MapSettings();
settings.setProperty(ProcessEntryPoint.PROPERTY_SHARED_PATH, ipcSharedDir.getAbsolutePath());
underTest = new CeHttpClient(settings);
}
Aggregations