Skip to content

Workflows

bartoszWesolowski edited this page Apr 28, 2020 · 4 revisions

Workflows

  • Implement bushiness processes
  • Performed desired action on assets and pages (workflow payload) - for example creating asset rendition
  • Each workflow consist of multiple steps executed after each other

Workflow execution - workflow instance is created and running (workflow was started):

  1. First step of workflow is executed
  2. Workflow engine determines which step to run next (based on workflow model)
  3. Next step is executed
  4. After all steps were executed workflow instance ends and is archived.

Executing a workflow instance generates a history that includes information about each step that has been executed for that instance - this can be useful for investigating errors.

Workflow step types

Participant step

  • Requires a user action
  • Can be assigned to group of users or particular user
  • User will get item in his Inbox which he needs to complete manually
  • Workflow instance will progress only when user step is finished

Process step

  • Service perform a step
  • Workflow instance will progress automatically

Participant process step

Process step example


@Component(immediate = true,
  property = {
    Constants.SERVICE_DESCRIPTION + "=Example workflow process",
    Constants.SERVICE_VENDOR + "=Vendor",
    WorkflowConstants.PROCESS_LABEL_PROPERTY_KEY + "=Example process step"
  })
public class CreateTaskForAssetCollaborators implements WorkflowProcess {

  @Reference
  private ResourceResolverFactory factory;

  @Override
  public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {

    try (ResourceResolver rr = factory.getServiceResourceResolver(null)) {
      if (PayloadMap.TYPE_JCR_PATH.equals(item.getWorkflowData().getPayloadType())) {
        String payloadPath = workItem.getWorkflowData().getPayload().toString();
        Resource payloadResource = Optional.ofNullable(resourceResolver.getResource(payloadPath))
          .orElseThrow(() -> new WorkflowException("Can not get workflow payload resource for path: " + payloadPath));
        // ....
      } else {
        throw new WorkflowException("Unsupported payload - only resource path is supported.");
      }
    } catch (LoginException e) {
      // handle exception
    }
  }

Using custom step in new workflow

  • Tools -> Workflow -> Models
  • Create new workflow
  • Add Process Step to the workflow parsys
  • Open step properties and select desired implementation to be invoked in this process
  • Workflow model stored in /conf directory
  • Runtime stored in /var directory - deploying changes through package will modify model definition in /conf, then in can be synced manually to update the runtime definition when other executions of the workflow are done

Clone this wiki locally