AEM Custom Workflow Process – Best practices

Problem statement:

What is the Adobe recommended way to create Custom Workflow Process?

Requirement:

Create the custom Workflow Process to do some business logic

Introduction:

WorkflowProcess is the interface to be used for automatic workflow steps implemented in Java. Classes implementing this interface define Java based processes that can be attached to a WorkflowNode and executed by the workflow engine.

Create Component Service with WorkflowProcessclass and implement WorkflowProcess class

Provide process.label for all the custom workflow process

Override execute method

package com.mysite.core.workflows;

import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;

/**
 * This process tracks back the properties which are changed in the generated
 * deck and updates its respective properties in all the assets.
 */
@Component(service = WorkflowProcess.class, property = { "process.label=Dynamic Deck Dynamo Write Back Process" })
public class CustomWorkflowProcess implements WorkflowProcess {
	private static final Logger LOGGER = LoggerFactory.getLogger(CustomWorkflowProcess.class);

	@Override
	public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
			throws WorkflowException {
		ResourceResolver resourceResolver;
		resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
	}
}

Refernces:

https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/indesign/dynamicdeckdynamo/workflow/processes/impl/DynamicDeckBackTrackProcess.java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s