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 { ...@@ -276,13 +276,13 @@ public class UpdateManager extends BasicModule {
/** /**
* Returns the list of available plugins to install as reported by igniterealtime.org. * 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. * @return the list of available plugins to install as reported by igniterealtime.org.
*/ */
public List<AvailablePlugin> getNotInstalledPlugins() { public List<AvailablePlugin> getNotInstalledPlugins() {
ArrayList<AvailablePlugin> plugins = List<AvailablePlugin> plugins = new ArrayList<AvailablePlugin>(availablePlugins.values());
new ArrayList<AvailablePlugin>(availablePlugins.values());
XMPPServer server = XMPPServer.getInstance(); XMPPServer server = XMPPServer.getInstance();
// Remove installed plugins from the list of available plugins // Remove installed plugins from the list of available plugins
for (Plugin plugin : server.getPluginManager().getPlugins()) { for (Plugin plugin : server.getPluginManager().getPlugins()) {
...@@ -295,6 +295,14 @@ public class UpdateManager extends BasicModule { ...@@ -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; return plugins;
} }
...@@ -576,9 +584,14 @@ public class UpdateManager extends BasicModule { ...@@ -576,9 +584,14 @@ public class UpdateManager extends BasicModule {
String currentVersion = server.getPluginManager().getVersion(plugin); String currentVersion = server.getPluginManager().getVersion(plugin);
if (latestPlugin != null && if (latestPlugin != null &&
latestPlugin.getLatestVersion().compareTo(currentVersion) > 0) { latestPlugin.getLatestVersion().compareTo(currentVersion) > 0) {
Update update = new Update(pluginName, latestPlugin.getLatestVersion(), // Check if the update can run in the current version of the server
latestPlugin.getChangelog(), latestPlugin.getURL()); String serverVersion =
pluginUpdates.add(update); 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 @@ ...@@ -39,9 +39,9 @@
List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins(); List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins();
// Sort plugins alphabetically // Sort plugins alphabetically
Collections.sort(plugins, new Comparator() { Collections.sort(plugins, new Comparator<AvailablePlugin>() {
public int compare(Object o1, Object o2) { public int compare(AvailablePlugin o1, AvailablePlugin o2) {
return ((AvailablePlugin)o1).getName().compareTo(((AvailablePlugin)o2).getName()); return o1.getName().compareTo(o2.getName());
} }
}); });
......
...@@ -47,9 +47,9 @@ ...@@ -47,9 +47,9 @@
List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins(); List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins();
// Sort plugins alphabetically // Sort plugins alphabetically
Collections.sort(plugins, new Comparator() { Collections.sort(plugins, new Comparator<AvailablePlugin>() {
public int compare(Object o1, Object o2) { public int compare(AvailablePlugin o1, AvailablePlugin o2) {
return ((AvailablePlugin) o1).getName().compareTo(((AvailablePlugin) o2).getName()); 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