]> source.dussan.org Git - gitblit.git/commitdiff
Simplify current plugin release detection, ignore currentRelease registry field
authorJames Moger <james.moger@gitblit.com>
Wed, 23 Apr 2014 14:34:17 +0000 (10:34 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 23 Apr 2014 14:34:17 +0000 (10:34 -0400)
releases.moxie
src/main/java/com/gitblit/manager/PluginManager.java
src/main/java/com/gitblit/models/PluginRegistry.java
src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java

index 8360d778660346682db63f85f39dbb414f83d6dd..8e183f7423f59a1ea001033093b9afe5730aac5a 100644 (file)
@@ -12,6 +12,7 @@ r23: {
     fixes: ~
     changes:
     - improve French translation (pr-176)
+    - simplify current plugin release detection and ignore the currentRelease registry field 
     additions: ~
     dependencyChanges:
     - update to Apache MINA/SSHD 0.11.0 (issue-410)
index 9e6a31f62d2e7bb0b83e083f28bc1f291d639214..2ee48558de010b703e96085617de6d5784e8d9e9 100644 (file)
@@ -377,7 +377,7 @@ public class PluginManager implements IPluginManager, PluginStateListener {
                List<PluginRegistration> list = getRegisteredPlugins();
                Iterator<PluginRegistration> itr = list.iterator();
                while (itr.hasNext()) {
-                       if (state != itr.next().getInstallState()) {
+                       if (state != itr.next().getInstallState(getSystemVersion())) {
                                itr.remove();
                        }
                }
index 0c5d5a1990fd7af4312fada2be109d204696c37b..8da345782f065cf2f71a7734a09edaf88b461203 100644 (file)
@@ -80,8 +80,6 @@ public class PluginRegistry implements Serializable {
 \r
                public String projectUrl;\r
 \r
-               public String currentRelease;\r
-\r
                public transient String installedRelease;\r
 \r
                public transient String registry;\r
@@ -95,38 +93,17 @@ public class PluginRegistry implements Serializable {
 \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
+                       Date date = new Date(0);\r
+                       for (PluginRelease pv : releases) {\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
+                               if (!StringUtils.isEmpty(pv.requires)) {\r
+                                       requires = Version.createVersion(pv.requires);\r
                                }\r
-                       }\r
 \r
-                       if (current == null) {\r
-                               // find by date\r
-                               Date date = new Date(0);\r
-                               for (PluginRelease pv : releases) {\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
+                               if (system.isZero() || system.atLeast(requires)) {\r
+                                       if (pv.date.after(date)) {\r
+                                               current = pv;\r
+                                               date = pv.date;\r
                                        }\r
                                }\r
                        }\r
@@ -142,12 +119,16 @@ public class PluginRegistry implements Serializable {
                        return null;\r
                }\r
 \r
-               public InstallState getInstallState() {\r
+               public InstallState getInstallState(Version system) {\r
                        if (StringUtils.isEmpty(installedRelease)) {\r
                                return InstallState.NOT_INSTALLED;\r
                        }\r
                        Version ir = Version.createVersion(installedRelease);\r
-                       Version cr = Version.createVersion(currentRelease);\r
+                       Version cr = Version.ZERO;\r
+                       PluginRelease curr = getCurrentRelease(system);\r
+                       if (cr != null) {\r
+                               cr = Version.createVersion(curr.version);\r
+                       }\r
                        switch (ir.compareTo(cr)) {\r
                        case -1:\r
                                return InstallState.UNKNOWN;\r
index 42325e7990373089ae529458d7101001dc893762..ce0958c367a8a02aee6503a64f4c98a6cb4abdc0 100644 (file)
@@ -283,7 +283,7 @@ public class PluginDispatcher extends DispatchCommand {
                                state = Joiner.on(", ").join(InstallState.INSTALLED, pw.getPluginState());
                        } else {
                                // registered, installed plugin
-                               state = Joiner.on(", ").join(reg.getInstallState(), pw.getPluginState());
+                               state = Joiner.on(", ").join(reg.getInstallState(system), pw.getPluginState());
                        }
 
                        StringBuilder sb = new StringBuilder();
@@ -486,9 +486,9 @@ public class PluginDispatcher extends DispatchCommand {
                                        curr = new PluginRelease();
                                }
                                if (verbose) {
-                                       data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.registry};
+                                       data[i] = new Object[] {p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(system), p.registry};
                                } else {
-                                       data[i] = new Object[] {p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState()};
+                                       data[i] = new Object[] {p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState(system)};
                                }
                        }
 
@@ -504,9 +504,9 @@ public class PluginDispatcher extends DispatchCommand {
                                        curr = new PluginRelease();
                                }
                                if (verbose) {
-                                       outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(), p.provider, p.registry);
+                                       outTabbed(p.id, p.description, p.installedRelease, curr.version, curr.requires, p.getInstallState(system), p.provider, p.registry);
                                } else {
-                                       outTabbed(p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState());
+                                       outTabbed(p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState(system));
                                }
                        }
                }