/** * Returns a module descriptor identified by key. * * @param key The key of the module descriptor * @return The module descriptor */ protected ModuleDescriptor<?> getDescriptor(final String key) { return pluginAccessor.getPlugin(Constants.PLUGIN_KEY) .getModuleDescriptor(key); } }
/** * Registers descriptors. * * @param descriptors the module descriptors of the plugin * @return a representation of the descriptor registration */ public Registration registerDescriptors(Iterable<ModuleDescriptor<?>> descriptors) { final List<ServiceRegistration> registrations = newArrayList(); for (ModuleDescriptor<?> descriptor : descriptors) { ModuleDescriptor<?> existingDescriptor = descriptor.getPlugin().getModuleDescriptor(descriptor.getKey()); if (existingDescriptor != null) { log.error("Duplicate key '" + descriptor.getKey() + "' detected, disabling previous instance"); ((StateAware) existingDescriptor).disabled(); } log.debug("Registering descriptor {}", descriptor.getClass().getName()); registrations.add(bundleContext.registerService(ModuleDescriptor.class.getName(), descriptor, null)); } return new Registration(registrations); }
final List<ServiceRegistration> registrations = newArrayList(); for (ModuleDescriptor<?> descriptor : descriptors) { ModuleDescriptor<?> existingDescriptor = descriptor.getPlugin().getModuleDescriptor(descriptor.getKey()); if (existingDescriptor != null) { log.error("Duplicate key '" + descriptor.getKey() + "' detected, disabling previous instance");
private ModuleDescriptor<?> getPluginModule(final ModuleCompleteKey key) { final Plugin plugin = getPlugin(key.getPluginKey()); if (plugin == null) { return null; } return plugin.getModuleDescriptor(key.getModuleKey()); }
private ModuleDescriptor<?> getPluginModule(final ModuleCompleteKey key) { final Plugin plugin = getPlugin(key.getPluginKey()); if (plugin == null) { return null; } return plugin.getModuleDescriptor(key.getModuleKey()); }
public String getScreenshotUrl(String pluginKey, String user) throws UnauthorizedAccessException { validateAccess(user); Plugin plugin = getPlugin(pluginKey); ModuleDescriptor<?> screenshotDescriptor = plugin.getModuleDescriptor("screenshot"); if (screenshotDescriptor == null) { screenshotDescriptor = unknownScreenshotDescriptor; } return webResourceManager.getStaticPluginResource(screenshotDescriptor, "screenshot.png", UrlMode.ABSOLUTE); }
public static void resolveDependency(Plugin plugin, Element dep, long state) { String fullKey = dep.getTextTrim(); int pos = fullKey.indexOf(':'); String pluginKey; String moduleKey; if (pos == -1) { moduleKey = fullKey; pluginKey = plugin.getKey(); } else { pluginKey = fullKey.substring(0, pos); moduleKey = fullKey.substring(pos + 1); } ModuleDescriptor<?> descriptor = plugin.getModuleDescriptor(moduleKey); String depText = pluginKey + ":" + moduleKey; if (pluginKey.equals(plugin.getKey()) && descriptor != null && descriptor instanceof SpeakeasyWebResourceModuleDescriptor) { depText += "-" + state; } dep.setText(depText); } }
ModuleDescriptor<?> moduleDescriptor = bonfire.getModuleDescriptor("bonfire-license-service"); if (moduleDescriptor == null)
@Override public ModuleDescriptor<?> getEnabledPluginModule(@Nullable final String completeKey) { final ModuleCompleteKey key = new ModuleCompleteKey(completeKey); // If it's disabled, return null if (!isPluginModuleEnabled(key)) { return null; } return getEnabledPlugin(key.getPluginKey()).getModuleDescriptor(key.getModuleKey()); }
public ModuleDescriptor<?> getEnabledPluginModule(final String completeKey) { final ModuleCompleteKey key = new ModuleCompleteKey(completeKey); // If it's disabled, return null if (!isPluginModuleEnabled(key)) { return null; } return getEnabledPlugin(key.getPluginKey()).getModuleDescriptor(key.getModuleKey()); }
private ErrorCollection invokeBonfireSetLicence() throws Exception { // // Bonfire doesnt implement the PluginLicenseManager because this is @since 4.4 and Bonfire needs to run on 4.3.3 // So we call directly onto its licence service with a custom written method just for JIRA (since 1.6.0 onwards) // SimpleErrorCollection errorCollection = new SimpleErrorCollection(); Plugin plugin = pluginAccessor.getPlugin(COM_ATLASSIAN_BONFIRE_PLUGIN); if (plugin == null) { errorCollection.addErrorMessage("setup.bonfire.no.plugin"); } else { // this doesnt throw exceptions if its not present pluginController.enablePlugins(COM_ATLASSIAN_BONFIRE_PLUGIN); ModuleDescriptor<?> moduleDescriptor = plugin.getModuleDescriptor("bonfire-license-service"); if (moduleDescriptor == null) { errorCollection.addErrorMessage(getText("setup.bonfire.no.licence.module")); } else { Object bonfireLicenceService = moduleDescriptor.getModule(); Method validateAndSetLicence = bonfireLicenceService.getClass().getMethod("validateAndSetLicence", ErrorCollection.class, String.class); validateAndSetLicence.invoke(bonfireLicenceService, errorCollection, getLicense()); } } return errorCollection; }
ModuleDescriptor<?> moduleDescriptor = otherPlugin.getModuleDescriptor(module.getResourceKey()); if (!(moduleDescriptor instanceof WebResourceModuleDescriptor)) { log.error("Failed to register new code macro language " +
public Plugin configurePlugin(final ModuleDescriptorFactory moduleDescriptorFactory, final Plugin plugin) throws PluginParseException { plugin.setName(descriptorReader.getPluginName()); plugin.setKey(getKey()); plugin.setPluginsVersion(getPluginsVersion()); plugin.setSystemPlugin(isSystemPlugin()); plugin.setI18nNameKey(descriptorReader.getI18nPluginNameKey().orElseGet(plugin::getI18nNameKey)); if (plugin.getKey().indexOf(":") > 0) { throw new PluginParseException("Plugin keys cannot contain ':'. Key is '" + plugin.getKey() + "'"); } plugin.setEnabledByDefault(descriptorReader.isEnabledByDefault()); plugin.setResources(descriptorReader.getResources()); plugin.setPluginInformation(createPluginInformation()); for (Element module : descriptorReader.getModules(plugin.getInstallationMode())) { final ModuleDescriptor<?> moduleDescriptor = createModuleDescriptor(plugin, module, moduleDescriptorFactory); // If we're not loading the module descriptor, null is returned, so we skip it if (moduleDescriptor == null) { continue; } if (plugin.getModuleDescriptor(moduleDescriptor.getKey()) != null) { throw new PluginParseException("Found duplicate key '" + moduleDescriptor.getKey() + "' within plugin '" + plugin.getKey() + "'"); } plugin.addModuleDescriptor(moduleDescriptor); // If we have any unloadable modules, also create an unloadable plugin, which will make it clear that there was a problem if (moduleDescriptor instanceof UnloadableModuleDescriptor) { log.error("There were errors loading the plugin '" + plugin.getName() + "'. The plugin has been disabled."); return UnloadablePluginFactory.createUnloadablePlugin(plugin); } } return plugin; }
plugin.getModuleDescriptor("modules") != null && plugin.getModuleDescriptor("images") != null && plugin.getModuleDescriptor("css") != null)