use of org.sonarsource.sonarlint.core.plugin.Version in project sonarlint-core by SonarSource.
the class PluginReferencesDownloader method checkVersion.
private static boolean checkVersion(@Nullable String version, @Nullable String minVersion) {
if (version != null && minVersion != null) {
Version v = Version.create(version);
Version minimalVersion = Version.create(minVersion);
return v.compareTo(minimalVersion) >= 0;
}
return true;
}
use of org.sonarsource.sonarlint.core.plugin.Version in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusChecker method checkVersionAndStatus.
/**
* Checks SonarQube version against a provided minimum version
* @return ServerInfos
* @throws UnsupportedServerException if version < minimum supported version
* @throws IllegalStateException If server is not ready
*/
public ServerInfos checkVersionAndStatus(String minVersion) {
ServerInfos serverStatus = fetchServerInfos();
if (!"UP".equals(serverStatus.getStatus())) {
throw new IllegalStateException(serverNotReady(serverStatus));
}
Version serverVersion = Version.create(serverStatus.getVersion());
if (serverVersion.compareToIgnoreQualifier(Version.create(minVersion)) < 0) {
throw new UnsupportedServerException(unsupportedVersion(serverStatus, minVersion));
}
return serverStatus;
}
use of org.sonarsource.sonarlint.core.plugin.Version in project sonarlint-core by SonarSource.
the class WsHelperImpl method validateConnection.
static ValidationResult validateConnection(SonarLintWsClient client, @Nullable String organizationKey) {
ServerVersionAndStatusChecker serverChecker = new ServerVersionAndStatusChecker(client);
AuthenticationChecker authChecker = new AuthenticationChecker(client);
try {
ServerInfos serverStatus = serverChecker.checkVersionAndStatus();
ValidationResult validateCredentials = authChecker.validateCredentials();
if (validateCredentials.success() && organizationKey != null) {
Version serverVersion = Version.create(serverStatus.getVersion());
if (serverVersion.compareToIgnoreQualifier(Version.create(MIN_VERSION_FOR_ORGANIZATIONS)) < 0) {
return new DefaultValidationResult(false, "No organization support for this server version: " + serverStatus.getVersion());
}
if (fetchOrganizations(client, organizationKey, new ProgressWrapper(null)).isEmpty()) {
return new DefaultValidationResult(false, "No organizations found for key: " + organizationKey);
}
}
return validateCredentials;
} catch (UnsupportedServerException e) {
return new DefaultValidationResult(false, e.getMessage());
} catch (RuntimeException e) {
throw SonarLintWrappedException.wrap(e);
}
}
use of org.sonarsource.sonarlint.core.plugin.Version in project sonarlint-core by SonarSource.
the class ServerVersionAndStatusChecker method validateStatusAndVersion.
public ValidationResult validateStatusAndVersion(String minVersion) {
ServerInfos serverStatus = fetchServerInfos();
if (!"UP".equals(serverStatus.getStatus())) {
return new DefaultValidationResult(false, serverNotReady(serverStatus));
}
Version serverVersion = Version.create(serverStatus.getVersion());
if (serverVersion.compareToIgnoreQualifier(Version.create(minVersion)) < 0) {
return new DefaultValidationResult(false, unsupportedVersion(serverStatus, minVersion));
}
return new DefaultValidationResult(true, "Compatible and ready");
}
use of org.sonarsource.sonarlint.core.plugin.Version in project sonarlint-intellij by SonarSource.
the class ServerUpdateTask method tooOld.
private static boolean tooOld(SonarAnalyzer analyzer) {
if (analyzer.minimumVersion() != null && analyzer.version() != null) {
Version minimum = Version.create(analyzer.minimumVersion());
Version version = Version.create(analyzer.version());
return version.compareTo(minimum) < 0;
}
return false;
}
Aggregations