public static String renderToString(ModuleContextParameters moduleContextParameters, ConnectIFrame connectIFrame) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { connectIFrame.render(moduleContextParameters, new OutputStreamWriter(out), Optional.empty()); } catch (IOException e) { // no I/O, so no IOException.. right? throw new IllegalStateException(e); } return out.toString(); }
public static String renderAccessDeniedToString(ConnectIFrame connectIFrame) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { connectIFrame.renderAccessDenied(new OutputStreamWriter(out)); } catch (IOException e) { // no I/O, so no IOException.. right? throw new IllegalStateException(e); } return out.toString(); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { Optional<AddOnKeyAndModuleKey> keys = keysFromPathMatcher.getAddOnKeyAndModuleKey(req.getPathInfo()); if (!keys.isPresent()) { resp.sendError(SC_NOT_FOUND); return; } final AddOnKeyAndModuleKey addOnKeyAndModuleKey = keys.get(); String classifier = req.getParameter(CLASSIFIER_PARAMETER); Optional<String> lookupClassifier = StringUtils.isBlank(classifier) || JSON_CLASSIFIER.equals(classifier) ? Optional.empty() : Optional.of(classifier); Optional<ConnectIFrame> maybeIFrame = iFrameAccessor.fetchConnectIFrame(addOnKeyAndModuleKey.getAddOnKey(), addOnKeyAndModuleKey.getModuleKey(), lookupClassifier); if (maybeIFrame.isPresent()) { ConnectIFrame iFrame = maybeIFrame.get(); if (JSON_CLASSIFIER.equals(classifier)) { iFrame = iFrame.toJsonIFrame(); } resp.setContentType(iFrame.getContentType()); ModuleContextParameters moduleContextParameters = moduleContextParser.parseContextParameters(req); if (iFrame.shouldShow(moduleContextParameters)) { Optional<String> moduleUiParameters = moduleUiParamParser.parseUiParameters(req); iFrame.render(moduleContextParameters, resp.getWriter(), moduleUiParameters); eventPublisher.publish(new IFrameRenderedEvent(addOnKeyAndModuleKey.getAddOnKey(), addOnKeyAndModuleKey.getModuleKey(), moduleContextParameters)); } else { iFrame.renderAccessDenied(resp.getWriter()); } } else { resp.sendError(SC_NOT_FOUND); } }
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); }
ConnectIFrame iFrame = maybeIFrame.get(); if (JSON_CLASSIFIER.equals(classifier)) { iFrame = iFrame.toJsonIFrame(); resp.setContentType(iFrame.getContentType()); ModuleContextParameters moduleContextParameters = moduleContextParser.parseContextParameters(req); if (iFrame.shouldShow(moduleContextParameters.getOriginalContext())) { Optional<String> moduleUiParameters = moduleUiParamParser.parseUiParameters(req); iFrame.render(moduleContextParameters, resp.getWriter(), moduleUiParameters); eventPublisher.publish(new IFrameRenderedEvent(addOnKeyAndModuleKey.getAddOnKey(), addOnKeyAndModuleKey.getModuleKey(), moduleContextParameters)); } else { iFrame.renderAccessDenied(resp.getWriter());
public static String renderAccessDeniedToString(ConnectIFrame connectIFrame) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { connectIFrame.renderAccessDenied(new OutputStreamWriter(out)); } catch (IOException e) { // no I/O, so no IOException.. right? throw new IllegalStateException(e); } return out.toString(); }
public static String renderToString(ModuleContextParameters moduleContextParameters, ConnectIFrame connectIFrame) { ByteArrayOutputStream out = new ByteArrayOutputStream(); try { connectIFrame.render(moduleContextParameters, new OutputStreamWriter(out), Optional.empty()); } catch (IOException e) { // no I/O, so no IOException.. right? throw new IllegalStateException(e); } return out.toString(); }