use of org.sonarsource.sonarlint.core.serverapi.system.ValidationResult in project sonarlint-core by SonarSource.
the class ConnectionValidator method validateConnection.
public CompletableFuture<ValidationResult> validateConnection() {
var serverChecker = new ServerVersionAndStatusChecker(helper);
var authChecker = new AuthenticationChecker(helper);
return serverChecker.checkVersionAndStatusAsync().thenApply(check -> {
var validateCredentials = authChecker.validateCredentials();
var organizationKey = helper.getOrganizationKey();
if (validateCredentials.success() && organizationKey.isPresent()) {
var organization = new ServerApi(helper).organization().fetchOrganization(organizationKey.get(), new ProgressMonitor(null));
if (organization.isEmpty()) {
return new DefaultValidationResult(false, "No organizations found for key: " + organizationKey.get());
}
}
return validateCredentials;
}).exceptionally(e -> new DefaultValidationResult(false, e.getCause().getMessage()));
}
Aggregations