/** * 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; }
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(); }
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(); } }
/** * 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(); }