private String getBookmarkParentPageContent(Space space, Page parentPage) { List<RuntimeException> conversionErrors = new ArrayList<RuntimeException>(); Map<String, Object> velocityContext = velocityHelperService.createDefaultVelocityContext(); velocityContext.put("spaceName", space.getName()); velocityContext.put("spaceKey", space.getKey()); String wikiMarkup = velocityHelperService.getRenderedTemplate("templates/plugins/socialbookmarking/bookmarkparentpage.vm", velocityContext); String storageXhtml = xhtmlContent.convertWikiToStorage(wikiMarkup, new DefaultConversionContext(parentPage.toPageContext()), conversionErrors); if (!conversionErrors.isEmpty()) { LOG.error(String.format("Unable to convert parent page wiki markup below to XHTML storage:\n%s", wikiMarkup)); for (RuntimeException conversionError : conversionErrors) LOG.error("Conversion error", conversionError); } return storageXhtml; }
protected InputStream getContentInternal() throws IOException { /* Mostly copied from PageWordExportAction to generate MS Word exports of a page */ Page page = getPage(); PageContext context = page.toPageContext(); Settings globalSettings = settingsManager.getGlobalSettings(); Map<String, Object> contextMap; context.setBaseUrl(globalSettings.getBaseUrl()); context.setSiteRoot(bootstrapManager.getWebAppContextPath()); context.setOutputType(RenderContextOutputType.WORD); context.setLinkRenderer(new WordDocLinkRenderer(context)); String renderedContent = ""; try { renderedContent = xhtmlContent.convertStorageToView(page.getBodyContent().getBody(), new DefaultConversionContext(context)); } catch (XMLStreamException e) { throw new IOException(e); } catch (XhtmlException e) { throw new IOException(e); } contextMap = new HashMap<String, Object>(); contextMap.put("renderedContent", renderedContent); contextMap.put("domainName", globalSettings.getBaseUrl()); contextMap.put("page", page); return new ByteArrayInputStream( VelocityUtils.getRenderedTemplate("templates/extra/webdav/exportword.vm", contextMap).getBytes(globalSettings.getDefaultEncoding())); }