Problem statement:
What is the recommended way to create a custom workflow process in AEM?
Requirement:
This article discusses the recommended approach to creating custom workflow processes in Adobe Experience Manager (AEM) for implementing business logic. The author outlines the steps for creating a custom workflow process, including creating a component service with WorkflowProcessclass and providing a process. label, and override the execute method. The article includes a code example to illustrate the process.
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);
}
}
Thanks Kiran
LikeLiked by 1 person