I have experience Fragment Footer/master.
There is a tag field (cq:tags) available on both Footer and Master. I have authored on Footer but not on master
Now if I try to run a workflow on master and try to fetch cq:tags using InheritanceValueMap I am not able to fetch from Footer properties.
InheritanceValueMap inheritanceValueMap = new HierarchyNodeInheritanceValueMap(resource);
String[] tagValue = inheritanceValueMap.getInherited("cq:tags", String[].class);
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
I've tried by initiating a Workflow Model on the master node. And I can have the value of cq:tags I have set on the parent Footer Experience Fragment.
My Workflow Model has a custom WorkflowProcess. Here is the simplified version of the code -
@Slf4j
@Component(service = WorkflowProcess.class, property = {"process.label=Test Workflow Process"})
public class TestProcess implements WorkflowProcess {
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
try {
Session session = workflowSession.adaptTo(Session.class);
WorkflowData workflowData = workItem.getWorkflowData();
if ("JCR_PATH".equals(workflowData.getPayloadType()) && workflowData.getPayload() != null) {
String payloadData = workflowData.getPayload().toString();
String pagePath = session.itemExists(payloadData) ? payloadData : StringUtils.EMPTY;
Resource resource = workflowSession.adaptTo(ResourceResolver.class).getResource(pagePath);
String[] tagValue = new HierarchyNodeInheritanceValueMap(resource).getInherited("cq:tags", String[].class);
log.info(String.join(", ", tagValue));
}
} catch (RuntimeException | RepositoryException e) {
log.error("error due to {}", e.getMessage(), e);
}
}
}
Please make sure that your imports are from com.adobe.granite.workflow. Here are the ones I used -
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.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.service.component.annotations.Component;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
I've tried by initiating a Workflow Model on the master node. And I can have the value of cq:tags I have set on the parent Footer Experience Fragment.
My Workflow Model has a custom WorkflowProcess. Here is the simplified version of the code -
@Slf4j
@Component(service = WorkflowProcess.class, property = {"process.label=Test Workflow Process"})
public class TestProcess implements WorkflowProcess {
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
try {
Session session = workflowSession.adaptTo(Session.class);
WorkflowData workflowData = workItem.getWorkflowData();
if ("JCR_PATH".equals(workflowData.getPayloadType()) && workflowData.getPayload() != null) {
String payloadData = workflowData.getPayload().toString();
String pagePath = session.itemExists(payloadData) ? payloadData : StringUtils.EMPTY;
Resource resource = workflowSession.adaptTo(ResourceResolver.class).getResource(pagePath);
String[] tagValue = new HierarchyNodeInheritanceValueMap(resource).getInherited("cq:tags", String[].class);
log.info(String.join(", ", tagValue));
}
} catch (RuntimeException | RepositoryException e) {
log.error("error due to {}", e.getMessage(), e);
}
}
}
Please make sure that your imports are from com.adobe.granite.workflow. Here are the ones I used -
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.WorkflowData;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import com.day.cq.commons.inherit.HierarchyNodeInheritanceValueMap;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.service.component.annotations.Component;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies