private void removePluginFromLoader(final Plugin plugin) throws PluginException { if (plugin.isUninstallable()) { final PluginLoader pluginLoader = installedPluginsToPluginLoader.get(plugin); pluginLoader.removePlugin(plugin); } installedPluginsToPluginLoader.remove(plugin); }
/** * Called during plugin framework shutdown * * @param event The shutdown event */ @PluginEventListener public void onShutdown(final PluginFrameworkShutdownEvent event) { for (final Iterator<Plugin> it = plugins.values().iterator(); it.hasNext(); ) { final Plugin plugin = it.next(); if (plugin.isUninstallable()) { plugin.uninstall(); } it.remove(); } scanner.reset(); }
private PluginLoader ensurePluginAndLoaderSupportsUninstall(final Plugin plugin) { if (!plugin.isUninstallable()) { throw new PluginException("Plugin is not uninstallable: " + plugin); } final PluginLoader loader = installedPluginsToPluginLoader.get(plugin); if ((loader != null) && !loader.supportsRemoval()) { throw new PluginException("Not uninstalling plugin - loader doesn't allow removal. Plugin: " + plugin); } return loader; }
private void removeOldPlugin(String pluginKey) throws ConnectAddonInstallException { final Plugin plugin = pluginAccessor.getPlugin(pluginKey); /*! With the app key validated for the user, the previous app with that key, if any, is uninstalled. */ if (plugin != null) { if (plugin.isUninstallable() && !vertigoState.isVertigoInstance()) { pluginController.uninstall(plugin); } else { throw new ConnectAddonInstallException(String.format("Addon-key cannot match key of system plugin: %s", pluginKey)); } } else if (connectAddonManager.hasDescriptor(pluginKey)) { connectAddonManager.uninstallConnectAddonQuietly(pluginKey, emptyList(), true); } }
/** * @param plugin - the plugin to remove * @throws com.atlassian.plugin.PluginException representing the reason for failure. */ public void removePlugin(final Plugin plugin) throws PluginException { if (plugin.getPluginState() == PluginState.ENABLED) { throw new PluginException("Cannot remove enabled plugin '" + plugin.getKey() + '"'); } if (!plugin.isUninstallable()) { throw new PluginException("Cannot remove uninstallable plugin '" + plugin.getKey() + '"'); } final DeploymentUnit deploymentUnit = findMatchingDeploymentUnit(plugin); plugin.uninstall(); if (plugin.isDeleteable()) { // If this throws (which it does if the file exists, it's directory is writable, and yet deletion fails), // we will leak resources. However, this is not unique to this code, and i'm loathe to change the exception // behaviour here in case there are ramifications in UPM. If this is getting restructured in 4.0 we can // hopefully revisit when we've got a backward compatibility break point. deleteDeploymentUnit(deploymentUnit); } plugins.remove(deploymentUnit); log.info("Removed plugin '" + plugin.getKey() + "'"); }
newPlugin.setKey(oldPlugin.getKey()); newPlugin.setI18nNameKey(oldPlugin.getI18nNameKey()); newPlugin.setUninstallable(oldPlugin.isUninstallable()); newPlugin.setDeletable(oldPlugin.isDeleteable()); newPlugin.setPluginsVersion(oldPlugin.getPluginsVersion());