use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class DefaultDatabaseTest method shouldGuessDefaultDriver.
@Test
public void shouldGuessDefaultDriver() {
Settings settings = new MapSettings();
settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
database.initSettings();
assertThat(database.getProperties().getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.postgresql.Driver");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class DefaultDatabaseTest method shouldCompleteProperties.
@Test
public void shouldCompleteProperties() {
Settings settings = new MapSettings();
DefaultDatabase db = new DefaultDatabase(logbackHelper, settings) {
@Override
protected void doCompleteProperties(Properties properties) {
properties.setProperty("sonar.jdbc.maxActive", "2");
}
};
db.initSettings();
Properties props = db.getProperties();
assertThat(props.getProperty("sonar.jdbc.maxActive")).isEqualTo("2");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class LoadPeriodsStep method buildPeriod.
@CheckForNull
private Period buildPeriod(Component projectOrView, DbSession session) {
Optional<ComponentDto> projectDto = dbClient.componentDao().selectByKey(session, projectOrView.getKey());
// No project on first analysis, no period
if (!projectDto.isPresent()) {
return null;
}
boolean isReportType = projectOrView.getType().isReportType();
PeriodResolver periodResolver = new PeriodResolver(dbClient, session, projectDto.get().uuid(), analysisMetadataHolder.getAnalysisDate(), isReportType ? projectOrView.getReportAttributes().getVersion() : null);
Settings settings = settingsRepository.getSettings(projectOrView);
Period period = periodResolver.resolve(settings);
// SONAR-4700 Add a past snapshot only if it exists
if (period != null) {
return period;
}
return null;
}
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;
}
Aggregations