this.releases = new ArrayList<PluginRelease>();\r
}\r
\r
- public PluginRelease getCurrentRelease() {\r
+ public PluginRelease getCurrentRelease(Version system) {\r
PluginRelease current = null;\r
if (!StringUtils.isEmpty(currentRelease)) {\r
// find specified\r
current = getRelease(currentRelease);\r
}\r
\r
+ if (current != null) {\r
+ // verify the current release is acceptable for this system\r
+ Version requires = Version.ZERO;\r
+ if (!StringUtils.isEmpty(current.requires)) {\r
+ requires = Version.createVersion(current.requires);\r
+ }\r
+\r
+ if (!system.isZero() && !system.atLeast(requires)) {\r
+ // requires newer system version\r
+ current = null;\r
+ }\r
+ }\r
+\r
if (current == null) {\r
// find by date\r
Date date = new Date(0);\r
for (PluginRelease pv : releases) {\r
- if (pv.date.after(date)) {\r
- current = pv;\r
+ Version requires = Version.ZERO;\r
+ if (!StringUtils.isEmpty(pv.requires)) {\r
+ requires = Version.createVersion(pv.requires);\r
+ }\r
+\r
+ if (system.isZero() || system.atLeast(requires)) {\r
+ if (pv.date.after(date)) {\r
+ current = pv;\r
+ date = pv.date;\r
+ }\r
}\r
}\r
}\r
}\r
}\r
\r
- public static class PluginRelease implements Comparable<PluginRelease> {\r
+ public static class PluginRelease implements Serializable, Comparable<PluginRelease> {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
public String version;\r
public Date date;\r
public String requires;\r
}
protected String buildFieldTable(PluginWrapper pw, PluginRegistration reg) {
+ Version system = getContext().getGitblit().getSystemVersion();
+ PluginRelease current = reg == null ? null : reg.getCurrentRelease(system);
+ if (current == null) {
+ current = new PluginRelease();
+ current.version = "";
+ current.requires = "";
+ }
+
final String id = pw == null ? reg.id : pw.getPluginId();
final String description = reg == null ? pw.getDescriptor().getPluginDescription() : reg.description;
- final String version = pw == null ? reg.getCurrentRelease().version : pw.getDescriptor().getVersion().toString();
- final String requires = pw == null ? reg.getCurrentRelease().requires : pw.getDescriptor().getRequires().toString();
+ final String version = pw == null ? current.version : pw.getDescriptor().getVersion().toString();
+ final String requires = pw == null ? current.requires : pw.getDescriptor().getRequires().toString();
final String provider = pw == null ? reg.provider : pw.getDescriptor().getProvider();
final String registry = reg == null ? "" : reg.registry;
final String path = pw == null ? "" : pw.getPluginPath();
String [] h = { "Id", "Installed", "Current", "Requires", "State" };
headers = h;
}
+ Version system = getContext().getGitblit().getSystemVersion();
Object[][] data = new Object[list.size()][];
for (int i = 0; i < list.size(); i++) {
PluginRegistration p = list.get(i);
- PluginRelease curr = p.getCurrentRelease();
+ PluginRelease curr = p.getCurrentRelease(system);
+ if (curr == null) {
+ curr = new PluginRelease();
+ }
if (verbose) {
data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.registry};
} else {
@Override
protected void asTabbed(List<PluginRegistration> list) {
+ Version system = getContext().getGitblit().getSystemVersion();
for (PluginRegistration p : list) {
- PluginRelease curr = p.getCurrentRelease();
+ PluginRelease curr = p.getCurrentRelease(system);
+ if (curr == null) {
+ curr = new PluginRelease();
+ }
if (verbose) {
outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.provider, p.registry);
} else {