diff options
author | lukasz-jarocki-sonarsource <lukasz.jarocki@sonarsource.com> | 2024-11-27 09:21:18 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-11-29 20:03:09 +0000 |
commit | 692dcd4fe7c59fed8d379d1aec50430fac4139e5 (patch) | |
tree | bf1964d35144a00c70bca04eaa95d11287d4d183 /server/sonar-webserver-api | |
parent | 2345e984986d324e8056f55f64530fba9fe9c92c (diff) | |
download | sonarqube-692dcd4fe7c59fed8d379d1aec50430fac4139e5.tar.gz sonarqube-692dcd4fe7c59fed8d379d1aec50430fac4139e5.zip |
SONAR-23803 determining sonar version to update takes into account two products
Diffstat (limited to 'server/sonar-webserver-api')
-rw-r--r-- | server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java index 48561139088..a1259e43d78 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java @@ -30,9 +30,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.Properties; import org.sonar.api.Property; +import org.sonar.api.SonarEdition; import org.sonar.api.config.Configuration; +import org.sonar.api.internal.MetadataLoader; +import org.sonar.api.utils.System2; import org.sonar.api.utils.UriReader; import org.sonar.process.ProcessProperties; +import org.sonar.updatecenter.common.Product; import org.sonar.updatecenter.common.UpdateCenter; import org.sonar.updatecenter.common.UpdateCenterDeserializer; import org.sonar.updatecenter.common.UpdateCenterDeserializer.Mode; @@ -67,6 +71,7 @@ public class UpdateCenterClient { static final String CACHE_TTL_DEFAULT_VALUE = "3600000"; private final long periodInMilliseconds; + private final Product product; private final URI uri; private final UriReader uriReader; @@ -74,11 +79,14 @@ public class UpdateCenterClient { private UpdateCenter pluginCenter = null; private long lastRefreshDate = 0; + public UpdateCenterClient(UriReader uriReader, Configuration config) throws URISyntaxException { this.uriReader = uriReader; this.uri = new URI(config.get(URL_PROPERTY).get()); this.isActivated = config.getBoolean(ProcessProperties.Property.SONAR_UPDATECENTER_ACTIVATE.getKey()).get(); this.periodInMilliseconds = Long.parseLong(config.get(CACHE_TTL_PROPERTY).get()); + this.product = MetadataLoader.loadEdition(System2.INSTANCE) == SonarEdition.COMMUNITY ? + Product.SONARQUBE_COMMUNITY_BUILD : Product.SONARQUBE_SERVER; LOG.info("Update center: {}", uriReader.description(uri)); } @@ -114,8 +122,9 @@ public class UpdateCenterClient { java.util.Properties properties = new java.util.Properties(); input = IOUtils.toInputStream(content, StandardCharsets.UTF_8); properties.load(input); - return new UpdateCenterDeserializer(Mode.PROD, true).fromProperties(properties); - + UpdateCenter updateCenter = new UpdateCenterDeserializer(Mode.PROD, true).fromProperties(properties); + updateCenter.setInstalledSonarProduct(product); + return updateCenter; } catch (Exception e) { LoggerFactory.getLogger(getClass()).error("Fail to connect to update center", e); return null; |