Commit 763fc5c7 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Do not offer plugins as available if they require a newer server version. JM-967

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@7046 b35dd754-fafc-0310-a699-88a17e54d16e
parent 4154e164
......@@ -276,13 +276,13 @@ public class UpdateManager extends BasicModule {
/**
* Returns the list of available plugins to install as reported by igniterealtime.org.
* Currently installed plugins will not be included.
* Currently installed plugins will not be included or plugins that require a newer
* server version.
*
* @return the list of available plugins to install as reported by igniterealtime.org.
*/
public List<AvailablePlugin> getNotInstalledPlugins() {
ArrayList<AvailablePlugin> plugins =
new ArrayList<AvailablePlugin>(availablePlugins.values());
List<AvailablePlugin> plugins = new ArrayList<AvailablePlugin>(availablePlugins.values());
XMPPServer server = XMPPServer.getInstance();
// Remove installed plugins from the list of available plugins
for (Plugin plugin : server.getPluginManager().getPlugins()) {
......@@ -295,6 +295,14 @@ public class UpdateManager extends BasicModule {
}
}
}
// Remove plugins that require a newer server version
String serverVersion = XMPPServer.getInstance().getServerInfo().getVersion().getVersionString();
for (Iterator<AvailablePlugin> it=plugins.iterator(); it.hasNext();) {
AvailablePlugin plugin = it.next();
if (serverVersion.compareTo(plugin.getMinServerVersion()) < 0) {
it.remove();
}
}
return plugins;
}
......@@ -576,9 +584,14 @@ public class UpdateManager extends BasicModule {
String currentVersion = server.getPluginManager().getVersion(plugin);
if (latestPlugin != null &&
latestPlugin.getLatestVersion().compareTo(currentVersion) > 0) {
Update update = new Update(pluginName, latestPlugin.getLatestVersion(),
latestPlugin.getChangelog(), latestPlugin.getURL());
pluginUpdates.add(update);
// Check if the update can run in the current version of the server
String serverVersion =
XMPPServer.getInstance().getServerInfo().getVersion().getVersionString();
if (serverVersion.compareTo(latestPlugin.getMinServerVersion()) >= 0) {
Update update = new Update(pluginName, latestPlugin.getLatestVersion(),
latestPlugin.getChangelog(), latestPlugin.getURL());
pluginUpdates.add(update);
}
}
}
}
......
......@@ -39,9 +39,9 @@
List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins();
// Sort plugins alphabetically
Collections.sort(plugins, new Comparator() {
public int compare(Object o1, Object o2) {
return ((AvailablePlugin)o1).getName().compareTo(((AvailablePlugin)o2).getName());
Collections.sort(plugins, new Comparator<AvailablePlugin>() {
public int compare(AvailablePlugin o1, AvailablePlugin o2) {
return o1.getName().compareTo(o2.getName());
}
});
......
......@@ -47,9 +47,9 @@
List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins();
// Sort plugins alphabetically
Collections.sort(plugins, new Comparator() {
public int compare(Object o1, Object o2) {
return ((AvailablePlugin) o1).getName().compareTo(((AvailablePlugin) o2).getName());
Collections.sort(plugins, new Comparator<AvailablePlugin>() {
public int compare(AvailablePlugin o1, AvailablePlugin o2) {
return o1.getName().compareTo(o2.getName());
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment