Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

You need to set up your project and environment go be able to use the Workflow API Services

You can use the Comala Workflows Document Management API Services to request and manipulate State, Tasks, Approval and Document Activity information.

...

The API Services are divided in four five groups

  • State Services

  • Task Services

  • Approval Services

  • Workflow Services

  • DocumentActivityService

Access the full Javadoc documentation for the API services here

The service objects have to be imported in your atlassian-plugin.xml:

Code Block
theme
languagexmlRDark
<component-import name="Comala Workflows API" key="workflowService" interface="com.comalatech.workflow.WorkflowService"/>
<component-import name="Comala State Services" key="stateService" interface="com.comalatech.workflow.StateService"/>
<component-import name="Comala Tasks Services" key="taskService" interface="com.comalatech.workflow.TaskService"/>
<component-import name="Comala Approvals Services" key="approvalService" interface="com.comalatech.workflow.ApprovalService"/>
<component-import name="Comala Document Activity API" key="documentActivitySevice" interface="com.comalatech.workflow.DocumentActivityService"/>

...

The services can then be imported by your plugin modules:

Code Block
languagejavathemeRDark
public class ShowStateMacro extends BaseMacro {

    private PageManager pageManager;

    private StateService stateService;

    public boolean hasBody() {
        return false;
    }

    public RenderMode getBodyRenderMode() {
        return RenderMode.NO_RENDER;
    }

    public String execute(Map parameters, String body, RenderContext renderContext) throws MacroException {
        AbstractPage page = (AbstractPage) ((PageContext)renderContext).getEntity();
        boolean isPublishedState = "releaseview".equalsIgnoreCase(ActionContext.getContext().getName());
        
        State state;
        if (isPublishedState) {
            state = stateService.getPublishedState(page);
        } else {
            state = stateService.getCurrentState(page);
        } if (state == null) {
            throw new MacroException("page does not have published state"); 
        }
        Map<String,Object> contextMap = MacroUtils.defaultVelocityContext();
        contextMap.put("state",state);
        contextMap.put("page",page);
        contextMap.put("pageManger",pageManager);
        return VelocityUtils.getRenderedTemplate("templates/com/comalatech/confluence/workflowutils/state.vm", contextMap);
    }

    public void setStateService(StateService stateService) {
        this.stateService = stateService;
    }

    public void setPageManager(PageManager pageManager) {
        this.pageManager = pageManager;
    }
}

...

If using Atlassian spring scanner, then skip component-imports in atlassian-plugin.xml and use annotations @ComponentImport  right inside your plugin component:

Code Block
languagejavathemeRDark
@ComponentImport
private WorkflowService workflowService;

...

One thing to be aware of when using the API Services is that many of the get methods are driven by the Confluence index internally. This means that some updates may not appear through calls to the API as the index can take a few minutes to update depending on the settings in your Confluence instance.