if (userWorkflowRegistry != null){
userWorkflowRegistry.updateWorkflow(workflowName, workflowGraphXml);
}else {
WorkerResource worker = jpa.getWorker();
if (!isWorkflowExists(workflowName)){
throw new UserWorkflowDoesNotExistsException(workflowName);
}
UserWorkflowResource workflowResource = worker.getWorkflowTemplate(workflowName);
workflowResource.setContent(workflowGraphXml);
workflowResource.save();
}