public M apply(final T from) { return from.getModule(); } }
public M apply(final T from) { return from.getModule(); } }
public boolean matches(ModuleDescriptor<? extends ApplicationType> moduleDescriptor) { return moduleDescriptor instanceof ApplicationTypeModuleDescriptor && type.getClass().isAssignableFrom(moduleDescriptor.getModule().getClass()); } });
private static <M> Optional<M> getModuleSafely(final ModuleDescriptor<M> moduleDescriptor) { try { // If getModule returns null, this is an error, and Optional.of will NullPointerException in this case, // which will be caught below, get logged, and an Optional.empty returned. return Optional.of(moduleDescriptor.getModule()); } catch (final RuntimeException runtime) { log.error("Failed to getModule() for '{}': {}", moduleDescriptor.getCompleteKey(), runtime.getMessage(), runtime); return Optional.empty(); } }
private Extractor getContentPermissionExtractor() { ModuleDescriptor extractorDescriptor = pluginAccessor.getEnabledPluginModule("confluence.extractors.core:contentPermissionsExtractor"); if (extractorDescriptor != null) { return (Extractor) extractorDescriptor.getModule(); } return null; } }
public JiraXmlRpcService(PluginAccessor pluginAccessor) { this.soapService = ((JiraSoapService) pluginAccessor.getPluginModule("com.atlassian.jira.ext.rpc:soap").getModule()); }
/** * Get the modules of all the given descriptor. If any of the getModule() calls fails, the error is recorded in the * logs * * @param moduleDescriptors the collection of module descriptors to get the modules from. * @return a {@link Collection} modules that can be any type of object. This collection will not contain any null * value. */ private <M> Stream<M> getModules(final Stream<ModuleDescriptor<M>> moduleDescriptors) { return moduleDescriptors .filter(Objects::nonNull) .map(md -> { try { return md.getModule(); } catch (final RuntimeException ex) { log.error("Exception when retrieving plugin module {}", md.getCompleteKey(), ex); md.setBroken(); return null; } }) .filter(Objects::nonNull); }
@POST @Path("/{pluginKey}/{issueKey}") public Response generate(@PathParam("pluginKey") final String pluginKey, @PathParam("issueKey") final String issueKey) { ModuleDescriptor<AbstractFishEyeCrucibleIssueTabPanel> descriptor = (ModuleDescriptor<AbstractFishEyeCrucibleIssueTabPanel>) pluginAccessor.getEnabledPluginModule(pluginKey); if (descriptor == null) { throw new RuntimeException("Could not find an enabled module with key '" + pluginKey + "'"); } AbstractFishEyeCrucibleIssueTabPanel panel = descriptor.getModule(); Issue issue = issueManager.getIssueObject(issueKey); if (issue == null) { throw new RuntimeException("Could not find issue with key '" + issueKey + "'"); } List<IssueAction> actions = panel.createActions(issue, jiraAuthenticationContext.getLoggedInUser(), true); return createOkResponse(renderActionList(actions)); }
@Override public Option<CustomFieldType> getCustomFieldType(final String completeModuleKey) { final ModuleDescriptor<?> module = pluginAccessor.getEnabledPluginModule(completeModuleKey); if (module != null && module instanceof CustomFieldTypeModuleDescriptor) { return Option.some((CustomFieldType) module.getModule()); } // JRA-28134: this is logged at the debug level for the following reason: // custom field types provided by plugins might come and go as part of normal JIRA // operation due to the dynamic nature of OSGi, so JIRA should really handle this scenario as something normal if (log.isDebugEnabled()) { log.debug("Could not load custom field type plugin with key '" + completeModuleKey + "'. Is the plugin present and enabled?"); } return Option.none(); } }
@Override public Optional<ConnectIFrame> fetchConnectIFrame(String addonKey, String moduleKey, Optional<String> optionalClassifier) { if (moduleKey.startsWith(addonKey + ModuleKeyUtils.ADDON_MODULE_SEPARATOR)) { log.info("ACDEV-2694: connect iframe requested for module " + addonKey + ":" + moduleKey); } ModuleDescriptor moduleDescriptor = pluginAccessor.getEnabledPluginModule( new ModuleCompleteKey(pluginRetrievalService.getPlugin().getKey(), ConnectIFrameModuleDescriptor.getModuleKey(addonKey, moduleKey, optionalClassifier)).getCompleteKey()); if (moduleDescriptor != null) { return Optional.of((ConnectIFrame)moduleDescriptor.getModule()); } return Optional.empty(); } }
@Override public Optional<ConnectIFrame> fetchConnectIFrame(String addonKey, String moduleKey, Optional<String> optionalClassifier) { final ModuleCompleteKey iframeModuleKey = new ModuleCompleteKey(pluginRetrievalService.getPlugin().getKey(), ConnectIFrameModuleDescriptorGenerator.getModuleKey(addonKey, moduleKey, optionalClassifier)); ModuleDescriptor moduleDescriptor = pluginAccessor.getEnabledPluginModule(iframeModuleKey.getCompleteKey()); if (moduleDescriptor != null) { final Object potentialConnectIframe = moduleDescriptor.getModule(); if(potentialConnectIframe instanceof ConnectIFrame) { return Optional.of((ConnectIFrame) potentialConnectIframe); } else { log.error("A ModuleDescriptor with key '{}' looked like it held an Atlassian ConnectIframe module but did not. It was actually a: {}", iframeModuleKey.getCompleteKey(), potentialConnectIframe.getClass().getName()); } } return Optional.empty(); } }
Object bonfireLicenseService = moduleDescriptor.getModule(); try
@Override public T apply(final ModuleDescriptor<T> moduleDescriptor) { T handler = moduleDescriptor.getModule(); handler.setBackupProject(backupProject); handler.setBackupSystemInformation(backupSystemInformation); handler.setProjectImportMapper(projectImportMapper); handler.setProjectImportResults(projectImportResults); return handler; } }));
@PluginEventListener public void pluginModuleEnabled(final PluginModuleEnabledEvent event) { final ModuleDescriptor<?> module = event.getModule(); if (!(module instanceof DownloadStrategyModuleDescriptor)) { return; } register(module.getCompleteKey(), (DownloadStrategy) module.getModule()); }
private Option<PluginGadgetSpec> getPluginGadgetSpecFromModuleKey(String completeGadgetModuleKey) { final ModuleDescriptor<?> moduleDescriptor = pluginAccessor.getEnabledPluginModule(completeGadgetModuleKey); if (moduleDescriptor == null) { return Option.none(); } Object module = moduleDescriptor.getModule(); if (module instanceof PluginGadgetSpec) { return Option.some((PluginGadgetSpec) module); } return Option.none(); }
public ModuleDescriptor adding(final ModuleDescriptor descriptor) { final String completeKey = descriptor.getCompleteKey(); if (descriptor instanceof AbstractAppLinksTypeModuleDescriptor) { final AbstractAppLinksTypeModuleDescriptor<?> typeDescriptor = (AbstractAppLinksTypeModuleDescriptor) descriptor; final Object moduleInstance = typeDescriptor.getModule(); // assign, as getModule() may return different instances each invocation if (!IdentifiableType.class.isAssignableFrom(moduleInstance.getClass())) { //todo this check should be done in the ModuleDescriptor log.error(moduleInstance.getClass() + " does not implement " + IdentifiableType.class.getName() + "! This type will not be available."); return descriptor; } put(completeKey, typeDescriptor.getModule().getClass(), moduleInstance); for (final String inyourface : typeDescriptor.getInterfaces()) { put(completeKey, inyourface, moduleInstance); } put(completeKey, ((IdentifiableType) moduleInstance).getId().get(), moduleInstance); // register against type id } else if (descriptor instanceof AuthenticationProviderModuleDescriptor) { final AuthenticationProviderPluginModule module = (AuthenticationProviderPluginModule) descriptor.getModule(); put(completeKey, module.getAuthenticationProviderClass().getName(), module.getAuthenticationProviderClass()); } return descriptor; }
public ModuleDescriptor adding(final ModuleDescriptor descriptor) { final String completeKey = descriptor.getCompleteKey(); if (descriptor instanceof AbstractAppLinksTypeModuleDescriptor) { final AbstractAppLinksTypeModuleDescriptor<?> typeDescriptor = (AbstractAppLinksTypeModuleDescriptor) descriptor; final Object moduleInstance = typeDescriptor.getModule(); // assign, as getModule() may return different instances each invocation if (!IdentifiableType.class.isAssignableFrom(moduleInstance.getClass())) { //todo this check should be done in the ModuleDescriptor log.error(moduleInstance.getClass() + " does not implement " + IdentifiableType.class.getName() + "! This type will not be available."); return descriptor; } put(completeKey, typeDescriptor.getModule().getClass(), moduleInstance); for (final String inyourface : typeDescriptor.getInterfaces()) { put(completeKey, inyourface, moduleInstance); } put(completeKey, ((IdentifiableType)moduleInstance).getId().get(), moduleInstance); // register against type id } else if (descriptor instanceof AuthenticationProviderModuleDescriptor) { final AuthenticationProviderPluginModule module = (AuthenticationProviderPluginModule) descriptor.getModule(); put(completeKey, module.getAuthenticationProviderClass().getName(), module.getAuthenticationProviderClass()); } return descriptor; }
/** * Safely extracts the module instance from the given module descriptor. This method will disable any plugin it * can't successfully extract the module instance from. * * @since 5.0.0 */ <M> M getModule(ModuleDescriptor<M> descriptor) { if (descriptor == null || descriptor.isBroken()) { return null; } try { return descriptor.getModule(); } catch (final RuntimeException ex) { final String pluginKey = descriptor.getPlugin().getKey(); log.error("Exception when retrieving plugin module {}, disabling plugin {}", descriptor.getCompleteKey(), pluginKey, ex); descriptor.setBroken(); // Don't persist: don't want to create a snowflake config in Cloud instance, // and the module might work following restart if something has changed. pluginController.disablePluginWithoutPersisting(pluginKey); return null; } } }
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; }
/** * Sets the dataset variable as per the <code>ReportCollector</code> that * is applicable for the plugin descriptor. * * @return the success status */ private String run() { if (resultsList != null && !resultsList.isEmpty()) { ModuleDescriptor descriptor = getPluginAccessor().getPluginModule(getReportKey()); if (descriptor != null) { ReportCollector collector = (ReportCollector) descriptor .getModule(); collector.setResultsList(getResultsList()); collector.setParams(Collections.EMPTY_MAP); dataset = (TimeTableXYDataset) collector.getDataset(); } } return SUCCESS; }