diff options
author | James Moger <james.moger@gitblit.com> | 2014-04-17 23:03:34 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-17 23:08:07 -0400 |
commit | 80cf76b88cb9b9c1696c48fd418c0cdee995812c (patch) | |
tree | 972b4b5dc2fd76743f35747ea0c9b4389d8af922 /src/main/java/com/gitblit/models/PluginRegistry.java | |
parent | 6b254fe9f76c202065153ac045859b8434c81c73 (diff) | |
download | gitblit-80cf76b88cb9b9c1696c48fd418c0cdee995812c.tar.gz gitblit-80cf76b88cb9b9c1696c48fd418c0cdee995812c.zip |
Filter the current plugin release by the system version
Diffstat (limited to 'src/main/java/com/gitblit/models/PluginRegistry.java')
-rw-r--r-- | src/main/java/com/gitblit/models/PluginRegistry.java | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/main/java/com/gitblit/models/PluginRegistry.java b/src/main/java/com/gitblit/models/PluginRegistry.java index ef463163..0c5d5a19 100644 --- a/src/main/java/com/gitblit/models/PluginRegistry.java +++ b/src/main/java/com/gitblit/models/PluginRegistry.java @@ -93,19 +93,40 @@ public class PluginRegistry implements Serializable { this.releases = new ArrayList<PluginRelease>();
}
- public PluginRelease getCurrentRelease() {
+ public PluginRelease getCurrentRelease(Version system) {
PluginRelease current = null;
if (!StringUtils.isEmpty(currentRelease)) {
// find specified
current = getRelease(currentRelease);
}
+ if (current != null) {
+ // verify the current release is acceptable for this system
+ Version requires = Version.ZERO;
+ if (!StringUtils.isEmpty(current.requires)) {
+ requires = Version.createVersion(current.requires);
+ }
+
+ if (!system.isZero() && !system.atLeast(requires)) {
+ // requires newer system version
+ current = null;
+ }
+ }
+
if (current == null) {
// find by date
Date date = new Date(0);
for (PluginRelease pv : releases) {
- if (pv.date.after(date)) {
- current = pv;
+ Version requires = Version.ZERO;
+ if (!StringUtils.isEmpty(pv.requires)) {
+ requires = Version.createVersion(pv.requires);
+ }
+
+ if (system.isZero() || system.atLeast(requires)) {
+ if (pv.date.after(date)) {
+ current = pv;
+ date = pv.date;
+ }
}
}
}
@@ -143,7 +164,10 @@ public class PluginRegistry implements Serializable { }
}
- public static class PluginRelease implements Comparable<PluginRelease> {
+ public static class PluginRelease implements Serializable, Comparable<PluginRelease> {
+
+ private static final long serialVersionUID = 1L;
+
public String version;
public Date date;
public String requires;
|