From: Sébastien Lesaint Date: Fri, 3 Aug 2018 11:59:32 +0000 (+0200) Subject: SONAR-11083 fail at startup if License plugin < 3.4 is installed X-Git-Tag: 6.7.5~1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=292a767d4aab4ef6aad38bf9fbb3762bbe569d58;p=sonarqube.git SONAR-11083 fail at startup if License plugin < 3.4 is installed --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java index 7fb654172f9..ff2675084b3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java +++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.CheckForNull; +import javax.annotation.Nullable; import org.apache.commons.io.FileUtils; import org.picocontainer.Startable; import org.sonar.api.Plugin; @@ -295,7 +296,19 @@ public class ServerPluginRepository implements PluginRepository, Startable { List orderedPlugins = Ordering.natural().sortedCopy(pluginInfosByKeys.values()); for (PluginInfo plugin : orderedPlugins) { LOG.info("Deploy plugin {}", SLASH_JOINER.join(plugin.getName(), plugin.getVersion(), plugin.getImplementationBuild())); + if (plugin.getKey().equals("license") && isBefore34(plugin.getVersion())) { + throw MessageException.of("Your commercial edition is obsolete. You must upgrade the edition bundle to its latest version."); + } + } + } + + private static final Set BEFORE_4_MINOR_VERSION = ImmutableSet.of("0", "1", "2", "3"); + + private static boolean isBefore34(@Nullable Version version) { + if (version == null) { + return true; } + return "3".equals(version.getMajor()) && BEFORE_4_MINOR_VERSION.contains(version.getMinor()); } private void loadInstances() {