*/
public boolean saveWorkflow() {
if (XBayaUtil.acquireJCRRegistry(this.engine)) {
try {
Workflow workflow = this.engine.getWorkflow();
JythonScript script = new JythonScript(workflow, this.engine.getConfiguration());
// Check if there is any errors in the workflow first.
ArrayList<String> warnings = new ArrayList<String>();
if (!script.validate(warnings)) {
StringBuilder buf = new StringBuilder();
for (String warning : warnings) {
buf.append("- ");
buf.append(warning);
buf.append("\n");
}
this.engine.getErrorWindow().warning(buf.toString());
return false;
}
RegistryWorkflowPublisherWindow registryPublishingWindow = new RegistryWorkflowPublisherWindow(
this.engine);
registryPublishingWindow.show();
String workflowId = workflow.getName();
workflowId = StringUtil.convertToJavaIdentifier(workflowId);
// FIXME::Commenting the workflow UUID. It is debatable if the
// workflow template id should be unique or not.
// workflowId = workflowId + UUID.randomUUID();
QName workflowQName = new QName(XBayaConstants.OGCE_WORKFLOW_NS, workflowId);
// first find whether this resource is already in xregistry
// TODO: Add the check back
// DocData[] resource =
// client.findOGCEResource(workflowQName.toString(), "Workflow",
// null);
// if (resource != null && !"".equals(resource)) {
// // if already there then remove
//
// int result =
// JOptionPane.showConfirmDialog(this.engine.getGUI().getGraphCanvas().getSwingComponent(),
// "Workflow Already Exist in Xregistry. Do you want to overwrite",
// "Workflow already exist", JOptionPane.YES_NO_OPTION);
// if(result != JOptionPane.YES_OPTION){
// return;
// }
// client.removeResource(workflowQName);
// }
String workflowAsString = XMLUtil.xmlElementToString(workflow.toXML());
String owner = this.engine.getConfiguration().getRegistryUserName();
AiravataRegistry registry = this.connectToRegistry();
boolean result = registry.saveWorkflow(workflowQName, workflow.getName(), workflow.getDescription(), workflowAsString,
owner, registryPublishingWindow.isMakePublic());
registryPublishingWindow.hide();
return result;
} catch (Exception e) {
this.engine.getErrorWindow().error(e.getMessage(), e);