use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class SonarLintProjectConfigurable method reset.
@Override
public void reset() {
if (panel == null) {
return;
}
List<SonarQubeServer> currentServers = null;
// try get the global settings that are currently being configured in the configurable, if it is open
DataContext ctx = DataManager.getInstance().getDataContextFromFocus().getResult();
if (ctx != null) {
Settings allSettings = Settings.KEY.getData(ctx);
if (allSettings != null) {
final SonarLintGlobalConfigurable globalConfigurable = allSettings.find(SonarLintGlobalConfigurable.class);
if (globalConfigurable != null) {
currentServers = globalConfigurable.getCurrentSettings();
}
}
}
// get saved settings if needed
if (currentServers == null) {
currentServers = SonarLintUtils.get(SonarLintGlobalSettings.class).getSonarQubeServers();
}
panel.load(currentServers, projectSettings);
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class AuthStep method fetchInformation.
private void fetchInformation() throws CommitStepException {
SonarQubeServer tmpServer = model.createServerWithoutOrganization();
InformationFetchTask task = new InformationFetchTask(tmpServer);
ProgressManager.getInstance().run(task);
if (task.getException() == null) {
model.setOrganizationList(task.organizations());
if (task.organizations().size() == 1) {
model.setOrganization(task.organizations().iterator().next().getKey());
} else if (task.organizations().isEmpty()) {
model.setOrganization(null);
}
model.setNotificationsSupported(task.notificationsSupported());
return;
}
String msg = "Failed to fetch information from the server. Please check the configuration and try again.";
if (task.getException().getMessage() != null) {
msg = msg + " Error: " + task.getException().getMessage();
}
throw new CommitStepException(msg);
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class AuthStep method checkConnection.
private void checkConnection() throws CommitStepException {
SonarQubeServer tmpServer = model.createServerWithoutOrganization();
ConnectionTestTask test = new ConnectionTestTask(tmpServer);
ProgressManager.getInstance().run(test);
ValidationResult r = test.result();
String msg = "Failed to connect to the server. Please check the configuration.";
if (test.getException() != null) {
if (test.getException().getMessage() != null) {
msg = msg + " Error: " + test.getException().getMessage();
}
throw new CommitStepException(msg);
} else if (!r.success()) {
throw new CommitStepException(msg + " Cause: " + r.message());
}
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class ProjectBindingManager method getSonarQubeServer.
public synchronized SonarQubeServer getSonarQubeServer() throws InvalidBindingException {
String serverId = projectSettings.getServerId();
List<SonarQubeServer> servers = globalSettings.getSonarQubeServers();
Optional<SonarQubeServer> server = servers.stream().filter(s -> s.getName().equals(serverId)).findAny();
return server.orElseThrow(() -> new InvalidBindingException("SonarQube server configuration does not exist for server id: " + serverId));
}
use of org.sonarlint.intellij.config.global.SonarQubeServer in project sonarlint-intellij by SonarSource.
the class WizardModelTest method testExportSonarCloud.
@Test
public void testExportSonarCloud() {
WizardModel model = new WizardModel();
model.setName("name");
model.setOrganization("org");
model.setToken("token");
model.setPassword(new char[] { 'p', 'a', 's', 's' });
model.setServerType(WizardModel.ServerType.SONARCLOUD);
SonarQubeServer server = model.createServer();
assertThat(server.getHostUrl()).isEqualTo("https://sonarcloud.io");
assertThat(server.getLogin()).isNull();
assertThat(server.getPassword()).isNull();
assertThat(server.getToken()).isEqualTo("token");
assertThat(server.getOrganizationKey()).isEqualTo("org");
}
Aggregations