Source:
public void execute(WorkItem item, WorkflowSession session, MetaDataMap metadata) throws WorkflowException { Map<String,String> args = getProcessArgsMap(metadata); String propertyName = args.get(WORKFLOW_PROPERTY_NAME); if (StringUtils.isBlank(propertyName)) { throw new WorkflowException ("propertyname not defined"); } String defaultWorkflowModel = args.get(DEFAULT_WORKFLOW_MODEL); LOG.debug ("propertyName = {}, default workflow model = {}", new Object[]{propertyName,defaultWorkflowModel}); ResourceResolver resolver = null; WorkflowData wfData = item.getWorkflowData(); if (wfData.getPayloadType().equals("JCR_PATH")) { String path = wfData.getPayload().toString(); Session jcrSession = session.adaptTo(Session.class); Map<String, Object> map = new HashMap<String, Object>(); map.put("user.jcr.session", jcrSession); try { resolver = rrf.getResourceResolver(map); } catch (LoginException e) { throw new WorkflowException (e); } if (resolver != null) { Resource wfResource = resolver.getResource(path); InheritanceValueMap inheritance = new HierarchyNodeInheritanceValueMap(wfResource); String foundWorkflowModel = inheritance.getInherited(propertyName, String.class); if (foundWorkflowModel != null) { LOG.debug ("Using workflowmodel {}", foundWorkflowModel); } else { if (defaultWorkflowModel == null) { throw new WorkflowException (String.format("Haven't found property %s on resource %s or higher, also defaultWorkflowModel not defined", new Object[]{propertyName,defaultWorkflowModel})); } else { foundWorkflowModel = defaultWorkflowModel; LOG.debug("Falling back to workflowmodel {}", foundWorkflowModel); } } WorkflowModel newModel = session.getModel(foundWorkflowModel); session.startWorkflow(newModel, wfData); LOG.debug("Started workflow model with current payload", foundWorkflowModel); } } }

Target:
public void execute(WorkItem item, WorkflowSession session, MetaDataMap metadata) throws WorkflowException { Map<String,String> args = getProcessArgsMap(metadata); String propertyName = args.get(WORKFLOW_PROPERTY_NAME); if (StringUtils.isBlank(propertyName)) { throw new WorkflowException ("PROCESS_ARG " + WORKFLOW_PROPERTY_NAME + " not defined"); } String defaultWorkflowModel = args.get(DEFAULT_WORKFLOW_MODEL); log.debug ("propertyName = {}, default workflow model = {}", new Object[]{propertyName,defaultWorkflowModel}); ResourceResolver resolver = null; WorkflowData wfData = item.getWorkflowData(); if (wfData.getPayloadType().equals("JCR_PATH")) { String path = wfData.getPayload().toString(); resolver = wfHelper.getResourceResolver(session); if (resolver != null) { Resource wfResource = resolver.getResource(path); InheritanceValueMap inheritance = new HierarchyNodeInheritanceValueMap(wfResource); String foundWorkflowModel = inheritance.getInherited(propertyName, String.class); if (foundWorkflowModel != null) { log.debug ("Using workflowmodel {}", foundWorkflowModel); } else { if (StringUtils.isBlank(defaultWorkflowModel)) { throw new WorkflowException (String.format("Haven't found property %s on resource %s or higher, also defaultWorkflowModel not defined", new Object[]{propertyName,defaultWorkflowModel})); } else { foundWorkflowModel = defaultWorkflowModel; log.debug("Falling back to configured default workflowmodel {}", foundWorkflowModel); } } WorkflowModel newModel = session.getModel(foundWorkflowModel); session.startWorkflow(newModel, wfData); log.info("Delegating workflow with payload to workflow model {}", new Object[]{wfData.getPayload() ,foundWorkflowModel}); } } }