本文整理了Java中com.atlassian.confluence.xhtml.api.XhtmlContent
类的一些代码示例,展示了XhtmlContent
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XhtmlContent
类的具体详情如下:
包路径:com.atlassian.confluence.xhtml.api.XhtmlContent
类名称:XhtmlContent
暂无
代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking
private String getBookmarkDescriptionRendered(ContentEntityObject contentEntityObject)
{
String bookmarkDescription = StringUtils.defaultString(bookmarkMacroParser.getParameters(contentEntityObject).get("description"));
try
{
return xhtmlContent.convertStorageToView(
bookmarkDescription,
new DefaultConversionContext(contentEntityObject.toPageContext())
);
}
catch (Exception e)
{
LOG.error("Error rendering bookmark description. Returning markup instead", e);
return bookmarkDescription;
}
}
代码示例来源:origin: org.randombits.support/support-confluence
/**
* Get all the Xhtml MacroDefinitions on this page
* See 3.2 of - http://confluence.atlassian.com/display/CONFDEV/Creating+a+new+Confluence+4.0+Macro
*
* @return a list of MacroDefinitions
* @throws com.atlassian.confluence.content.render.xhtml.XhtmlException
* if t here is an issue parsing the macro definition list.
* @deprecated No replacement. Inject {@link XhtmlContent} and handle it directly if required.
*/
@SuppressWarnings("unchecked")
@Deprecated
public List<MacroDefinition> getPageMacros() throws XhtmlException {
if ( xhtmlContent != null ) {
final List<MacroDefinition> macros = new ArrayList<MacroDefinition>();
ContentEntityObject pageCEO = conversionContext.getEntity();
String pageContent = pageCEO.getBodyAsString();
xhtmlContent.handleMacroDefinitions( pageContent, conversionContext, new MacroDefinitionHandler() {
public void handle( MacroDefinition macroDefinition ) {
macros.add( macroDefinition );
}
} );
return macros;
}
return Collections.EMPTY_LIST;
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin
private String convertWikimarkupToViewFormat(String value, ConversionContext conversionContext, List<RuntimeException> errors) throws XhtmlException, XMLStreamException
{
return xhtmlUtils.convertStorageToView(xhtmlUtils.convertWikiToStorage(value, conversionContext, errors), conversionContext);
}
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin
/**
* From the old {@link com.atlassian.renderer.v2.macro.Macro} interface.
* Converts the old wiki markup body into storage format XHTML, then delegates to the newer interface.
*/
@Override
public String execute(Map macroParameters, String bodyWikiMarkup, RenderContext renderContext)
{
// TODO SHouldn't we do something with this list?
final List<RuntimeException> wikiMarkupToStorageConversionErrors = newArrayList();
final ConversionContext conversionContext = new DefaultConversionContext(renderContext);
final String storageFormatBody = xhtmlContent.convertWikiToStorage(
bodyWikiMarkup,
conversionContext,
wikiMarkupToStorageConversionErrors
);
return execute(macroParameters, storageFormatBody, conversionContext);
}
代码示例来源:origin: org.randombits.support/support-confluence
private String renderWiki( Renderable renderable ) throws RenderException {
List<RuntimeException> exceptions = new ArrayList<RuntimeException>();
try {
String value = xhtmlContent.convertWikiToView( renderable.getText(), renderable.getConversionContext(), exceptions );
if ( !exceptions.isEmpty() ) {
throw new RenderException( "Exceptions occurred while rendering wiki markup.", exceptions );
}
return XhtmlUtils.stripParagraphWrapper(value);
} catch ( XMLStreamException e ) {
throw new RenderException( e.getMessage(), e );
} catch ( XhtmlException e ) {
throw new RenderException( e.getMessage(), e );
}
}
代码示例来源:origin: com.atlassian.confluence.extra/dynamictasklist2
/**
* @param taskList task list to save
* @param content containing content that will be saved. NOTE: this method will
* change the content before saving it.
* @param comment change comment
*/
public void save(final TaskList taskList, final ContentEntityObject content, String comment) {
ContentEntityObject original;
try {
original = (ContentEntityObject) content.clone();
} catch (Exception e) {
throw Throwables.propagate(e);
}
String updatedBody;
try {
updatedBody = xhtmlContent.updateMacroDefinitions(content.getBodyAsString(), new DefaultConversionContext(content.toPageContext()),
new TaskListMacroDefinitionUpdater(taskList, taskListSerializer, taskListDeserializer));
} catch (XhtmlException e) {
throw new RuntimeException(e);
}
content.setBodyAsString(updatedBody);
if (taskList.getConfig().getEnableVersioning()) {
content.setVersionComment("Dynamic Task List: " + comment);
// suppress notifications, update last modifier, but don't suppress other events
SaveContext saveContext = new DefaultSaveContext(true, true, false);
pageManager.saveContentEntity(content, original, saveContext);
}
}
代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking
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;
}
代码示例来源:origin: com.atlassian.confluence.extra.chart/chart-plugin
public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException
{
try
{
ConversionContext conversionContext = new DefaultConversionContext(renderContext);
List<RuntimeException> errorList = new ArrayList<>();
body = xhtmlContent.convertWikiToView(body, conversionContext, errorList);
if(!errorList.isEmpty())
{
for(RuntimeException runtimeException : errorList)
{
log.error("RuntimeException while parsing wiki markup ", runtimeException);
}
throw new MacroException(getI18NBean().getText("confluence.extra.chart.chart.error.parseWikiToStorage"));
}
return execute(parameters, body, conversionContext);
}
catch (MacroExecutionException | XhtmlException | XMLStreamException e)
{
throw new MacroException(e);
}
}
代码示例来源:origin: com.atlassian.confluence.plugins.toc/toc-plugin
/**
* This macro operates on the body of the content entity (e.g. the page) on which the macro is a part of. This
* method fetches the content body (which should be in XHTML storage-format), renders that to view-format, then
* returns that to be used as the basis of the TOC generation.
*/
@Override
protected String getContent(final Map<String, String> parameters, final String body, final ConversionContext conversionContext)
{
final ContentEntityObject contentEntity = conversionContext.getEntity();
if (contentEntity == null)
{
log.warn("There was an error converting the preview content to view - content entity object was null.");
return "";
}
try
{
return xhtmlContent.convertStorageToView(contentEntity.getBodyAsString(), conversionContext);
}
catch (Exception ex)
{
log.warn("There was an error converting the content for id " + contentEntity.getId() + " to storage format.", ex);
return "";
}
}
代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking
final String xhtml = xhtmlContent.convertStorageToView(
xhtmlContent.convertWikiToStorage(bodyText, conversionContext, conversionErrors),
conversionContext
);
代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking
public Map<String, String> getParameters(ContentEntityObject contentEntityObject)
{
BookmarkMacroHandler bookmarkMacroHandler = new BookmarkMacroHandler();
try
{
xhtmlContent.handleMacroDefinitions(
contentEntityObject.getBodyAsString(),
new DefaultConversionContext(contentEntityObject.toPageContext()),
bookmarkMacroHandler
);
}
catch (XhtmlException xhtmlError)
{
LOG.error(String.format("Unable to find bookmark macro parameters in content %s", contentEntityObject.toString()), xhtmlError);
}
return bookmarkMacroHandler.getParameters();
}
代码示例来源:origin: com.atlassian.confluence.plugins.socialbookmarking/socialbookmarking
: xhtmlContent.convertWikiToStorage(bodyText, conversionContext, conversionErrors);
代码示例来源:origin: com.atlassian.labs/confluence-mentions-plugin
velocityContext.put("contentHtml", xhtmlContent.convertWikiToView(contentEntityObject.getDisplayTitle(),
conversionContext, new ArrayList<RuntimeException>()));
代码示例来源:origin: net.customware.confluence.plugin.toc/toc-plugin
protected String getContent(Map<String, String> parameters , String body, ConversionContext conversionContext)
{
ContentEntityObject ceo = conversionContext.getEntity();
if (ceo == null)
{
log.warn("There was an error converting the preview content to view - content entity object was null.");
return "";
}
String pageContent = ceo.getBodyAsString();
try
{
return getXhtmlContent().convertStorageToView(pageContent, conversionContext);
}
catch (Exception ex)
{
log.warn("There was an error converting the content for id " + ceo.getId() + " to storage format.", ex);
return "";
}
}
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin
public ImmutableMap<String, ImmutableList<ImmutableMap<String, PageProperty>>> extractProperties(ContentEntityObject entity,
DetailsSummaryMacroMetricsEvent.Builder metrics)
{
// We need to marshall non-detail-macros encountered in the body of the detail macro, so that these macros
// can be rendered in the table of detail lines.
final DefaultConversionContext subContext = new DefaultConversionContext(entity.toPageContext());
final DetailsMacroBodyHandler macroBodyHandler = new DetailsMacroBodyHandler(metrics);
try
{
metrics.entityBodyFetchStart();
final String entityBody = entity.getBodyAsString();
metrics.entityBodyFetchFinish(defaultString(entityBody).length());
xhtmlContent.handleMacroDefinitions(entityBody, subContext, macroBodyHandler, MARSHALL_MACRO);
}
catch (XhtmlException e)
{
log.error("Cannot extract page properties from content with id: " + entity.getIdAsString(), e);
}
return macroBodyHandler.getDetails();
}
}
代码示例来源:origin: com.atlassian.confluence.plugin/func-test
commentManager.updateCommentContent(
pageComment,
xhtmlContent.convertWikiToStorage(
StringUtils.defaultString((String) commentStruct.get("content")),
new DefaultConversionContext(commentPage.toPageContext()),
commentPage,
parentComment,
xhtmlContent.convertWikiToStorage(
StringUtils.defaultString((String) commentStruct.get("content")),
new DefaultConversionContext(commentPage.toPageContext()),
代码示例来源:origin: com.atlassian.confluence.plugins/confluence-masterdetail-plugin
renderedValue = xhtmlContent.convertStorageToView(headingStorageFormat, context);
代码示例来源:origin: com.atlassian.confluence.extra/dynamictasklist2
/**
* Gets the list of tasks associated with the given listName and contentObject
*
* @param listName list name
* @param occurance occurance
* @param content contentObject
* @return the list of tasks associated with the given parameters
*/
public TaskList getTaskList(String listName, int occurance, final ContentEntityObject content) {
final TaskListId taskListId = new TaskListId(listName, occurance);
final TaskListMacroDefinitionHandler handler = new TaskListMacroDefinitionHandler(taskListId, taskListDeserializer);
try {
xhtmlContent.handleMacroDefinitions(content.getBodyAsString(), new DefaultConversionContext(content.toPageContext()), handler);
} catch (XhtmlException e) {
throw new RuntimeException(e);
}
return handler.getMatchingTaskList();
}
代码示例来源:origin: com.atlassian.confluence.plugin/func-test
@Override
public String getViewFormat(String authToken, String pageId) throws XMLStreamException, XhtmlException
{
ContentEntityObject contentEntityObject = getContentEntityObject(pageId);
return null == contentEntityObject ? null : xhtmlContent.convertStorageToView(contentEntityObject.getBodyAsString(), new DefaultConversionContext(contentEntityObject.toPageContext()));
}
代码示例来源:origin: org.randombits.support/support-confluence
private String renderRichText( Renderable renderable ) throws RenderException {
try {
return XhtmlUtils.stripParagraphWrapper(
xhtmlContent.convertStorageToView( renderable.getText(), renderable.getConversionContext()) );
} catch ( XMLStreamException e ) {
throw new RenderException( e.getMessage(), e );
} catch ( XhtmlException e ) {
throw new RenderException( e.getMessage(), e );
}
}
}
内容来源于网络,如有侵权,请联系作者删除!