Search code examples
velocityconfluenceatlassian-plugin-sdk

What is the origin of $generalUtil in my atlassian-plugin.xml?


I'm studying the code of a custom Confluence plugin, which contains an atlassian-plugin.xml file that includes references to two variables $generalUtil and $helper, but I find no definitions of them whatsoever in the entire project. They simply work and it appears to me that they are magically instantiated out of thin air.

<web-item key="configtab" name="configtab" section="system.space.tools/addons">
  <label key="myplugin.space.tools.addons.tab.label" />
  <link>/spaces/myplugin-config.action?spaceKey=$generalUtil.urlEncode($helper.spaceKey)</link>
</web-item>

The $generalUtil must be an instance of com.atlassian.confluence.util.GeneralUtil, which also has a method urlEncode(). But where does this variable originate from?

What puzzles me even more is the $helper, which has a spaceKey field/method that I find in the code, but without any relationship to any kind of Helper class. The $helper also appears in a velocity template, but also without any definition of it. Any ideas where this stuff is documented?


Solution

  • generalUtil is documented here: https://docs.atlassian.com/ConfluenceServer/javadoc/7.11.6/

    I think helper is https://docs.atlassian.com/ConfluenceServer/javadoc/7.11.6/com/atlassian/confluence/themes/GlobalHelper.html

    They are injected into the Velocity context used to render that link.