Example Implementation of a Workflow Process Step

Problem

Resolution

A Workflow Precess Step implementation in Java is a Class which implements the Interface JavaProcessExt (or JavaProcess if no external attributes are used).

This Class must be a OSGI Service and implement the method execute(WorkItem item, WorkflowSession session, String[] args). In this method the provided objects item (WorkItem) and session (WorkflowSession) can be used to implement the business logic of the process step.

As soon as this Service is available in the system (for example when you include it in a bundle and install it) you can select it in the Workflow GUI (workflow model - process step - Implementation)...

Examples

Note: The following examples are just very simple examples not to be used in production as they are.
You have to include the example Class into one of your bundles and mark the package com.day.cq.examples.wf external to make the service available in the system...

Simple Workflow Process Step Example:

The following Workflow Process Step just checks the available routes to the next step(s) and process the route marked as defaut or the first rout if no route was marked as default and writes some logging.

Translation Workflow Process Step Example:

With this it's possible to define parallel XOR steps for the translation job for every language. Every step can belong to another user or group.
As Process Arguments you can set the default language (for example de) and the language hierarchy level (default is 3)

Note: As the Workfow GUI is not able to display more than two XOR (or AND) steps you have to manage workflows with more parallel XOR steps (so more than two languages) directly in CRX, please see How to add more than two "AND" Steps to a Workflow.
Attached you will find an example translation workflow (ExampleTranslationWorkflow-1.1-2.zip) with seven parallel XOR steps for en, de, fr, es, it, ja and zh. Please note that the user for all steps is admin, so this has to be adapted with the corresponding users or groups the translations should executed for the corresponding language...