private List<ConditionalBean> getPageAndAdditionalConditions(final ConnectPageModuleBean page) { return Stream.of(page.getConditions(), getAdditionalConditions()).flatMap(Collection::stream).collect(toList()); }
protected void validateConditions(ShallowConnectAddonBean descriptor, List<ConnectPageModuleBean> pageBeans) throws ConnectModuleValidationException { for (ConnectPageModuleBean page : pageBeans) { for (SingleConditionBean condition : ConditionUtils.getSingleConditionsRecursively(page.getConditions())) { assertValidPageCondition(descriptor, condition); } } }
protected void validateConditions(ShallowConnectAddonBean descriptor, List<ConnectPageModuleBean> pageBeans) throws ConnectModuleValidationException { for (ConnectPageModuleBean page : pageBeans) { for (SingleConditionBean condition : ConditionUtils.getSingleConditionsRecursively(page.getConditions())) { assertValidPageCondition(descriptor, condition); } } }
protected void validateConditions(ShallowConnectAddonBean descriptor, List<ConnectPageModuleBean> pageBeans) throws ConnectModuleValidationException { List<ConnectConditionClassResolver> conditionClassResolvers = pluginAccessor.getEnabledModulesByClass(ConnectConditionClassResolver.class); for (ConnectPageModuleBean page : pageBeans) { for (SingleConditionBean condition : ConditionUtils.getSingleConditionsRecursively(page.getConditions())) { assertValidPageCondition(descriptor, condition, conditionClassResolvers); } } }
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 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 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> 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); }
@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); }