API Services

Overview

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

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

Usage

The available API Services are the following:

  • State Services

    • → Retrieve current status-related information as well as perform actions over the current state

  • Task Services

    • Retrieve tasks and perform task-related actions given a task and a piece of content

  • Approval Services

    • → Perform approval-related actions given an approval name and a piece of content

  • Workflow Services

    • → Retrieve workflows and perform workflow-related actions

  • Workflow Configuration Service

    • → Retrieve and modify global and space-level workflow configuration settings

  • Document Activity Service

    • → Retrieve document activity entries of groups of pages or whole spaces

  • Approval Stats Service

    • → Actions to retrieve Approval and Approver-related statistics

  • State Stats Service

    • → Actions to retrieve State-related statistics

Access the full Javadoc documentation for the API services here.

Service objects

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

<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="Workflow Configuration Service" key="workflowConfigurationService" interface="com.comalatech.workflow.WorkflowConfigurationService"/> <component-import name="Comala Document Activity API" key="documentActivitySevice" interface="com.comalatech.workflow.DocumentActivityService"/> <component-import name="Approval Stats Service" key="approvalStatsService" interface="com.comalatech.workflow.statistics.ApprovalStatsService"/> <component-import name="State Stats Service" key="stateStatsService" interface="com.comalatech.workflow.statistics.StateStatsService"/>

Services import

The services can then be imported by your plugin modules.

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; } }

Atlassian spring scanner

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

@ComponentImport private WorkflowService workflowService;