mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-17 05:52:26 +00:00
this is more OO.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11395 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
1436bf7798
commit
1e11a2fd39
2 files changed
+21
-10
No files matched your search
@@ -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;
|
||||
return null;
|
||||
} catch (IllegalArgumentException e) {
|
||||
// couldn't parse it as the version number. ignore.
|
||||
return null;
|
||||
}
|
||||
if(p!=null && p.isNewerThan(getVersion())) return p;
|
||||
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 {
|
||||
|
||||
Reference in new issue
Block a user