try {
//parse input:
Element rootElem = xmlUtil.parseXML(xml).getRootElement();
WorkflowManager wkflManager = getWorkflowManager();
Map config = new HashMap();
config.put("TASK_INFO_MANAGER", wkflManager);
config.put("WORKFLOW_MANAGER", wkflManager);
config.put("WORKFLOW_MANAGER_SERVICE", this);
config.put("WORKING_DIRECTORY", workDir);
WorkflowSubmissionSerializer wkflSerializer = serializers
.getWorkflowSerializerSet(wkflManager)
.getWorkflowSubmissionSerializer(config);
WorkflowSubmission wkfl = wkflSerializer.readWorkflow(rootElem);
wkfl.setContextParam("WORKING_DIRECTORY", workDir);
List jobs = wkfl.getJobs();
for (int i=0; i<jobs.size(); i++) {
JobSubmission job = (JobSubmission)jobs.get(i);
String jobId = "job_" + (i+1);
File subWorkDir = new File(workDir, jobId);
job.setContextParam("WORKING_DIRECTORY", subWorkDir);
}
//submit:
String wkflId = wkflManager.submitWorkflow(wkfl);
logger.debug("Workflow submitted: " + wkflId);
RunningJobInfo jobInfo = new RunningJobInfo(wkflId, null, workDir);
jobInfoManager.storeJobInfo(jobInfo);