private Collection<TypedPluginModule> serializeConnectIframes(ConnectPageModuleBean module, ConnectAddonBean addon) { String pageIframePluginModuleKey = ConnectIFrameModuleDescriptorGenerator.getModuleKey(addon.getKey(), module.getRawKey(), Optional.empty()); TypedPluginModule pageIframePluginModule = TypedPluginModule.of(ConnectIFrame.IFRAME_PLUGIN_MODULE_DESERIALIZER_IDENTIFIER, pageIframePluginModuleKey, createPageIFrame(module, addon).serialize()); String rawIframepluginModuleKey = ConnectIFrameModuleDescriptorGenerator.getModuleKey(addon.getKey(), module.getRawKey(), Optional.of(RAW_CLASSIFIER)); TypedPluginModule rawIframePluginModule = TypedPluginModule.of(ConnectIFrame.IFRAME_PLUGIN_MODULE_DESERIALIZER_IDENTIFIER, rawIframepluginModuleKey, createRawIFrame(module, addon).serialize()); return ImmutableList.of(pageIframePluginModule, rawIframePluginModule); }
@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(); } }
@Override public ConnectIFrameModuleDescriptor createModuleDescriptor(ConnectIFrameBean bean, String addonKey) { return createModuleDescriptor(bean.getConnectIFrame(), ConnectIFrameModuleDescriptorGenerator.getModuleKey(addonKey, bean.getModuleKey(), bean.getClassifier())); }