All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.greenpepper.confluence.macros.GreenPepperWiki Maven / Gradle / Ivy

There is a newer version: 4.2.4
Show newest version
package com.greenpepper.confluence.macros;

import java.util.Map;

import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.macro.MacroExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.atlassian.renderer.RenderContext;
import com.atlassian.renderer.v2.RenderMode;
import com.atlassian.renderer.v2.macro.MacroException;

/**
 * 

GreenPepperWiki class.

* * @author oaouattara * @version $Id: $Id * @since 4.0-beta3 */ public class GreenPepperWiki extends AbstractGreenPepperMacro { private static final Logger LOGGER = LoggerFactory.getLogger(GreenPepperWiki.class); /** {@inheritDoc} */ @Override public boolean hasBody() { return true; } /** *

getBodyRenderMode.

* * @return a {@link com.atlassian.renderer.v2.RenderMode} object. */ public RenderMode getBodyRenderMode() { return RenderMode.ALL; } /** {@inheritDoc} */ @Override public BodyType getBodyType() { return BodyType.PLAIN_TEXT; } /** * Confluence 2 and 3 * * @param parameters * @param body * @param renderContext * @return * @throws MacroException */ @Override public String execute(@SuppressWarnings("rawtypes") Map parameters, String body, RenderContext renderContext) throws MacroException { try { return body; } catch (Exception e) { return getErrorView("greenpepper.info.macroid", e.getMessage()); } } /** * Confluence 4+ * @param parameters * @param body * @param context * @return * @throws MacroExecutionException */ @Override public String execute(Map parameters, String body, ConversionContext context) throws MacroExecutionException { try { String xhtmlRendered = gpUtil.getWikiStyleRenderer().convertWikiToXHtml(context.getPageContext(), body); LOGGER.trace("rendering : \n - source \n {} \n - output \n {}", body, xhtmlRendered); return xhtmlRendered; } catch (Exception e) { return getErrorView("greenpepper.info.macroid", e.getMessage()); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy