diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 12fa0bcb16..062a287c06 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -1041,4 +1041,64 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas return pluginsWithCycle; } } + + public static PluginUpdateMonitor getPluginUpdateMonitor() { + return PluginUpdateMonitor.getInstance(); + } + + /** + * {@link AdministrativeMonitor} that informs the administrator about a required plugin update. + */ + @Extension + public static final class PluginUpdateMonitor extends AdministrativeMonitor { + + private List pluginsToBeUpdated = new ArrayList(); + + /** + * Convenience method to ease access to this monitor, this allows other plugins to register required updates. + * @return this monitor. + */ + public static final PluginUpdateMonitor getInstance() { + return Jenkins.getInstance().getExtensionList(PluginUpdateMonitor.class).get(0); + } + + public PluginUpdateMonitor() { + init(); + } + + private void init() { + ifPluginOlderThenReport("config-file-provider", "2.2.2", "The current installed version of 'config-file-provider' is not compatible with this core anymore"); + } + + private void ifPluginOlderThenReport(String pluginName, String version, String message){ + Plugin plugin = Jenkins.getInstance().getPlugin(pluginName); + if(plugin != null){ + if(plugin.getWrapper().getVersionNumber().isOlderThan(new VersionNumber(version))) { + pluginsToBeUpdated.add(new PluginUpdateInfo(pluginName, message)); + } + } + } + + public boolean isActivated() { + return !pluginsToBeUpdated.isEmpty(); + } + + public void addPluginToUpdate(String pluginName, String message) { + this.pluginsToBeUpdated.add(new PluginUpdateInfo(pluginName, message)); + } + + public List getPluginsToBeUpdated() { + return pluginsToBeUpdated; + } + + private static class PluginUpdateInfo { + public final String pluginName; + public final String message; + public PluginUpdateInfo(String pluginName, String message) { + this.pluginName = pluginName; + this.message = message; + } + } + + } } diff --git a/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.jelly b/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.jelly new file mode 100644 index 0000000000..27606dc42e --- /dev/null +++ b/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.jelly @@ -0,0 +1,35 @@ + + + + +
+ ${%RequiredPluginUpdates} +
    + +
  • -
  • +
    +
+
+
diff --git a/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.properties b/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.properties new file mode 100644 index 0000000000..930492c735 --- /dev/null +++ b/core/src/main/resources/hudson/PluginManager/PluginUpdateMonitor/message.properties @@ -0,0 +1,24 @@ +# The MIT License +# +# Copyright (c) 2004-2012, Dominik Bartholdi +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + + +RequiredPluginUpdates=The following plugins require an update. \ No newline at end of file