private List<ConditionalBean> getPageAndAdditionalConditions(final ConnectPageModuleBean page) { return Stream.of(page.getConditions(), getAdditionalConditions()).flatMap(Collection::stream).collect(toList()); }
public ConnectPageModuleBeanBuilder(ConnectPageModuleBean defaultBean) { super(defaultBean); this.weight = defaultBean.getWeight(); this.url = defaultBean.getUrl(); this.location = defaultBean.getLocation(); this.icon = defaultBean.getIcon(); }
private WebItemModuleBean createWebItemModuleBean(ConnectPageModuleBean bean, String url) { Integer weight = bean.getWeight() == null ? getDefaultWeight() : bean.getWeight(); String location = isNullOrEmpty(bean.getLocation()) ? getDefaultSection() : bean.getLocation(); return newWebItemBean() .withName(bean.getName()) .withKey(bean.getRawKey()) .withContext(page) .withUrl(url) .withLocation(location) .withWeight(weight) .withIcon(bean.getIcon()) .withConditions(bean.getConditions()) .setNeedsEscaping(needsEscaping()) .build(); }
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); }
private ConnectIFrame createRawIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { return connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getRawKey()) .genericBodyTemplate() .urlTemplate(page.getUrl()) .title(page.getDisplayName()) .conditions(getPageAndAdditionalConditions(page)) .dimensions("100%", "100%") // the client (js) will size the parent of the iframe .build(); }
private void addPluginInfoParameterForPageIfDeclared(PluginInformation pluginInfo, String parameterKey, ConnectAddonBean addon, String moduleType) { Optional<List<ModuleBean>> optionalPages = addon.getModules().getValidModuleListOfType( moduleType, moduleValidationExceptionHandler); optionalPages.ifPresent(moduleBeans -> { ConnectPageModuleBean page = (ConnectPageModuleBean) moduleBeans.get(0); if (null != page && !Strings.isNullOrEmpty(page.getUrl())) { pluginInfo.addParameter(parameterKey, ConnectIFrameServletPath.forModule(addon.getKey(), page.getRawKey())); } }); } }
@Override public Collection<TypedPluginModule> serializeToPluginModules(Collection<ConnectPageModuleBean> modules, ConnectAddonBean addon, Translations translations) { ImmutableList.Builder<TypedPluginModule> builder = ImmutableList.builder(); if (hasWebItem()) { final List<WebItemModuleBean> webItems = modules.stream().map(module -> createWebItemModuleBean(module, module.getRawKey())).collect(Collectors.toList()); builder.addAll(webItemModuleProvider.serializeToPluginModules(webItems, addon, translations)); } return builder.addAll(modules.stream().flatMap(module -> serializeConnectIframes(module, addon).stream()).collect(Collectors.toList())).build(); }
private static String createGeneralPageAsViewComponentExample() { return gson.toJson(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My viewer page")) .withKey("my-viewer") .withUrl("/my-general-page?content.plugin={content.plugin}&content.id={content.id}&content.version={content.version}&space.key={space.key}") .build()); }
@Override public List<ModuleDescriptor<?>> createPluginModuleDescriptors(List<ConnectPageModuleBean> modules, ConnectAddonBean addon) { List<ModuleDescriptor<?>> descriptors = new ArrayList<>(); for (ConnectPageModuleBean bean : modules) { if (hasWebItem()) { // create a web item targeting the iframe page Integer weight = bean.getWeight() == null ? getDefaultWeight() : bean.getWeight(); String location = isNullOrEmpty(bean.getLocation()) ? getDefaultSection() : bean.getLocation(); WebItemModuleBean webItemBean = newWebItemBean() .withName(bean.getName()) .withKey(bean.getRawKey()) .withContext(page) .withUrl(ConnectIFrameServletPath.forModule(addon.getKey(), bean.getRawKey())) .withLocation(location) .withWeight(weight) .withIcon(bean.getIcon()) .withConditions(bean.getConditions()) .setNeedsEscaping(needsEscaping()) .build(); descriptors.add(webItemModuleDescriptorFactory.createModuleDescriptor( webItemBean, addon, getConditionClasses())); } descriptors.add(createPageIFrame(bean, addon)); descriptors.add(createRawIFrame(bean, addon)); } return descriptors; }
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); }
public ConnectPageModuleBeanBuilder(ConnectPageModuleBean defaultBean) { super(defaultBean); this.weight = defaultBean.getWeight(); this.url = defaultBean.getUrl(); this.location = defaultBean.getLocation(); this.icon = defaultBean.getIcon(); }
private ConnectIFrame createPageIFrame(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { return connectIFrameBuilderFactory.builder() .addon(connectAddonBean.getKey()) .module(page.getRawKey()) .pageTemplate() .urlTemplate(page.getUrl()) .decorator(getDecorator()) .conditions(getPageAndAdditionalConditions(page)) .title(page.getDisplayName()) .resizeToParent(true) .build(); }
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 static String createPageExample() { JsonElement generalPageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My General Page")) .withKey("my-general-page") .withIcon(newIconBean().withUrl("/maps/icon.png").withHeight(80).withWidth(80).build()) .build()); JsonElement adminPageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Admin Page")) .withKey("my-admin-page") .withUrl("/my-admin-page") .build()); JsonElement configurePageModuleBean = gson.toJsonTree(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Configure Page")) .withKey("my-config-page") .withUrl("/my-config-page") .build()); JsonElement postInstallPageModuleBean = gson.toJsonTree(ConnectPageModuleBean.newPageBean() .withName(new I18nProperty("My Post-Install Page", "mypostinstallpage.name")) .withKey("my-post-install-page") .withUrl("/my-post-install-page") .build()); JsonElement userProfilePageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Confluence User Profile Page")) .withKey("my-confluence-user-profile-page")
@Override public List<ModuleDescriptor> createPluginModuleDescriptors(List<ConnectPageModuleBean> modules, ConnectModuleProviderContext moduleProviderContext) { List<ModuleDescriptor> descriptors = new ArrayList<>(); final ConnectAddonBean connectAddonBean = moduleProviderContext.getConnectAddonBean(); for (ConnectPageModuleBean bean : modules) { if (hasWebItem()) { // create a web item targeting the iframe page Integer weight = bean.getWeight() == null ? getDefaultWeight() : bean.getWeight(); String location = isNullOrEmpty(bean.getLocation()) ? getDefaultSection() : bean.getLocation(); WebItemModuleBean webItemBean = newWebItemBean() .withName(bean.getName()) .withKey(bean.getRawKey()) .withContext(page) .withUrl(ConnectIFrameServletPath.forModule(connectAddonBean.getKey(), bean.getRawKey())) .withLocation(location) .withWeight(weight) .withIcon(bean.getIcon()) .withConditions(bean.getConditions()) .setNeedsEscaping(needsEscaping()) .build(); descriptors.add(webItemModuleDescriptorFactory.createModuleDescriptor(moduleProviderContext, pluginRetrievalService.getPlugin(), webItemBean, getConditionClasses())); } registerIframeRenderStrategy(bean, connectAddonBean); } return descriptors; }
protected void registerIframeRenderStrategy(ConnectPageModuleBean page, ConnectAddonBean connectAddonBean) { // register a render strategy for our iframe page IFrameRenderStrategy pageRenderStrategy = iFrameRenderStrategyBuilderFactory.builder() .addOn(connectAddonBean.getKey()) .module(page.getKey(connectAddonBean)) .pageTemplate() .urlTemplate(page.getUrl()) .decorator(getDecorator()) .conditions(page.getConditions()) .conditionClasses(getConditionClasses()) .title(page.getDisplayName()) .resizeToParent(true) .build(); iFrameRenderStrategyRegistry.register(connectAddonBean.getKey(), page.getRawKey(), pageRenderStrategy); // and an additional strategy for raw content, in case the user wants to use it as a dialog target IFrameRenderStrategy rawRenderStrategy = iFrameRenderStrategyBuilderFactory.builder() .addOn(connectAddonBean.getKey()) .module(page.getKey(connectAddonBean)) .genericBodyTemplate() .urlTemplate(page.getUrl()) .conditions(page.getConditions()) .conditionClasses(getConditionClasses()) .dimensions("100%", "100%") // the client (js) will size the parent of the iframe .build(); iFrameRenderStrategyRegistry.register(connectAddonBean.getKey(), page.getRawKey(), RAW_CLASSIFIER, rawRenderStrategy); }
@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; }
private static String createPageExample() { JsonElement generalPageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My General Page")) .withKey("my-general-page") .withIcon(newIconBean().withUrl("/maps/icon.png").withHeight(80).withWidth(80).build()) .build()); JsonElement adminPageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Admin Page")) .withKey("my-admin-page") .withUrl("/my-admin-page") .build()); JsonElement configurePageModuleBean = gson.toJsonTree(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Configure Page")) .withKey("my-config-page") .withUrl("/my-config-page") .build()); JsonElement postInstallPageModuleBean = gson.toJsonTree(ConnectPageModuleBean.newPageBean() .withName(new I18nProperty("My Post-Install Page", "mypostinstallpage.name")) .withKey("my-post-install-page") .withUrl("/my-post-install-page") .build()); JsonElement userProfilePageModuleBean = JsonExamplesUtils.createJsonArrayWithSingleObject(ConnectPageModuleBean.newPageBean() .withName(i18nProperty("My Confluence User Profile Page")) .withKey("my-confluence-user-profile-page")