Confluence Docs 3.0 : Within a Confluence macro, how do I retrieve the current ContentEntityObject? This page last changed on Jan 24, 2006 by jnolen. ### Cannot resolve external resource into attachment. Within a Confluence macro, how do I retrieve the current ContentEntityObject? You can retrieve the current ContentEntityObject (ie the content object this macro is a part of), as follows:
    public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException {
        // retrieve a reference to the body object this macro is in
        if (!(renderContext instanceof PageContext))
        {
            throw new MacroException("This macro can only be used in a page");
        }
        ContentEntityObject contentObject = ((PageContext)renderContext).getEntity();
        ...
Note that this method might return null if there is no current content object (for example if you are previewing a page that has not been added yet, or if a remote user is rendering a fragment of notation).

Document generated by Confluence on Nov 05, 2009 23:34