mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
fix missing X under substance
SPARK-1143 - Add Plugin Dependencies generic on user search git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@11737 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
michael.will
parent
5bacf95a64
commit
1ebb6c17ee
@ -19,21 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jivesoftware.spark;
|
package org.jivesoftware.spark;
|
||||||
|
|
||||||
import org.dom4j.Document;
|
|
||||||
import org.dom4j.DocumentException;
|
|
||||||
import org.dom4j.Element;
|
|
||||||
import org.dom4j.io.SAXReader;
|
|
||||||
import org.jivesoftware.MainWindowListener;
|
|
||||||
import org.jivesoftware.Spark;
|
|
||||||
import org.jivesoftware.spark.plugin.Plugin;
|
|
||||||
import org.jivesoftware.spark.plugin.PluginClassLoader;
|
|
||||||
import org.jivesoftware.spark.plugin.PublicPlugin;
|
|
||||||
import org.jivesoftware.spark.util.URLFileSystem;
|
|
||||||
import org.jivesoftware.spark.util.log.Log;
|
|
||||||
import org.jivesoftware.sparkimpl.settings.JiveInfo;
|
|
||||||
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -41,7 +26,6 @@ import java.io.FilenameFilter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -54,6 +38,22 @@ import java.util.jar.JarEntry;
|
|||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
|
import org.dom4j.Document;
|
||||||
|
import org.dom4j.DocumentException;
|
||||||
|
import org.dom4j.Element;
|
||||||
|
import org.dom4j.io.SAXReader;
|
||||||
|
import org.jivesoftware.MainWindowListener;
|
||||||
|
import org.jivesoftware.Spark;
|
||||||
|
import org.jivesoftware.spark.plugin.Plugin;
|
||||||
|
import org.jivesoftware.spark.plugin.PluginClassLoader;
|
||||||
|
import org.jivesoftware.spark.plugin.PluginDependency;
|
||||||
|
import org.jivesoftware.spark.plugin.PublicPlugin;
|
||||||
|
import org.jivesoftware.spark.util.URLFileSystem;
|
||||||
|
import org.jivesoftware.spark.util.log.Log;
|
||||||
|
import org.jivesoftware.sparkimpl.settings.JiveInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This manager is responsible for the loading of all Plugins and Workspaces within Spark environment.
|
* This manager is responsible for the loading of all Plugins and Workspaces within Spark environment.
|
||||||
*
|
*
|
||||||
@ -241,6 +241,22 @@ public class PluginManager implements MainWindowListener {
|
|||||||
Log.error("Unable to load plugin " + name + " due to no minSparkVersion.");
|
Log.error("Unable to load plugin " + name + " due to no minSparkVersion.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set dependencies
|
||||||
|
try {
|
||||||
|
List dependencies = plugin.selectNodes("depends/plugin");
|
||||||
|
for (Object depend1 : dependencies) {
|
||||||
|
Element depend = (Element) depend1;
|
||||||
|
PluginDependency dependency = new PluginDependency();
|
||||||
|
dependency.setVersion(depend.selectSingleNode("version").getText());
|
||||||
|
dependency.setName(depend.selectSingleNode("name").getText());
|
||||||
|
publicPlugin.addDependency(dependency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do operating system check.
|
// Do operating system check.
|
||||||
boolean operatingSystemOK = isOperatingSystemOK(plugin);
|
boolean operatingSystemOK = isOperatingSystemOK(plugin);
|
||||||
@ -406,6 +422,63 @@ public class PluginManager implements MainWindowListener {
|
|||||||
public void initializePlugins() {
|
public void initializePlugins() {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
int j = 0;
|
||||||
|
boolean dependsfound = false;
|
||||||
|
|
||||||
|
// Dependency check
|
||||||
|
for (int i = 0; i< publicPlugins.size(); i++) {
|
||||||
|
// if dependencies are available, check these
|
||||||
|
if(((PublicPlugin)publicPlugins.get(i)).getDependency().size()>0) {
|
||||||
|
List<PluginDependency> dependencies = ((PublicPlugin)publicPlugins.get(i)).getDependency();
|
||||||
|
|
||||||
|
// go trough all dependencies
|
||||||
|
for( PluginDependency dependency : dependencies) {
|
||||||
|
j = 0;
|
||||||
|
dependsfound = false;
|
||||||
|
// look for the specific plugin
|
||||||
|
for(PublicPlugin plugin1 :publicPlugins) {
|
||||||
|
|
||||||
|
if(plugin1.getName()!= null
|
||||||
|
&& plugin1.getName().equals(dependency.getName())) {
|
||||||
|
|
||||||
|
// if the version is compatible then reorder
|
||||||
|
if(dependency.compareVersion(plugin1.getVersion())){
|
||||||
|
dependsfound = true;
|
||||||
|
// when depended Plugin hadn't been installed yet
|
||||||
|
if(j>i){
|
||||||
|
|
||||||
|
// change the order
|
||||||
|
publicPlugins.add(i, publicPlugins.get(j));
|
||||||
|
publicPlugins.remove(j+1);
|
||||||
|
|
||||||
|
plugins.add(i, plugins.get(j));
|
||||||
|
plugins.remove(j+1);
|
||||||
|
|
||||||
|
// start again, to check the other dependencies
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// else don't load the plugin and show an error
|
||||||
|
else {
|
||||||
|
Log.error("Depended Plugin " + dependency.getName() + " hasn't the right version (" + dependency.getVersion() + "<>" + ((PublicPlugin)publicPlugins.get(i)).getVersion());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
// if the depended Plugin wasn't found, then show error
|
||||||
|
if(!dependsfound) {
|
||||||
|
Log.error("Depended Plugin " + dependency.getName() + " is missing for the Plugin " + ((PublicPlugin)publicPlugins.get(i)).getName());
|
||||||
|
// delete the Plugin, because the depended Plugin is missing
|
||||||
|
publicPlugins.remove(i);
|
||||||
|
plugins.remove(i);
|
||||||
|
i--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
for (Plugin plugin1 : plugins) {
|
for (Plugin plugin1 : plugins) {
|
||||||
|
|||||||
71
src/java/org/jivesoftware/spark/plugin/PluginDependency.java
Normal file
71
src/java/org/jivesoftware/spark/plugin/PluginDependency.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package org.jivesoftware.spark.plugin;
|
||||||
|
|
||||||
|
import net.java.sipmack.common.Log;
|
||||||
|
|
||||||
|
public class PluginDependency
|
||||||
|
{
|
||||||
|
private String name;
|
||||||
|
private String version;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean compareVersion(String version) {
|
||||||
|
|
||||||
|
if(version != null && getVersion() != null) {
|
||||||
|
String checkVersion[] = version.split("\\.");
|
||||||
|
String originalVersion[] = getVersion().split("\\.");
|
||||||
|
int maxlength = (originalVersion.length >= checkVersion.length)?originalVersion.length:checkVersion.length;
|
||||||
|
|
||||||
|
|
||||||
|
// go through all Version-parts
|
||||||
|
for(int i= 0; i < maxlength; i++) {
|
||||||
|
// if the checked version is too short
|
||||||
|
if ( checkVersion.length <= i
|
||||||
|
&& originalVersion[i].equals(0))
|
||||||
|
return true;
|
||||||
|
else if (checkVersion.length <= i)
|
||||||
|
return false;
|
||||||
|
// if the original version is long enough
|
||||||
|
if(originalVersion.length > i) {
|
||||||
|
|
||||||
|
// convert to integer
|
||||||
|
try {
|
||||||
|
int originalVersNumber = Integer.valueOf(originalVersion[i]).intValue();
|
||||||
|
int checkVersNumber = Integer.valueOf(checkVersion[i]).intValue();
|
||||||
|
|
||||||
|
// check the numbers
|
||||||
|
if(checkVersNumber > originalVersNumber) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if(checkVersNumber < originalVersNumber) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
Log.error("Version " + checkVersion + " contains letters.", e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,6 +20,8 @@
|
|||||||
package org.jivesoftware.spark.plugin;
|
package org.jivesoftware.spark.plugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PublicPlugin {
|
public class PublicPlugin {
|
||||||
private String name;
|
private String name;
|
||||||
@ -35,9 +37,9 @@ public class PublicPlugin {
|
|||||||
private boolean smallIconAvailable;
|
private boolean smallIconAvailable;
|
||||||
private boolean largeIconAvailable;
|
private boolean largeIconAvailable;
|
||||||
private String minVersion;
|
private String minVersion;
|
||||||
|
|
||||||
private File pluginDir;
|
private File pluginDir;
|
||||||
|
private List<PluginDependency> dependencies = new ArrayList<PluginDependency>();
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -149,4 +151,12 @@ public class PublicPlugin {
|
|||||||
public void setMinVersion(String minVersion) {
|
public void setMinVersion(String minVersion) {
|
||||||
this.minVersion = minVersion;
|
this.minVersion = minVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addDependency(PluginDependency dependency) {
|
||||||
|
dependencies.add(dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PluginDependency> getDependency() {
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1151,13 +1151,6 @@ public class ChatContainer extends SparkTabbedPane implements MessageListener, C
|
|||||||
chatFrame = new ChatFrame();
|
chatFrame = new ChatFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The ultimate workground for 1.6
|
|
||||||
chatFrame.dispose();
|
|
||||||
chatFrame.setFocusableWindowState(false);
|
|
||||||
chatFrame.setFocusableWindowState(true);
|
|
||||||
chatFrame.dispose();
|
|
||||||
|
|
||||||
|
|
||||||
chatFrame.addWindowListener(new WindowAdapter() {
|
chatFrame.addWindowListener(new WindowAdapter() {
|
||||||
public void windowActivated(WindowEvent windowEvent) {
|
public void windowActivated(WindowEvent windowEvent) {
|
||||||
stopFlashing();
|
stopFlashing();
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package org.jivesoftware.sparkimpl.search.users;
|
package org.jivesoftware.sparkimpl.search.users;
|
||||||
|
|
||||||
|
import org.jivesoftware.Spark;
|
||||||
import org.jivesoftware.resource.Res;
|
import org.jivesoftware.resource.Res;
|
||||||
import org.jivesoftware.resource.SparkRes;
|
import org.jivesoftware.resource.SparkRes;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
@ -61,10 +62,11 @@ import java.io.IOException;
|
|||||||
* UserSearchForm is used to do explicit searching of users using the JEP 55 Search Service.
|
* UserSearchForm is used to do explicit searching of users using the JEP 55 Search Service.
|
||||||
*/
|
*/
|
||||||
public class UserSearchForm extends JPanel {
|
public class UserSearchForm extends JPanel {
|
||||||
|
private static final long serialVersionUID = -9192188543673595941L;
|
||||||
private JComboBox servicesBox;
|
private JComboBox servicesBox;
|
||||||
private UserSearchManager searchManager;
|
private UserSearchManager searchManager;
|
||||||
|
|
||||||
private Collection searchServices;
|
private Collection<String> searchServices;
|
||||||
|
|
||||||
private CardLayout cardLayout = new CardLayout();
|
private CardLayout cardLayout = new CardLayout();
|
||||||
private JPanel cardPanel = new JPanel();
|
private JPanel cardPanel = new JPanel();
|
||||||
@ -74,14 +76,14 @@ public class UserSearchForm extends JPanel {
|
|||||||
private Map<String,SearchForm> serviceMap = new HashMap<String,SearchForm>();
|
private Map<String,SearchForm> serviceMap = new HashMap<String,SearchForm>();
|
||||||
|
|
||||||
|
|
||||||
private static File pluginsettings = new File(System.getProperty("user.home") + "\\Spark\\search.properties"); //new
|
private static File pluginsettings = new File(Spark.getSparkUserHome() + File.separator + "search.properties"); //new
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the UserSearchForm with all available search services.
|
* Initializes the UserSearchForm with all available search services.
|
||||||
*
|
*
|
||||||
* @param searchServices a Collection of all search services found.
|
* @param searchServices a Collection of all search services found.
|
||||||
*/
|
*/
|
||||||
public UserSearchForm(Collection searchServices) {
|
public UserSearchForm(Collection<String> searchServices) {
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
cardPanel.setLayout(cardLayout);
|
cardPanel.setLayout(cardLayout);
|
||||||
@ -104,9 +106,9 @@ public class UserSearchForm extends JPanel {
|
|||||||
// Populate with Search Services
|
// Populate with Search Services
|
||||||
servicesBox = new JComboBox();
|
servicesBox = new JComboBox();
|
||||||
|
|
||||||
for (Object searchService : searchServices) {
|
for (String searchService : searchServices) {
|
||||||
String service = (String) searchService;
|
String service = searchService;
|
||||||
servicesBox.addItem(service);
|
servicesBox.addItem(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -122,12 +124,10 @@ public class UserSearchForm extends JPanel {
|
|||||||
props.load(new FileInputStream(pluginsettings));
|
props.load(new FileInputStream(pluginsettings));
|
||||||
String testsearch;
|
String testsearch;
|
||||||
numbprop_bool=true;
|
numbprop_bool=true;
|
||||||
while (numbprop_bool)
|
while (numbprop_bool) {
|
||||||
{
|
|
||||||
nextprop = "search"+numbprop;
|
nextprop = "search"+numbprop;
|
||||||
testsearch = props.getProperty(nextprop);
|
testsearch = props.getProperty(nextprop);
|
||||||
if (null != testsearch)
|
if (null != testsearch) {
|
||||||
{
|
|
||||||
Log.warning("Search-Info: SearchService-" + numbprop + " from properties-file is " + nextprop + " : " + testsearch);
|
Log.warning("Search-Info: SearchService-" + numbprop + " from properties-file is " + nextprop + " : " + testsearch);
|
||||||
servicesBox.addItem(testsearch);
|
servicesBox.addItem(testsearch);
|
||||||
numbprop++;
|
numbprop++;
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
package org.jivesoftware.spark.plugin;
|
||||||
|
|
||||||
|
import org.jivesoftware.spark.plugin.PluginDependency;
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
|
public class PluginDependencyTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testCompare()
|
||||||
|
{
|
||||||
|
PluginDependency depend = new PluginDependency();
|
||||||
|
depend.setName("Test");
|
||||||
|
depend.setVersion("1.0.0");
|
||||||
|
|
||||||
|
assertTrue(depend.compareVersion("1.0.0"));
|
||||||
|
assertTrue(depend.compareVersion("1.1"));
|
||||||
|
assertTrue(depend.compareVersion("1.1.1"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.0"));
|
||||||
|
assertTrue(depend.compareVersion("1.9.0.0"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.1"));
|
||||||
|
assertTrue(depend.compareVersion("1.9.1"));
|
||||||
|
|
||||||
|
|
||||||
|
depend.setVersion("2.0.0.0");
|
||||||
|
assertTrue(depend.compareVersion("2.1"));
|
||||||
|
assertTrue(depend.compareVersion("2.1.1"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.0"));
|
||||||
|
assertTrue(depend.compareVersion("2.9.0.0"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.1"));
|
||||||
|
assertTrue(depend.compareVersion("2.9.1"));
|
||||||
|
|
||||||
|
depend.setVersion("2.1");
|
||||||
|
assertTrue(depend.compareVersion("2.1"));
|
||||||
|
assertTrue(depend.compareVersion("2.1.1"));
|
||||||
|
assertTrue(depend.compareVersion("2.1.0"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.0"));
|
||||||
|
assertTrue(depend.compareVersion("2.9.0.0"));
|
||||||
|
assertFalse(depend.compareVersion("0.9.1"));
|
||||||
|
assertTrue(depend.compareVersion("2.9.1"));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user