*/
private void parse(XmlElement workflowElement) throws GraphException, ComponentException {
// Graph
XmlElement graphElement = workflowElement.element(GraphSchema.GRAPH_TAG);
this.graph = WSGraphFactory.createGraph(graphElement);
WsdlDefinitions wsdl = null;
XmlElement wsdlsElement = workflowElement.element(WSDLS_TAG);
for (XmlElement wsdlElement : wsdlsElement.elements(null, WSDL_TAG)) {
String wsdlText = wsdlElement.requiredText();
try {
wsdl = WSDLUtil.stringToWSDL(wsdlText);
} catch (UtilsException e) {
logger.error(e.getMessage(), e);
}
String id = wsdlElement.attributeValue(NS_XWF, ID_ATTRIBUTE);
if (id == null || id.length() == 0) {
// xwf up to 2.2.6_2 doesn't have ID.
id = WSDLUtil.getWSDLQName(wsdl).toString();
}
addWSDL(id, wsdl);
}
bindComponents();
// Image
XmlElement imageElement = workflowElement.element(IMAGE_TAG);
if (imageElement != null) {
String base64 = imageElement.requiredText();
byte[] bytes = Base64.decodeBase64(base64.getBytes());
try {
this.image = ImageIO.read(new ByteArrayInputStream(bytes));
} catch (IOException e) {
// This should not happen and it's OK that image is broken. We
// can reproduce it anytime.
logger.error(e.getMessage(), e);
}
}
XmlElement bpelElement = workflowElement.element(BPEL_TAG);
if (bpelElement != null) {
try {
String bpelString = bpelElement.requiredText();
XmlNamespace gpelNS = XmlInfosetBuilder.newInstance().newNamespace(BPELScript.GPEL, BPELScript.GPELNS);
GpelConstants.GPEL_NS = gpelNS;
this.gpelProcess = new GpelProcess(XMLUtil.stringToXmlElement(bpelString));
} catch (RuntimeException e) {
String error = "Failed to parse the BPEL document.";
throw new GraphException(error, e);
}
}
XmlElement workflowWSDLElement = workflowElement.element(WORKFLOW_WSDL_TAG);
if (workflowWSDLElement != null) {
try {
String wsdlText = workflowWSDLElement.requiredText();
this.workflowWSDL = new WsdlDefinitions(XMLUtil.stringToXmlElement(wsdlText));
} catch (RuntimeException e) {
String error = "Failed to parse the workflow WSDL.";
throw new GraphException(error, e);
}
}