提交 1e11a2fd 编写于 作者: K kohsuke

this is more OO.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11395 71c3de6d-444a-0410-be80-ed276b4c234a
上级 1436bf77
......@@ -477,16 +477,8 @@ public final class PluginWrapper {
public UpdateCenter.Plugin getUpdateInfo() {
UpdateCenter uc = Hudson.getInstance().getUpdateCenter();
UpdateCenter.Plugin p = uc.getPlugin(getShortName());
if(p==null) return null;
try {
if(new VersionNumber(getVersion()).compareTo(new VersionNumber(p.version)) < 0)
return p;
if(p!=null && p.isNewerThan(getVersion())) return p;
return null;
} catch (IllegalArgumentException e) {
// couldn't parse it as the version number. ignore.
return null;
}
}
/**
......
......@@ -7,6 +7,7 @@ import hudson.Util;
import hudson.ProxyConfiguration;
import hudson.util.DaemonThreadFactory;
import hudson.util.TextFile;
import hudson.util.VersionNumber;
import static hudson.util.TimeUnit2.DAYS;
import net.sf.json.JSONObject;
import org.apache.commons.io.input.CountingInputStream;
......@@ -264,6 +265,24 @@ public class UpdateCenter implements ModelObject {
this.version = o.getString("version");
this.url = o.getString("url");
}
/**
* Checks if the specified "current version" is older than the version of this entry.
*
* @param currentVersion
* The string that represents the version number to be compared.
* @return
* true if the version listed in this entry is newer.
* false otherwise, including the situation where the strings couldn't be parsed as version numbers.
*/
public boolean isNewerThan(String currentVersion) {
try {
return new VersionNumber(currentVersion).compareTo(new VersionNumber(version)) < 0;
} catch (IllegalArgumentException e) {
// couldn't parse as the version number.
return false;
}
}
}
public final class Plugin extends Entry {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册