Execute workflow process step only if the payload is having only one level of child or no child.
otherwise display error message to author that "Node is having grand child pages"
Example :
Scene 1 [true]: if we pass payload : /content/we-retail/ca/en/experience/arctic-surfing-in-lofoten to workflow it will check the payload is having only one level of child, then execute the logic.
Scene 2 [true]: if we pass payload : /content/we-retail/ca/en/experience/arctic-surfing-in-lofoten/men to workflow it will check the payload is having only one level or no level of child, then execute the logic
Scene 3 [false]: if we pass payload : /content/we-retail/ca/en/experience to workflow it will check the payload is having only one level or no level of child, then execute the logic otherwise display error message to author that "Node is having grand child pages"
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
String payload = workItem.getWorkflowData().getPayload().toString();
ResourceResolver resourceResolver = resourceResolverUtil.getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
Page rootPage = resourceResolver.getResource(payload).adaptTo(Page.class);
//TODO check page is having only one level or no child and update the values.
if (rootPage != null && payload.startsWith(ROOT_PATH) && "Check if node is having one level or no child") {
// code logic here..
}
}
Thanks
@arunpatidar @lukasz-m @kautuk_sahni