JCR Session comes back null in custom Workflow step implementation
I have created a custom Workflow step for AEM 6.0. I created a class that implements com.adobe.granite.workflow.exec.WorkflowProcess. I need to get the jcr session and session.adaptTo(Session.class) is returning null. session is not null and its type is com.adobe.granite.workflow.WorkflowSession. The example in the Extending Workflow Functionality documentation uses this call to get the jcr session. http://docs.adobe.com/docs/en/aem/6-0/develop/extending/workflows/wf-extending.html
Below is the class declaration and the first part of the execute method. This custom Workflow step is set up in place of the Product Asset Upload step at the end of the DAM Update Asset Workflow.
@Component
@Service(value = WorkflowProcess.class)
@Properties({
@Property(name = "process.label", value = "Custom Product Assets Upload Process"),
@Property(name = Constants.SERVICE_DESCRIPTION, value = "Custom Product Assets Upload Process"),
@Property(name = Constants.SERVICE_VENDOR, value = "Test")
})
public class CustomProductAssetsUploadProcess implements com.adobe.granite.workflow.exec.WorkflowProcess{
private static final String TYPE_JCR_PATH = "JCR_PATH";
private static final Logger log = LoggerFactory.getLogger(CustomProductAssetsUploadProcess.class);
public static final String ENABLE_WRITEBACK = "writebackEnable";
@Reference(cardinality= ReferenceCardinality.MANDATORY_UNARY, policy = ReferencePolicy.STATIC)
private ResourceResolverFactory resourceResolverFactory;
public void execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
try {
String payloadPath = null;
if (item.getWorkflowData().getPayloadType().equals(TYPE_JCR_PATH)) {
payloadPath = item.getWorkflowData().getPayload().toString();
}
log.info("payload path :"+payloadPath);
Session jcrSession = session.adaptTo(Session.class);
...
