Author: mes
Date: 2010-02-01 16:38:11 -0800 (Mon, 01 Feb 2010)
New Revision: 19110
Modified:
cytoscape/trunk/src/cytoscape/plugin/DownloadableInfo.java
Log:
Fixed a potential NPE that was seen on the cytoscape-discuss mailing list.
Modified: cytoscape/trunk/src/cytoscape/plugin/DownloadableInfo.java
===================================================================
--- cytoscape/trunk/src/cytoscape/plugin/DownloadableInfo.java 2010-02-02
00:37:43 UTC (rev 19109)
+++ cytoscape/trunk/src/cytoscape/plugin/DownloadableInfo.java 2010-02-02
00:38:11 UTC (rev 19110)
@@ -36,6 +36,7 @@
package cytoscape.plugin;
import java.net.URL;
+import java.io.IOException;
import cytoscape.util.URLUtil;
import cytoscape.logger.CyLogger;
@@ -44,14 +45,17 @@
import static cytoscape.plugin.PluginVersionUtils.versionOk;
import static cytoscape.plugin.PluginVersionUtils.getNewerVersion;
-
import java.util.Set;
import java.util.HashSet;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
public abstract class DownloadableInfo {
- private static CyLogger logger = CyLogger.getLogger(DownloadableInfo.class);
+ private static CyLogger logger =
CyLogger.getLogger(DownloadableInfo.class);
- protected String versionMatch = PluginVersionUtils.versionMatch;
+ protected String versionMatch = PluginVersionUtils.versionMatch;
+
protected String versionSplit = PluginVersionUtils.versionSplit;
private String releaseDate;
@@ -64,7 +68,6 @@
private String objVersion;
-
private String downloadURL = "";
private String objURL = "";
@@ -77,25 +80,22 @@
private Set<String> compatibleCyVersions;
- private DownloadableInfo parentObj = null;
+ private DownloadableInfo parentObj;
public DownloadableInfo() {
- compatibleCyVersions = new HashSet<String>();
+ this(null,null);
}
- public DownloadableInfo(String ID) {
- this.uniqueID = ID;
- compatibleCyVersions = new HashSet<String>();
+ public DownloadableInfo(String id) {
+ this(id, null);
}
- public DownloadableInfo(String ID, DownloadableInfo ParentObj) {
- this.uniqueID = ID;
- this.parentObj = ParentObj;
- compatibleCyVersions = new HashSet<String>();
+ public DownloadableInfo(String id, DownloadableInfo parentObj) {
+ this.uniqueID = id;
+ this.parentObj = parentObj;
+ this.compatibleCyVersions = new HashSet<String>();
}
- /* --- SET --- */
-
/**
* Sets the license information for the plugin. Not required.
*
@@ -133,8 +133,8 @@
this.category = cat.toString();
}
- public void setParent(DownloadableInfo ParentObj) {
- this.parentObj = ParentObj;
+ public void setParent(DownloadableInfo parentObj) {
+ this.parentObj = parentObj;
}
/**
@@ -335,8 +335,8 @@
/**
* @return All compatible Cytoscape versions.
*/
- public java.util.List<String> getCytoscapeVersions() {
- return new
java.util.ArrayList<String>(this.compatibleCyVersions);
+ public List<String> getCytoscapeVersions() {
+ return new ArrayList<String>(this.compatibleCyVersions);
}
protected boolean containsVersion(String cyVersion) {
@@ -394,14 +394,19 @@
* specifies a bugfix version)
*/
private boolean isCytoscapeVersionCurrent(String pluginVersion) {
- String[] CyVersion = new
cytoscape.CytoscapeVersion().getFullVersion().split(versionSplit);
- String[] PlVersion = pluginVersion.split(versionSplit);
+ if (pluginVersion == null )
+ return false;
- for (int i = 0; i < PlVersion.length; i++) {
- if (Integer.valueOf(CyVersion[i]).intValue() != Integer.valueOf(
- PlVersion[i]).intValue())
+ String[] cyVersion = new
CytoscapeVersion().getFullVersion().split(versionSplit);
+ String[] plVersion = pluginVersion.split(versionSplit);
+
+ if ( cyVersion.length < plVersion.length )
+ return false;
+
+ for (int i = 0; i < plVersion.length; i++)
+ if (Integer.valueOf(cyVersion[i]).intValue() !=
Integer.valueOf(plVersion[i]).intValue())
return false;
- }
+
return true;
}
@@ -431,7 +436,7 @@
if ( PluginVersionUtils.isVersion(pluginVersion,
PluginVersionUtils.MINOR) ) {
cyVersion = new String[]{cyVersion[0], cyVersion[1]};
}
- logger.debug("Comparing versions: " +
java.util.Arrays.toString(cyVersion) + " : " +
java.util.Arrays.toString(plVersion));
+ logger.debug("Comparing versions: " + Arrays.toString(cyVersion) + " : "
+ Arrays.toString(plVersion));
if (compareVersions(cyVersion, plVersion)) {
compatible = true;
@@ -530,16 +535,15 @@
* Fetches and keeps a plugin license if one is available.
*/
protected class License {
- private java.net.URL url;
-
+ private URL url;
private String text;
- public License(java.net.URL Url) {
- url = Url;
+ public License(URL url) {
+ this.url = url;
}
- public License(String LicenseText) {
- text = LicenseText;
+ public License(String licenseText) {
+ text = licenseText;
}
/**
@@ -552,13 +556,12 @@
if (text == null) {
try {
text = URLUtil.download(url);
- } catch (java.io.IOException E) {
- DownloadableInfo.logger.warn("Unable to
get license: "+E.toString());
+ } catch (Exception e) {
+ DownloadableInfo.logger.warn("Unable to
get license: "+e.toString());
+ text = "No license found";
}
}
return text;
}
-
}
-
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.