Last updated Dec 8, 2017

Writing a Blueprint - Advanced

If you've followed the steps in Confluence Blueprints and Writing a Blueprint - Intermediate and find that your Blueprint needs more flexibility, you're probably going to want a custom action and may have to interact with some other components made available by the Blueprint API.

Adding a dependency on the confluence-create-content-plugin

The Blueprint API is provided by a plugin called the confluence-create-content-plugin, so to interact with the API you will have to add a dependency in your project's pom.xml.

1
2
<dependency>
    <groupId>com.atlassian.confluence.plugins</groupId>
    <artifactId>confluence-create-content-plugin</artifactId>
    <!-- 1.5.25 is the version released with Confluence 5.1.4 -->
    <version>1.5.25</version>
    <scope>provided</scope>
</dependency>

Adding an event listener

If the only functionality you need to add to the default behaviour is to take some action after the Blueprint is created, you can listen for the BlueprintPageCreateEvent.

1
2
public class MyBlueprintListener
{
    private static final ModuleCompleteKey MY_BLUEPRINT_KEY = new ModuleCompleteKey(
        "com.atlassian.confluence.plugins.myplugin", "myplugin-blueprint");

    public MyBlueprintListener(EventPublisher eventPublisher)
    {
        eventPublisher.register(this);
    }

    @EventListener
    public void onBlueprintCreateEvent(BlueprintPageCreateEvent event)
    {
        ModuleCompleteKey moduleCompleteKey = event.getBluePrintKey();
        if (MY_BLUEPRINT_KEY.equals(moduleCompleteKey))
        {
            // Take some action when a My Plugin Blueprint is created
            System.out.println("Created your kind of blueprint");
        }
    }
}

You will also need to register the class as a component in your atlassian-plugin.xml

1
2
<component key="my-listener" class="myplugin.MyBlueprintListener" />

Blueprint API components

We are currently in the process of updating this Blueprints API for v2.

Please contact us if you require access to these managers in your plugin.

If you need to interact with the Blueprints API at a low level, you can import and use these components:

Component KeyInterfaceMethods
blueprintManagercom.atlassian.confluence.plugins.createcontent.actions.BlueprintManager
  • createAndPinIndexPage checks for and creates a index page if required for this blueprint, and pins it to the Space Sidebar.
  • setBlueprintCreatedByUser flags that a Blueprint of a certain type has been created by a given user
contentGeneratorcom.atlassian.confluence.plugins.createcontent.actions.BlueprintContentGenerator
  • createIndexPageObject creates a content page object given a plugin template and a render context.

  • generateBlueprintPageObject creates an index page object given a plugin template and a render context.

Rate this page: