| | |
| | | import com.gitblit.models.PluginRegistry.InstallState; |
| | | import com.gitblit.models.PluginRegistry.PluginRegistration; |
| | | import com.gitblit.models.PluginRegistry.PluginRelease; |
| | | import com.gitblit.models.UserModel; |
| | | import com.gitblit.utils.FlipTable; |
| | | import com.gitblit.utils.FlipTable.Borders; |
| | | import com.gitblit.utils.StringUtils; |
| | |
| | | public class PluginDispatcher extends DispatchCommand { |
| | | |
| | | @Override |
| | | protected void setup(UserModel user) { |
| | | register(user, ListPlugins.class); |
| | | register(user, StartPlugin.class); |
| | | register(user, StopPlugin.class); |
| | | register(user, EnablePlugin.class); |
| | | register(user, DisablePlugin.class); |
| | | register(user, ShowPlugin.class); |
| | | register(user, RefreshPlugins.class); |
| | | register(user, AvailablePlugins.class); |
| | | register(user, InstallPlugin.class); |
| | | register(user, UpgradePlugin.class); |
| | | register(user, UninstallPlugin.class); |
| | | protected void setup() { |
| | | register(ListPlugins.class); |
| | | register(StartPlugin.class); |
| | | register(StopPlugin.class); |
| | | register(EnablePlugin.class); |
| | | register(DisablePlugin.class); |
| | | register(ShowPlugin.class); |
| | | register(RefreshPlugins.class); |
| | | register(AvailablePlugins.class); |
| | | register(InstallPlugin.class); |
| | | register(UpgradePlugin.class); |
| | | register(UninstallPlugin.class); |
| | | } |
| | | |
| | | @CommandMetaData(name = "list", aliases = { "ls" }, description = "List plugins") |
| | |
| | | } |
| | | |
| | | 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(); |
| | |
| | | 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(); |
| | |
| | | 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}; |
| | | 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)}; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @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); |
| | | 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)); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (gitblit.installPlugin(urlOrId, !disableChecksum)) { |
| | | stdout.println(String.format("Installed %s", urlOrId)); |
| | | } else { |
| | | new UnloggedFailure(1, String.format("Failed to install %s", urlOrId)); |
| | | throw new UnloggedFailure(1, String.format("Failed to install %s", urlOrId)); |
| | | } |
| | | } else { |
| | | PluginRelease pr = gitblit.lookupRelease(urlOrId, version); |