Developers' Guide to Creating Custom Suppliers

The following documentation is provided as is and is out of scope for technical support.

Starting from Reporting version 6.0.0, RandomBits Plugins have been consolidated into a new compile-time library for Reporting and other ServiceRocket add-ons. Due to this major change, developers who previously developed custom suppliers for use with Reporting will need to make some changes.

Upcoming changes

As of Reporting version 6.6.0, support for supplier-core and support-core plugins will be removed from Reporting, which means support for the legacy custom supplier, custom reporter, and custom query will be removed.

This tutorial will take you to step by step through the process of creating your first Custom Supplier and to also register the created Custom Supplier into the Reporting for Confluence app by Appfire.

When you complete the tutorial, you will have added a Custom Supplier into the Reporting add-on and you will be able to retrieve and display the data on your Confluence page by using macros of Reporting add-on.

Step-by-Step Guide

Step 1: Create Your Plugin Project

If you haven't already done so, go ahead and open a terminal window and do the following:

  1. Create a directory under your home directory and navigate to the directory.
     
  2. Once you are in the directory, enter the atlas-create-confluence-plugin command to create the plugin.

    atlas-create-confluence-plugin 
  3. The command prompts you with the basic information each plugin needs.

    Confirm properties configuration:
    groupId: com.servicerocket.confluence.plugin
    artifactId: custom-supplier
    version: 1.0-SNAPSHOT
    package: com.servicerocket.confluence.plugin

Step 2: Add ServiceRocket Utility Library As Dependency

You need to add the ServiceRocket Utility Library add-on as a dependency to your plugin's pom.xml, which will be available on OSS Sonatype:

<dependency>
    <groupId>com.servicerocket.confluence.plugin</groupId>
    <artifactId>servicerocket-utility-library</artifactId>
    <version>2.2.0</version>
    <scope>provided</scope>
</dependency>

Step 3: Create Custom Supplier Class

  1. Now you can create your custom supplier class, com.servicerocket.confluence.plugin.MyCustomSupplier.
  2. The custom supplier will look like this:

    package com.servicerocket.confluence.plugin;
    
    import com.atlassian.confluence.spaces.Space;
    import com.servicerocket.confluence.randombits.supplier.core.annotate.*;
    import org.randombits.utils.lang.API;
    
    @SupplierPrefix("custom-supplier")
    @SupportedTypes(Space.class)
    @API("1.0.0")
    public class MyCustomSupplier extends AnnotatedSupplier {
    
        @SupplierKey("{key}")
        public String getValue(@KeyValue Space space, @KeyParam("key") String key) {
            if (key.equals("key")) {
                return "Key";
            }
            return null;
        }
    
        @SupplierKey("supplier key")
        public String getValue(@KeyValue Space space) {
            return "Supplier Key";
        }
    }
  3. It supports the Space type as the input value.
  4. It defines two SupplierKeys, one accepts a dynamic "{key}" and the other a fixed "supplier key". Both supplier keys will return a String value.

Step 4: Register the Custom Supplier

You need to register the custom supplier that you created earlier into your atlassian-plugin.xml.

<reporting-supplier key="customSupplier" name="Custom Supplier" class="com.servicerocket.confluence.plugin.MyCustomSupplier"/>

Step 5: Check Your Work

  1. Run "mvn clean install" to create the plugin installer.

    mvn clean install
  2. Install your plugin into your Confluence instance.
     
  3. Create a new page and insert a {report-info} macro with the following key.

    content:space > custom-supplier:supplier key
  4. You should see "Supplier Key" in the page.