@Override public List<ModuleDescriptor<?>> createPluginModuleDescriptors(List<ConnectPageModuleBean> modules, ConnectAddonBean addon) { List<ModuleDescriptor<?>> descriptors = new ArrayList<>(); for (ConnectPageModuleBean bean : modules) { if (hasWebItem()) { WebItemModuleBean webItemBean = createWebItemModuleBean(bean, ConnectIFrameServletPath.forModule(addon.getKey(), bean.getRawKey())); descriptors.add(webItemModuleDescriptorFactory.createModuleDescriptor( webItemBean, addon, getAdditionalConditions())); } descriptors.add(iFrameModuleDescriptorGenerator.createModuleDescriptor( new ConnectIFrameBean(createPageIFrame(bean, addon), bean.getRawKey(), Optional.empty()), addon.getKey())); descriptors.add(iFrameModuleDescriptorGenerator.createModuleDescriptor( new ConnectIFrameBean(createRawIFrame(bean, addon), bean.getRawKey(), Optional.of(RAW_CLASSIFIER)), addon.getKey())); } return descriptors; }
@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(); } }
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); }
private ModuleDescriptor<ConnectIFrame> createRawIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { ConnectIFrameBuilder.ModuleUriBuilder moduleUriBuilder = connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getKey(connectAddonBean)); ConnectIFrameBuilder.InitializedBuilder builder = setRawIFrameTemplate(moduleUriBuilder) .urlTemplate(page.getUrl()) .conditions(page.getConditions()) .conditionClasses(getConditionClasses()) .dimensions("100%", "100%"); // the client (js) will size the parent of the iframe // allow subclasses to customize the IFrame builder = customizeIFrameBuilder(builder, page, connectAddonBean); return iFrameModuleDescriptorGenerator.createModuleDescriptor( new ConnectIFrameBean(builder.build(), page.getRawKey(), Optional.of(RAW_CLASSIFIER)), connectAddonBean); }
@Override public ConnectIFrameModuleDescriptor createModuleDescriptor(ConnectIFrameBean bean, String addonKey) { return createModuleDescriptor(bean.getConnectIFrame(), ConnectIFrameModuleDescriptorGenerator.getModuleKey(addonKey, bean.getModuleKey(), bean.getClassifier())); }
private ModuleDescriptor<ConnectIFrame> createPageIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { ConnectIFrameBuilder.ModuleUriBuilder moduleUriBuilder = connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getKey(connectAddonBean)); ConnectIFrameBuilder.InitializedBuilder builder = setIFrameTemplate(moduleUriBuilder) .urlTemplate(page.getUrl()) .decorator(getDecorator()) .conditions(page.getConditions()) .conditionClasses(getConditionClasses()) .title(page.getDisplayName()) .resizeToParent(true); // allow subclasses to customize the IFrame builder = customizeIFrameBuilder(builder, page, connectAddonBean); return iFrameModuleDescriptorGenerator.createModuleDescriptor( new ConnectIFrameBean(builder.build(), page.getRawKey(), Optional.empty()), connectAddonBean); }