public String getHtml(MacroParameter macroParameter) throws IllegalArgumentException, IOException {
Map<String, Object> contextMap = getDefaultVelocityContext();
Map contextParams = macroParameter.getContext().getParameters();
String currentSpaceKey = ((PageContext) contextParams.get(WikiRendererContextKeys.RENDER_CONTEXT)).getSpaceKey();
final Space currentSpace = spaceManager.getSpace(currentSpaceKey);
final int maxPages = Integer.valueOf(System.getProperty("page.index.macro.max.pages", Integer.toString(INDEX_RENDER_LIMIT)));
final long totalPages = pageManager.getPageCount(currentSpace.getKey());
contextMap.put("totalPages", totalPages);
contextMap.put("maxPages", maxPages);
contextMap.put("baseurl", calculateBaseUrl());
if (totalPages > maxPages) {
contextMap.put("docUrl", docBean.getLink(DOC_LINK));
return getVelocityRenderedTemplate(TEMPLATE_ERROR, contextMap);
}
final List<Page> pages = fetchPages(currentSpace);
contextMap.put("pages", new AlphabeticPageListing(pages));
contextMap.put("thisMacro", this);
contextMap.put("excerptRenderLimit", EXCERPT_RENDER_LIMIT);
try {
return getVelocityRenderedTemplate(TEMPLATE, contextMap);
} catch (Exception e) {
log.error("Error while trying to assemble the IndexMacro result!", e);
throw new IOException(e.getMessage());
}
}