public String execute(Map params, String body, RenderContext renderContext) throws MacroException {
@SuppressWarnings("unchecked")
Map<String, String> typeSafeMacroParams = (Map<String, String>) params;
if (!isThumbnailSupported()) {
return "<p><span class=\"error\">"
+ getConfluenceActionSupport().getText("gallery.error.thumbnails-not-supported")
+ "</span></p>";
}
Integer galleryId = nextGalleryId(renderContext);
String title = typeSafeMacroParams.get("title");
Thumbnails thumbnails = findThumbnails(typeSafeMacroParams, renderContext);
boolean slideshow = renderContext.getOutputType().equals(RenderContextOutputType.DISPLAY);
String template = getTemplate(null);
VelocityContext contextMap = createVelocityContext(galleryId, title, thumbnails, slideshow);
try {
return getRenderedTemplateWithoutSwallowingErrors(template, contextMap);
} catch (ResourceNotFoundException e) {
return "<p><span class='error'>"
+ getConfluenceActionSupport().getText("gallery.error.unable-to-find-render-template", new String[]{escapeHtml4(typeSafeMacroParams.get("theme"))})
+ "</span></p>";
} catch (Exception exception) {
log.error("Error while trying to draw the image gallery", exception);
return "<p><span class='error'>"
+ getConfluenceActionSupport().getText("gallery.error.unable-to-render", new String[]{escapeHtml4(exception.toString())})
+ "</span></p>";
}
}