Uploaded image for project: 'JIRA Components'
  1. JIRA Components
  2. JIRA-120

The JIRA Scripting API cannot be used from Velocity

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 8.2
    • API
    • Unknown

    Description

      Problem

      $services.jira (JiraScriptService in jira-api) exposes exactly one public method:

      public JiraRestClient getJiraRestClient(JIRAServer jiraServer)
      

      A Velocity script has no way to obtain a JIRAServer instance:

      • Velocity cannot instantiate objects, so new JIRAServer(...) is not an option.
      • $services.component.getInstance() takes a java.lang.reflect.Type, which Velocity cannot produce, since getClass() and Class.forName are blocked by SecureUberspector.

      The getJiraRestClient(String jiraURL, AuthenticationHandler) overload is private, and there is no getJiraRestClient(String serverId) method. The scripting API is therefore usable from Groovy only.

      This looks like a lost capability rather than a deliberate choice: the commit that introduced the module (XWIKI-6879, 2011) says "Make it possible to use it from Velocity", and the documentation on extensions.xwiki.org carried Velocity examples calling $services.jira.getJiraRestClient($serverId) - a method that has never existed in this repository. Those examples were dropped when the documentation was migrated to xwiki.org, and the new page documents Groovy only, with the gap stated in its FAQ.

      Suggested fix

      Add a public getJiraRestClient(String serverId) that resolves the id against JIRAConfiguration.getJIRAServers(), so a Velocity script can use an instance declared in the JIRA administration section.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vmassol Vincent Massol
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: