/**
* Exports a BPEL process to the local file
*/
public void exportBPEL() {
Workflow workflow = this.engine.getWorkflow();
BPELScript bpel = new BPELScript(workflow);
// Check if there is any errors in the workflow first.
ArrayList<String> warnings = new ArrayList<String>();
if (!bpel.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;
}
int returnVal = this.bpelFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = this.bpelFileChooser.getSelectedFile();
logger.info(file.getPath());
String path = file.getPath();
// Remove ".bpel" at the end if any
if (path.endsWith(XBayaConstants.BPEL_SUFFIX)) {
path = path.substring(0, path.length() - XBayaConstants.BPEL_SUFFIX.length());
}
// Add ".bpel" at the end of the file name
File bpelFile = new File(path + XBayaConstants.BPEL_SUFFIX);
// Add ".wsdl" at the end of the file name
File wsdlFile = new File(path + XBayaConstants.WSDL_SUFFIX);
try {
// Create the script.
bpel.create(BPELScriptType.BPEL2);
GpelProcess gpelProcess = bpel.getGpelProcess();
XMLUtil.saveXML(gpelProcess.xml(), bpelFile);
WorkflowWSDL workflowWSDL = bpel.getWorkflowWSDL();
XMLUtil.saveXML(workflowWSDL.getWsdlDefinitions().xml(), wsdlFile);
} catch (IOException e) {
this.engine.getErrorWindow().error(ErrorMessages.WRITE_FILE_ERROR, e);
} catch (GraphException e) {