From fad6b4a3d5f9a7fe7f7bced14e591478cf959bb3 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sat, 12 Apr 2014 13:27:25 -0400 Subject: [PATCH] Eliminate plugin name, stick with id and description --- .../com/gitblit/manager/GitblitManager.java | 8 +++--- .../com/gitblit/manager/PluginManager.java | 8 +++--- .../com/gitblit/models/PluginRegistry.java | 7 ++--- .../ssh/commands/PluginDispatcher.java | 28 ++++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java index 5fca0c24..9510de80 100644 --- a/src/main/java/com/gitblit/manager/GitblitManager.java +++ b/src/main/java/com/gitblit/manager/GitblitManager.java @@ -1270,12 +1270,12 @@ public class GitblitManager implements IGitblit { } @Override - public PluginRegistration lookupPlugin(String idOrName) { - return pluginManager.lookupPlugin(idOrName); + public PluginRegistration lookupPlugin(String pluginId) { + return pluginManager.lookupPlugin(pluginId); } @Override - public PluginRelease lookupRelease(String idOrName, String version) { - return pluginManager.lookupRelease(idOrName, version); + public PluginRelease lookupRelease(String pluginId, String version) { + return pluginManager.lookupRelease(pluginId, version); } } diff --git a/src/main/java/com/gitblit/manager/PluginManager.java b/src/main/java/com/gitblit/manager/PluginManager.java index 1c26fa15..5bd97ea2 100644 --- a/src/main/java/com/gitblit/manager/PluginManager.java +++ b/src/main/java/com/gitblit/manager/PluginManager.java @@ -320,9 +320,9 @@ public class PluginManager implements IPluginManager, PluginStateListener { } @Override - public synchronized PluginRegistration lookupPlugin(String idOrName) { + public synchronized PluginRegistration lookupPlugin(String pluginId) { for (PluginRegistration reg : getRegisteredPlugins()) { - if (reg.id.equalsIgnoreCase(idOrName) || reg.name.equalsIgnoreCase(idOrName)) { + if (reg.id.equalsIgnoreCase(pluginId)) { return reg; } } @@ -330,8 +330,8 @@ public class PluginManager implements IPluginManager, PluginStateListener { } @Override - public synchronized PluginRelease lookupRelease(String idOrName, String version) { - PluginRegistration reg = lookupPlugin(idOrName); + public synchronized PluginRelease lookupRelease(String pluginId, String version) { + PluginRegistration reg = lookupPlugin(pluginId); if (reg == null) { return null; } diff --git a/src/main/java/com/gitblit/models/PluginRegistry.java b/src/main/java/com/gitblit/models/PluginRegistry.java index b5cf0ee1..6d82b97e 100644 --- a/src/main/java/com/gitblit/models/PluginRegistry.java +++ b/src/main/java/com/gitblit/models/PluginRegistry.java @@ -47,10 +47,9 @@ public class PluginRegistry implements Serializable { } } - public PluginRegistration lookup(String idOrName) { + public PluginRegistration lookup(String id) { for (PluginRegistration registration : registrations) { - if (registration.id.equalsIgnoreCase(idOrName) - || registration.name.equalsIgnoreCase(idOrName)) { + if (registration.id.equalsIgnoreCase(id)) { return registration; } } @@ -75,8 +74,6 @@ public class PluginRegistry implements Serializable { public final String id; - public String name; - public String description; public String provider; diff --git a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java index 19cefe02..e33a2c91 100644 --- a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java +++ b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatcher.java @@ -73,7 +73,7 @@ public class PluginDispatcher extends DispatchCommand { protected void asTable(List list) { String[] headers; if (verbose) { - String [] h = { "#", "Id", "Version", "State", "Path", "Provider"}; + String [] h = { "#", "Id", "Description", "Version", "Requires", "State", "Path", "Provider"}; headers = h; } else { String [] h = { "#", "Id", "Version", "State", "Path"}; @@ -84,7 +84,7 @@ public class PluginDispatcher extends DispatchCommand { PluginWrapper p = list.get(i); PluginDescriptor d = p.getDescriptor(); if (verbose) { - data[i] = new Object[] { "" + (i + 1), d.getPluginId(), d.getVersion(), p.getPluginState(), p.getPluginPath(), d.getProvider() }; + data[i] = new Object[] { "" + (i + 1), d.getPluginId(), null/*d.getDescription()*/, d.getVersion(), null/*d.getRequires()*/, p.getPluginState(), p.getPluginPath(), d.getProvider() }; } else { data[i] = new Object[] { "" + (i + 1), d.getPluginId(), d.getVersion(), p.getPluginState(), p.getPluginPath() }; } @@ -98,7 +98,7 @@ public class PluginDispatcher extends DispatchCommand { for (PluginWrapper pw : list) { PluginDescriptor d = pw.getDescriptor(); if (verbose) { - outTabbed(d.getPluginId(), d.getVersion(), pw.getPluginState(), pw.getPluginPath(), d.getProvider()); + outTabbed(d.getPluginId(), null/*d.getDescription()*/, d.getVersion(), null/*d.getRequires()*/, pw.getPluginState(), pw.getPluginPath(), d.getProvider()); } else { outTabbed(d.getPluginId(), d.getVersion(), pw.getPluginState(), pw.getPluginPath()); } @@ -256,8 +256,9 @@ public class PluginDispatcher extends DispatchCommand { protected String buildFieldTable(PluginWrapper pw, PluginRegistration reg) { final String id = pw == null ? reg.id : pw.getPluginId(); - final String name = reg == null ? "" : reg.name; - final String version = pw == null ? "" : pw.getDescriptor().getVersion().toString(); + final String description = reg == null ? ""/*pw.getDescriptor().getDescription()*/ : 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 provider = pw == null ? reg.provider : pw.getDescriptor().getProvider(); final String registry = reg == null ? "" : reg.registry; final String path = pw == null ? "" : pw.getPluginPath(); @@ -277,10 +278,11 @@ public class PluginDispatcher extends DispatchCommand { StringBuilder sb = new StringBuilder(); sb.append("ID : ").append(id).append('\n'); sb.append("Version : ").append(version).append('\n'); + sb.append("Requires : ").append(requires).append('\n'); sb.append("State : ").append(state).append('\n'); sb.append("Path : ").append(path).append('\n'); sb.append('\n'); - sb.append("Name : ").append(name).append('\n'); + sb.append("Description : ").append(description).append('\n'); sb.append("Provider : ").append(provider).append('\n'); sb.append("Project URL : ").append(projectUrl).append('\n'); sb.append("Registry : ").append(registry).append('\n'); @@ -451,17 +453,17 @@ public class PluginDispatcher extends DispatchCommand { @Override protected boolean matches(String filter, PluginRegistration t) { - return t.id.matches(filter) || t.name.matches(filter); + return t.id.matches(filter) || (t.description != null && t.description.matches(filter)); } @Override protected void asTable(List list) { String[] headers; if (verbose) { - String [] h = { "Id", "Name", "Description", "Installed", "Current", "Requires", "State", "Registry" }; + String [] h = { "Id", "Description", "Installed", "Current", "Requires", "State", "Registry" }; headers = h; } else { - String [] h = { "Id", "Name", "Installed", "Current", "Requires", "State" }; + String [] h = { "Id", "Installed", "Current", "Requires", "State" }; headers = h; } Object[][] data = new Object[list.size()][]; @@ -469,9 +471,9 @@ public class PluginDispatcher extends DispatchCommand { PluginRegistration p = list.get(i); PluginRelease curr = p.getCurrentRelease(); if (verbose) { - data[i] = new Object[] {p.id, p.name, 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(), p.registry}; } else { - data[i] = new Object[] {p.id, p.name, p.installedRelease, curr.version, curr.requires, p.getInstallState()}; + data[i] = new Object[] {p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState()}; } } @@ -483,9 +485,9 @@ public class PluginDispatcher extends DispatchCommand { for (PluginRegistration p : list) { PluginRelease curr = p.getCurrentRelease(); if (verbose) { - outTabbed(p.id, p.name, 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(), p.provider, p.registry); } else { - outTabbed(p.id, p.name, p.installedRelease, curr.version, curr.requires, p.getInstallState()); + outTabbed(p.id, p.installedRelease, curr.version, curr.requires, p.getInstallState()); } } } -- 2.39.5