public void publishWorkflow(String workflowName, String publishWorkflowName) throws RegistryException {
if (publishedWorkflowRegistry != null){
publishedWorkflowRegistry.publishWorkflow(workflowName, publishWorkflowName);
} else {
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();
}