GatewayResource gateway = jpa.getGateway();
String workflowGraphXML = getWorkflowGraphXML(workflowName);
if (gateway.isPublishedWorkflowExists(publishWorkflowName)){
throw new PublishedWorkflowAlreadyExistsException(publishWorkflowName);
}
PublishWorkflowResource publishedWorkflow = gateway.createPublishedWorkflow(publishWorkflowName);
publishedWorkflow.setCreatedUser(getUser().getUserName());
publishedWorkflow.setContent(workflowGraphXML);
publishedWorkflow.setPublishedDate(new Timestamp(Calendar.getInstance().getTime().getTime()));
publishedWorkflow.save();
}
}