com.atlassian.confluence.xhtml.api.XhtmlContent类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中com.atlassian.confluence.xhtml.api.XhtmlContent类的一些代码示例,展示了XhtmlContent类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XhtmlContent类的具体详情如下:
包路径:com.atlassian.confluence.xhtml.api.XhtmlContent
类名称:XhtmlContent

XhtmlContent介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking

  1. private String getBookmarkDescriptionRendered(ContentEntityObject contentEntityObject)
  2. {
  3. String bookmarkDescription = StringUtils.defaultString(bookmarkMacroParser.getParameters(contentEntityObject).get("description"));
  4. try
  5. {
  6. return xhtmlContent.convertStorageToView(
  7. bookmarkDescription,
  8. new DefaultConversionContext(contentEntityObject.toPageContext())
  9. );
  10. }
  11. catch (Exception e)
  12. {
  13. LOG.error("Error rendering bookmark description. Returning markup instead", e);
  14. return bookmarkDescription;
  15. }
  16. }

代码示例来源:origin: org.randombits.support/support-confluence

  1. /**
  2. * Get all the Xhtml MacroDefinitions on this page
  3. * See 3.2 of - http://confluence.atlassian.com/display/CONFDEV/Creating+a+new+Confluence+4.0+Macro
  4. *
  5. * @return a list of MacroDefinitions
  6. * @throws com.atlassian.confluence.content.render.xhtml.XhtmlException
  7. * if t here is an issue parsing the macro definition list.
  8. * @deprecated No replacement. Inject {@link XhtmlContent} and handle it directly if required.
  9. */
  10. @SuppressWarnings("unchecked")
  11. @Deprecated
  12. public List<MacroDefinition> getPageMacros() throws XhtmlException {
  13. if ( xhtmlContent != null ) {
  14. final List<MacroDefinition> macros = new ArrayList<MacroDefinition>();
  15. ContentEntityObject pageCEO = conversionContext.getEntity();
  16. String pageContent = pageCEO.getBodyAsString();
  17. xhtmlContent.handleMacroDefinitions( pageContent, conversionContext, new MacroDefinitionHandler() {
  18. public void handle( MacroDefinition macroDefinition ) {
  19. macros.add( macroDefinition );
  20. }
  21. } );
  22. return macros;
  23. }
  24. return Collections.EMPTY_LIST;
  25. }

代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin

  1. private String convertWikimarkupToViewFormat(String value, ConversionContext conversionContext, List<RuntimeException> errors) throws XhtmlException, XMLStreamException
  2. {
  3. return xhtmlUtils.convertStorageToView(xhtmlUtils.convertWikiToStorage(value, conversionContext, errors), conversionContext);
  4. }
  5. }

代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin

  1. /**
  2. * From the old {@link com.atlassian.renderer.v2.macro.Macro} interface.
  3. * Converts the old wiki markup body into storage format XHTML, then delegates to the newer interface.
  4. */
  5. @Override
  6. public String execute(Map macroParameters, String bodyWikiMarkup, RenderContext renderContext)
  7. {
  8. // TODO SHouldn't we do something with this list?
  9. final List<RuntimeException> wikiMarkupToStorageConversionErrors = newArrayList();
  10. final ConversionContext conversionContext = new DefaultConversionContext(renderContext);
  11. final String storageFormatBody = xhtmlContent.convertWikiToStorage(
  12. bodyWikiMarkup,
  13. conversionContext,
  14. wikiMarkupToStorageConversionErrors
  15. );
  16. return execute(macroParameters, storageFormatBody, conversionContext);
  17. }

代码示例来源:origin: org.randombits.support/support-confluence

  1. private String renderWiki( Renderable renderable ) throws RenderException {
  2. List<RuntimeException> exceptions = new ArrayList<RuntimeException>();
  3. try {
  4. String value = xhtmlContent.convertWikiToView( renderable.getText(), renderable.getConversionContext(), exceptions );
  5. if ( !exceptions.isEmpty() ) {
  6. throw new RenderException( "Exceptions occurred while rendering wiki markup.", exceptions );
  7. }
  8. return XhtmlUtils.stripParagraphWrapper(value);
  9. } catch ( XMLStreamException e ) {
  10. throw new RenderException( e.getMessage(), e );
  11. } catch ( XhtmlException e ) {
  12. throw new RenderException( e.getMessage(), e );
  13. }
  14. }

代码示例来源:origin: com.atlassian.confluence.extra/dynamictasklist2

  1. /**
  2. * @param taskList task list to save
  3. * @param content containing content that will be saved. NOTE: this method will
  4. * change the content before saving it.
  5. * @param comment change comment
  6. */
  7. public void save(final TaskList taskList, final ContentEntityObject content, String comment) {
  8. ContentEntityObject original;
  9. try {
  10. original = (ContentEntityObject) content.clone();
  11. } catch (Exception e) {
  12. throw Throwables.propagate(e);
  13. }
  14. String updatedBody;
  15. try {
  16. updatedBody = xhtmlContent.updateMacroDefinitions(content.getBodyAsString(), new DefaultConversionContext(content.toPageContext()),
  17. new TaskListMacroDefinitionUpdater(taskList, taskListSerializer, taskListDeserializer));
  18. } catch (XhtmlException e) {
  19. throw new RuntimeException(e);
  20. }
  21. content.setBodyAsString(updatedBody);
  22. if (taskList.getConfig().getEnableVersioning()) {
  23. content.setVersionComment("Dynamic Task List: " + comment);
  24. // suppress notifications, update last modifier, but don't suppress other events
  25. SaveContext saveContext = new DefaultSaveContext(true, true, false);
  26. pageManager.saveContentEntity(content, original, saveContext);
  27. }
  28. }

代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking

  1. private String getBookmarkParentPageContent(Space space, Page parentPage)
  2. {
  3. List<RuntimeException> conversionErrors = new ArrayList<RuntimeException>();
  4. Map<String, Object> velocityContext = velocityHelperService.createDefaultVelocityContext();
  5. velocityContext.put("spaceName", space.getName());
  6. velocityContext.put("spaceKey", space.getKey());
  7. String wikiMarkup = velocityHelperService.getRenderedTemplate("templates/plugins/socialbookmarking/bookmarkparentpage.vm", velocityContext);
  8. String storageXhtml = xhtmlContent.convertWikiToStorage(wikiMarkup, new DefaultConversionContext(parentPage.toPageContext()), conversionErrors);
  9. if (!conversionErrors.isEmpty())
  10. {
  11. LOG.error(String.format("Unable to convert parent page wiki markup below to XHTML storage:\n%s", wikiMarkup));
  12. for (RuntimeException conversionError : conversionErrors)
  13. LOG.error("Conversion error", conversionError);
  14. }
  15. return storageXhtml;
  16. }

代码示例来源:origin: com.atlassian.confluence.extra.chart/chart-plugin

  1. public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException
  2. {
  3. try
  4. {
  5. ConversionContext conversionContext = new DefaultConversionContext(renderContext);
  6. List<RuntimeException> errorList = new ArrayList<>();
  7. body = xhtmlContent.convertWikiToView(body, conversionContext, errorList);
  8. if(!errorList.isEmpty())
  9. {
  10. for(RuntimeException runtimeException : errorList)
  11. {
  12. log.error("RuntimeException while parsing wiki markup ", runtimeException);
  13. }
  14. throw new MacroException(getI18NBean().getText("confluence.extra.chart.chart.error.parseWikiToStorage"));
  15. }
  16. return execute(parameters, body, conversionContext);
  17. }
  18. catch (MacroExecutionException | XhtmlException | XMLStreamException e)
  19. {
  20. throw new MacroException(e);
  21. }
  22. }

代码示例来源:origin: com.atlassian.confluence.plugins.toc/toc-plugin

  1. /**
  2. * This macro operates on the body of the content entity (e.g. the page) on which the macro is a part of. This
  3. * method fetches the content body (which should be in XHTML storage-format), renders that to view-format, then
  4. * returns that to be used as the basis of the TOC generation.
  5. */
  6. @Override
  7. protected String getContent(final Map<String, String> parameters, final String body, final ConversionContext conversionContext)
  8. {
  9. final ContentEntityObject contentEntity = conversionContext.getEntity();
  10. if (contentEntity == null)
  11. {
  12. log.warn("There was an error converting the preview content to view - content entity object was null.");
  13. return "";
  14. }
  15. try
  16. {
  17. return xhtmlContent.convertStorageToView(contentEntity.getBodyAsString(), conversionContext);
  18. }
  19. catch (Exception ex)
  20. {
  21. log.warn("There was an error converting the content for id " + contentEntity.getId() + " to storage format.", ex);
  22. return "";
  23. }
  24. }

代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking

  1. final String xhtml = xhtmlContent.convertStorageToView(
  2. xhtmlContent.convertWikiToStorage(bodyText, conversionContext, conversionErrors),
  3. conversionContext
  4. );

代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking

  1. public Map<String, String> getParameters(ContentEntityObject contentEntityObject)
  2. {
  3. BookmarkMacroHandler bookmarkMacroHandler = new BookmarkMacroHandler();
  4. try
  5. {
  6. xhtmlContent.handleMacroDefinitions(
  7. contentEntityObject.getBodyAsString(),
  8. new DefaultConversionContext(contentEntityObject.toPageContext()),
  9. bookmarkMacroHandler
  10. );
  11. }
  12. catch (XhtmlException xhtmlError)
  13. {
  14. LOG.error(String.format("Unable to find bookmark macro parameters in content %s", contentEntityObject.toString()), xhtmlError);
  15. }
  16. return bookmarkMacroHandler.getParameters();
  17. }

代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking

  1. : xhtmlContent.convertWikiToStorage(bodyText, conversionContext, conversionErrors);

代码示例来源:origin: com.atlassian.labs/confluence-mentions-plugin

  1. velocityContext.put("contentHtml", xhtmlContent.convertWikiToView(contentEntityObject.getDisplayTitle(),
  2. conversionContext, new ArrayList<RuntimeException>()));

代码示例来源:origin: net.customware.confluence.plugin.toc/toc-plugin

  1. protected String getContent(Map<String, String> parameters , String body, ConversionContext conversionContext)
  2. {
  3. ContentEntityObject ceo = conversionContext.getEntity();
  4. if (ceo == null)
  5. {
  6. log.warn("There was an error converting the preview content to view - content entity object was null.");
  7. return "";
  8. }
  9. String pageContent = ceo.getBodyAsString();
  10. try
  11. {
  12. return getXhtmlContent().convertStorageToView(pageContent, conversionContext);
  13. }
  14. catch (Exception ex)
  15. {
  16. log.warn("There was an error converting the content for id " + ceo.getId() + " to storage format.", ex);
  17. return "";
  18. }
  19. }

代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin

  1. public ImmutableMap<String, ImmutableList<ImmutableMap<String, PageProperty>>> extractProperties(ContentEntityObject entity,
  2. DetailsSummaryMacroMetricsEvent.Builder metrics)
  3. {
  4. // We need to marshall non-detail-macros encountered in the body of the detail macro, so that these macros
  5. // can be rendered in the table of detail lines.
  6. final DefaultConversionContext subContext = new DefaultConversionContext(entity.toPageContext());
  7. final DetailsMacroBodyHandler macroBodyHandler = new DetailsMacroBodyHandler(metrics);
  8. try
  9. {
  10. metrics.entityBodyFetchStart();
  11. final String entityBody = entity.getBodyAsString();
  12. metrics.entityBodyFetchFinish(defaultString(entityBody).length());
  13. xhtmlContent.handleMacroDefinitions(entityBody, subContext, macroBodyHandler, MARSHALL_MACRO);
  14. }
  15. catch (XhtmlException e)
  16. {
  17. log.error("Cannot extract page properties from content with id: " + entity.getIdAsString(), e);
  18. }
  19. return macroBodyHandler.getDetails();
  20. }
  21. }

代码示例来源:origin: com.atlassian.confluence.plugin/func-test

  1. commentManager.updateCommentContent(
  2. pageComment,
  3. xhtmlContent.convertWikiToStorage(
  4. StringUtils.defaultString((String) commentStruct.get("content")),
  5. new DefaultConversionContext(commentPage.toPageContext()),
  6. commentPage,
  7. parentComment,
  8. xhtmlContent.convertWikiToStorage(
  9. StringUtils.defaultString((String) commentStruct.get("content")),
  10. new DefaultConversionContext(commentPage.toPageContext()),

代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin

  1. renderedValue = xhtmlContent.convertStorageToView(headingStorageFormat, context);

代码示例来源:origin: com.atlassian.confluence.extra/dynamictasklist2

  1. /**
  2. * Gets the list of tasks associated with the given listName and contentObject
  3. *
  4. * @param listName list name
  5. * @param occurance occurance
  6. * @param content contentObject
  7. * @return the list of tasks associated with the given parameters
  8. */
  9. public TaskList getTaskList(String listName, int occurance, final ContentEntityObject content) {
  10. final TaskListId taskListId = new TaskListId(listName, occurance);
  11. final TaskListMacroDefinitionHandler handler = new TaskListMacroDefinitionHandler(taskListId, taskListDeserializer);
  12. try {
  13. xhtmlContent.handleMacroDefinitions(content.getBodyAsString(), new DefaultConversionContext(content.toPageContext()), handler);
  14. } catch (XhtmlException e) {
  15. throw new RuntimeException(e);
  16. }
  17. return handler.getMatchingTaskList();
  18. }

代码示例来源:origin: com.atlassian.confluence.plugin/func-test

  1. @Override
  2. public String getViewFormat(String authToken, String pageId) throws XMLStreamException, XhtmlException
  3. {
  4. ContentEntityObject contentEntityObject = getContentEntityObject(pageId);
  5. return null == contentEntityObject ? null : xhtmlContent.convertStorageToView(contentEntityObject.getBodyAsString(), new DefaultConversionContext(contentEntityObject.toPageContext()));
  6. }

代码示例来源:origin: org.randombits.support/support-confluence

  1. private String renderRichText( Renderable renderable ) throws RenderException {
  2. try {
  3. return XhtmlUtils.stripParagraphWrapper(
  4. xhtmlContent.convertStorageToView( renderable.getText(), renderable.getConversionContext()) );
  5. } catch ( XMLStreamException e ) {
  6. throw new RenderException( e.getMessage(), e );
  7. } catch ( XhtmlException e ) {
  8. throw new RenderException( e.getMessage(), e );
  9. }
  10. }
  11. }

相关文章