I have a requirement where I need to create the jobspec xml file in one of the external task in our workflow and simply start a sub workflow off of that jobspec. In perl, I could issue the iwmodelc command and it worked. However in java I don't see any libraries I could use to achieve this. I tried using com.interwoven.modeler.clt.* but not sure which object/function to use from here.Has anyone has this specific need that can help me?Thanks,Anna.
/* * URLExternalTaskSimpleTest.java */package dfait.custom.workflow;import com.interwoven.cssdk.common.CSClient;import com.interwoven.cssdk.common.CSException;import com.interwoven.cssdk.workflow.*;import java.lang.Runtime;import java.io.*;import java.util.*;/** * An simple implementation of an external task. */public class DFAITComponentController implements CSURLExternalTask{ public void execute ( CSClient client, CSExternalTask task, Hashtable params)throws CSException { CSWorkflow job = task.getWorkflow(); String rss_enabled = job.getVariable("rssupdate_triggered"); String lyris_enabled = job.getVariable("lyris_triggered"); System.out.println("Testing"); try{ String command = "D:\\iw-home\\bin\\iwmodelc.exe -d \"Lyris Workflow\" \"/dfait-maeci/main/internet-internet/ci-ci/ci-ci/WORKAREA/content-contenu\" \"d:/iw-home/local/logs/wf\""; Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(command); InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; System.out.println("Output of running %s is: "+ command); while ((line = br.readLine()) != null) { System.out.println("Line:"+ line); } }catch(IOException o){ System.out.println("IO Execption"); System.out.println(o.toString()); } }}
TestingIO Execptionjava.io.IOException: CreateProcess: \iw-home\bin\iwmodelc.exe -d "Lyris Workflow" "/dfait-maeci/main/internet-internet/ci-ci/ci-ci/WORKAREA/content-contenu" "d:/iw-home/local/logs/wf" error=2
import java.util.Hashtable;import com.interwoven.cssdk.common.CSClient;import com.interwoven.cssdk.common.CSException;import com.interwoven.cssdk.workflow.CSExternalTask;import com.interwoven.cssdk.workflow.CSURLExternalTask;import com.interwoven.cssdk.workflow.CSWorkflow;import com.interwoven.cssdk.workflow.CSWorkflowEngine;public class RunNestedWFM implements CSURLExternalTask { // ... public void execute(CSClient client, CSExternalTask task, Hashtable hash) throws CSException { //... String jobSpec = createJobSpec(/* parameters TBD */); CSWorkflowEngine wfsys = client.getWorkflowEngine(); CSWorkflow subJob = wfsys.createNestedWorkflow(jobSpec, task.getId()); // ... }}
Thanks,I was hoping to do something similar too. but I could not find the function/library that I could use to create the jobspec. In your code where does the function createJobSpec() come from? Were you thinking of a custom function or from one of the CSSDK libraries?I couldn't find the right function that would create the jobspec for me given the wfm and your function createJobSpec() won't work unless it is in one of the java libraries.I'll keep looking,Anna.