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);
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class SettingsRepositoryTest method get_project_settings_from_db.
@Test
public void get_project_settings_from_db() {
ComponentDto project = ComponentTesting.newProjectDto(dbTester.organizations().insert()).setKey(ROOT.getKey());
dbClient.componentDao().insert(session, project);
dbClient.propertiesDao().saveProperty(session, new PropertyDto().setResourceId(project.getId()).setKey("key").setValue("value"));
session.commit();
Settings settings = underTest.getSettings(ROOT);
assertThat(settings.getString("key")).isEqualTo("value");
}
use of org.sonar.api.config.Settings in project sonarqube by SonarSource.
the class NotificationDaemonTest method setUpMocks.
private void setUpMocks() {
when(emailChannel.getKey()).thenReturn("email");
when(gtalkChannel.getKey()).thenReturn("gtalk");
when(commentOnIssueAssignedToMe.getKey()).thenReturn("CommentOnIssueAssignedToMe");
when(commentOnIssueAssignedToMe.getType()).thenReturn("issue-changes");
when(commentOnIssueCreatedByMe.getKey()).thenReturn("CommentOnIssueCreatedByMe");
when(commentOnIssueCreatedByMe.getType()).thenReturn("issue-changes");
when(qualityGateChange.getKey()).thenReturn("QGateChange");
when(qualityGateChange.getType()).thenReturn("qgate-changes");
when(manager.getFromQueue()).thenReturn(notification).thenReturn(null);
Settings settings = new MapSettings().setProperty("sonar.notifications.delay", 1L);
underTest = new NotificationDaemon(settings, manager, service);
}
Aggregations