Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reverted from v. 8
Info

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

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

Usage

The API Services are divided in 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
languagexml
<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
languagejava
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
languagejava
@ComponentImport
private WorkflowService workflowService;