cq5 - How to invoke a workflow providing data/arguments using Java API -
i've followed https://helpx.adobe.com/experience-manager/using/invoking-experience-manager-workflows-using.html , can invoke workflow using java api. i'm trying tweak example can start workflow metadatamap containing key value pairs steps work with. log message prints key , value sets. steps in workflow not have data. how pass metadatamap workflow when starting java api?
@override public string startworkflow(string workflowname, string workflowcontent, metadatamap metamap) { try { //invoke adaptto method create session resourceresolver resourceresolver = writeservice.getresolver(); session = resourceresolver.adaptto(session.class); //create workflow session workflowsession wfsession = workflowservice.getworkflowsession(session); // workflow model workflowmodel wfmodel = wfsession.getmodel(workflowname); // workflow data // first param in newworkflowdata method payloadtype. // fancy name let know type of workflow working with. workflowdata wfdata = wfsession.newworkflowdata("jcr_path", workflowcontent); metadatamap mdp = wfdata.getmetadatamap(); for(entry<string, object> entry: metamap.entryset()){ log.info("wf args entry="+ entry.getkey()+" "+entry.getvalue()); mdp.put(entry.getkey(), entry.getvalue()); } // run workflow. wfsession.startworkflow(wfmodel, wfdata, mdp); return workflowname +" has been invoked on content: "+workflowcontent ; } catch(exception e) { e.printstacktrace(); } return null; }
i believe trying data parameter of execute method - metadatamap, instead, workitem object, workitem.getworkflowdata().getmetadatamap()
.
Comments
Post a Comment