| | |
| | | |
| | | public PluginManager(IRuntimeManager runtimeManager) { |
| | | File dir = runtimeManager.getFileOrFolder(Keys.plugins.folder, "${baseFolder}/plugins"); |
| | | dir.mkdirs(); |
| | | this.runtimeManager = runtimeManager; |
| | | this.pf4j = new DefaultPluginManager(dir); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public synchronized boolean refreshRegistry() { |
| | | public synchronized boolean refreshRegistry(boolean verifyChecksum) { |
| | | String dr = "http://gitblit.github.io/gitblit-registry/plugins.json"; |
| | | String url = runtimeManager.getSettings().getString(Keys.plugins.registry, dr); |
| | | try { |
| | | File file = download(url, true); |
| | | File file = download(url, verifyChecksum); |
| | | if (file != null && file.exists()) { |
| | | URL selfUrl = new URL(url.substring(0, url.lastIndexOf('/'))); |
| | | // replace ${self} with the registry url |
| | |
| | | File[] files = folder.listFiles(jsonFilter); |
| | | if (files == null || files.length == 0) { |
| | | // automatically retrieve the registry if we don't have a local copy |
| | | refreshRegistry(); |
| | | refreshRegistry(true); |
| | | files = folder.listFiles(jsonFilter); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @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; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | @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; |
| | | } |