http://git-wip-us.apache.org/repos/asf/airavata/blob/9a6eaaae/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEClient.java ---------------------------------------------------------------------- diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEClient.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEClient.java index 2263eeb..fc69988 100644 --- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEClient.java +++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEClient.java @@ -1,100 +1,100 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.workflow.model.ode; - -import java.util.LinkedList; -import java.util.List; - -import org.apache.airavata.workflow.model.component.ComponentException; -import org.apache.airavata.workflow.model.component.ws.WSComponentPort; -import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; -import org.apache.airavata.workflow.model.gpel.script.BPELScript; -import org.apache.airavata.workflow.model.gpel.script.BPELScriptType; -import org.apache.airavata.workflow.model.graph.GraphException; -import org.apache.airavata.workflow.model.graph.impl.NodeImpl; -import org.apache.airavata.workflow.model.graph.system.InputNode; -import org.apache.airavata.workflow.model.graph.system.OutputNode; -import org.apache.airavata.workflow.model.wf.Workflow; - -public class ODEClient { - - public static final String STREAM_SOURCE_NS = "http://extreme.indiana.edu/streaming/source"; - - public ODEClient() { - - } - - public List<InputNode> getInputNodes(Workflow workflow) { - LinkedList<InputNode> ret = new LinkedList<InputNode>(); - List<NodeImpl> nodes = workflow.getGraph().getNodes(); - for (NodeImpl nodeImpl : nodes) { - if (nodeImpl instanceof InputNode) { - ret.add((InputNode) nodeImpl); - } - - } - return ret; - } - - /** - * Returns workflow inputs and can be used to get workflow input metadata - * - * @param workflow - * @return - */ - public List<WSComponentPort> getInputs(Workflow workflow) { - List<WSComponentPort> inputs; - try { - if (workflow.getWorkflowWSDL() == null) { - BPELScript script = new BPELScript(workflow); - script.create(BPELScriptType.BPEL2); - workflow.setWorkflowWSDL(script.getWorkflowWSDL().getWsdlDefinitions()); - workflow.setGpelProcess(script.getGpelProcess()); - - } - inputs = workflow.getInputs(); - return inputs; - } catch (GraphException e) { - throw new WorkflowRuntimeException(e); - } catch (ComponentException e) { - throw new WorkflowRuntimeException(e); - } - - } - - /** - * @param workflow - * @return - */ - public LinkedList<OutputNode> getoutNodes(Workflow workflow) { - List<NodeImpl> nodes = workflow.getGraph().getNodes(); - LinkedList<OutputNode> ret = new LinkedList<OutputNode>(); - for (NodeImpl nodeImpl : nodes) { - if (nodeImpl instanceof OutputNode) { - ret.add((OutputNode) nodeImpl); - } - } - return ret; - - } - -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.workflow.model.ode; +// +//import java.util.LinkedList; +//import java.util.List; +// +//import org.apache.airavata.workflow.model.component.ComponentException; +//import org.apache.airavata.workflow.model.component.ws.WSComponentPort; +//import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; +//import org.apache.airavata.workflow.model.gpel.script.BPELScript; +//import org.apache.airavata.workflow.model.gpel.script.BPELScriptType; +//import org.apache.airavata.workflow.model.graph.GraphException; +//import org.apache.airavata.workflow.model.graph.impl.NodeImpl; +//import org.apache.airavata.workflow.model.graph.system.InputNode; +//import org.apache.airavata.workflow.model.graph.system.OutputNode; +//import org.apache.airavata.workflow.model.wf.Workflow; +// +//public class ODEClient { +// +// public static final String STREAM_SOURCE_NS = "http://extreme.indiana.edu/streaming/source"; +// +// public ODEClient() { +// +// } +// +// public List<InputNode> getInputNodes(Workflow workflow) { +// LinkedList<InputNode> ret = new LinkedList<InputNode>(); +// List<NodeImpl> nodes = workflow.getGraph().getNodes(); +// for (NodeImpl nodeImpl : nodes) { +// if (nodeImpl instanceof InputNode) { +// ret.add((InputNode) nodeImpl); +// } +// +// } +// return ret; +// } +// +// /** +// * Returns workflow inputs and can be used to get workflow input metadata +// * +// * @param workflow +// * @return +// */ +// public List<WSComponentPort> getInputs(Workflow workflow) { +// List<WSComponentPort> inputs; +// try { +// if (workflow.getWorkflowWSDL() == null) { +// BPELScript script = new BPELScript(workflow); +// script.create(BPELScriptType.BPEL2); +// workflow.setWorkflowWSDL(script.getWorkflowWSDL().getWsdlDefinitions()); +// workflow.setGpelProcess(script.getGpelProcess()); +// +// } +// inputs = workflow.getInputs(); +// return inputs; +// } catch (GraphException e) { +// throw new WorkflowRuntimeException(e); +// } catch (ComponentException e) { +// throw new WorkflowRuntimeException(e); +// } +// +// } +// +// /** +// * @param workflow +// * @return +// */ +// public LinkedList<OutputNode> getoutNodes(Workflow workflow) { +// List<NodeImpl> nodes = workflow.getGraph().getNodes(); +// LinkedList<OutputNode> ret = new LinkedList<OutputNode>(); +// for (NodeImpl nodeImpl : nodes) { +// if (nodeImpl instanceof OutputNode) { +// ret.add((OutputNode) nodeImpl); +// } +// } +// return ret; +// +// } +// +//} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/9a6eaaae/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEDeploymentDescriptor.java ---------------------------------------------------------------------- diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEDeploymentDescriptor.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEDeploymentDescriptor.java index 5f7dedc..914e8f6 100644 --- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEDeploymentDescriptor.java +++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEDeploymentDescriptor.java @@ -1,184 +1,184 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.workflow.model.ode; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import javax.xml.namespace.QName; - -import org.apache.airavata.workflow.model.graph.GraphException; -import org.gpel.model.GpelPartnerLink; -import org.gpel.model.GpelPartnerLinksContainer; -import org.gpel.model.GpelProcess; -import org.xmlpull.infoset.XmlAttribute; -import org.xmlpull.infoset.XmlElement; -import org.xmlpull.infoset.XmlInfosetBuilder; -import org.xmlpull.infoset.XmlNamespace; - -import xsul5.XmlConstants; -import xsul5.wsdl.WsdlDefinitions; -import xsul5.wsdl.WsdlPort; -import xsul5.wsdl.WsdlPortType; -import xsul5.wsdl.WsdlService; - -public class ODEDeploymentDescriptor { - - /** - * NAME - */ - private static final String NAME = "name"; - /** - * PROCESS - */ - private static final String PROCESS = "process"; - - private static XmlInfosetBuilder builder = XmlConstants.BUILDER; - - public ODEDeploymentDescriptor() { - } - - public XmlElement generate(String workflowName, WsdlDefinitions workflowWSDL, GpelProcess gpelProcess, - Map<String, WsdlDefinitions> wsdls) throws GraphException { - - Iterator<WsdlService> services = workflowWSDL.services().iterator(); - WsdlService service = null; - if (services.hasNext()) { - service = services.next(); - } else { - throw new IllegalStateException("NO Service found in the workflow WSDL:" + workflowName); - } - - Iterator<WsdlPort> ports = service.ports().iterator(); - WsdlPort port = null; - if (ports.hasNext()) { - port = ports.next(); - } else { - throw new IllegalStateException("NO Port found in the workflow WSDL:" + workflowName); - } - String targetNamespace = gpelProcess.getTargetNamespace(); - String targetNamespacePrefix = "wfns"; - - XmlNamespace odeNs = builder.newNamespace("http://www.apache.org/ode/schemas/dd/2007/03"); - XmlElement deploy = builder.newFragment(odeNs, "deploy"); - deploy.declareNamespace(PROCESS, targetNamespace); - deploy.declareNamespace(targetNamespacePrefix, workflowWSDL.getTargetNamespace()); - - XmlElement process = deploy.addElement(odeNs, PROCESS); - process.setAttributeValue(NAME, PROCESS + ":" + workflowName); - // active - XmlElement active = process.addElement(odeNs, "active"); - active.addChild("true"); - - // provide - XmlElement provide = process.addElement(odeNs, "provide"); - provide.setAttributeValue("partnerLink", "workflowUserPartner"); - XmlElement providerService = provide.addElement(odeNs, "service"); - providerService.setAttributeValue("port", port.getName()); - providerService.setAttributeValue(NAME, targetNamespacePrefix + ":" + service.getName()); - - org.xmlpull.infoset.XmlElement wsdlXml = workflowWSDL.xml(); - Iterable<org.xmlpull.infoset.XmlElement> partnerLinkTypes = wsdlXml.elements(null, "partnerLinkType"); - - GpelPartnerLinksContainer partnerLinks = gpelProcess.getPartnerLinks(); - Iterable<GpelPartnerLink> partnerLinkList = partnerLinks.partnerLinks(); - - HashMap<String, String> newNamespaceMap = new HashMap<String, String>(); - - for (GpelPartnerLink link : partnerLinkList) { - String partnerRole = link.getPartnerRole(); - if (null != partnerRole) { - // These are the parrtner links that are non providers - XmlElement invoke = process.addElement(odeNs, "invoke"); - invoke.setAttributeValue("partnerLink", link.getName()); - - XmlElement invokeService = invoke.addElement(odeNs, "service"); - // invokeService.addAttribute("name", arg1) - QName partnerLinkTypeQName = link.getPartnerLinkTypeQName(); - Iterator<org.xmlpull.infoset.XmlElement> plIterator = partnerLinkTypes.iterator(); - while (plIterator.hasNext()) { - org.xmlpull.infoset.XmlElement plType = plIterator.next(); - XmlAttribute plTypeName = plType.attribute(NAME); - if (plTypeName.getValue().equals(partnerLinkTypeQName.getLocalPart())) { - // found the correct partnerlink type - // now find the porttype - - XmlAttribute plPortType = plType.element("role").attribute("portType"); - String portTypeQnameString = plPortType.getValue(); - String[] portTypeSegs = portTypeQnameString.split(":"); - Iterator<org.xmlpull.infoset.XmlNamespace> namespaceIterator = wsdlXml.namespaces().iterator(); - QName portTypeQname = null; - // find the qname of the porttype - while (namespaceIterator.hasNext()) { - org.xmlpull.infoset.XmlNamespace ns = (org.xmlpull.infoset.XmlNamespace) namespaceIterator - .next(); - if (ns.getPrefix().equals(portTypeSegs[0])) { - portTypeQname = new QName(ns.getName(), portTypeSegs[1]); - } - - } - - // now go through the WSDLS and find the one with the proper port type - Set<String> keys = wsdls.keySet(); - for (String key : keys) { - WsdlDefinitions wsdl = wsdls.get(key); - WsdlPortType portType = wsdl.getPortType(portTypeQname.getLocalPart()); - if (null != portType && portType.getQName().equals(portTypeQname)) { - // this is the right porttype so extract the service and you will be done - Iterator<WsdlService> svcIterator = wsdl.services().iterator(); - String nsPrefix = null; - if (svcIterator.hasNext()) { - WsdlService plService = svcIterator.next(); - if (null == newNamespaceMap.get(wsdl.getTargetNamespace())) { - nsPrefix = "p" + newNamespaceMap.size(); - newNamespaceMap.put(wsdl.getTargetNamespace(), nsPrefix); - } else { - nsPrefix = newNamespaceMap.get(wsdl.getTargetNamespace()); - } - - String portName = null; - Iterator<WsdlPort> portItr = plService.ports().iterator(); - if (portItr.hasNext()) { - portName = portItr.next().getName(); - } - invokeService.setAttributeValue(NAME, nsPrefix + ":" + plService.getName()); - invokeService.setAttributeValue("port", portName); - - } - } - } - } - } - - } - } - - Set<String> keys = newNamespaceMap.keySet(); - for (String key : keys) { - String nsPrefix = newNamespaceMap.get(key); - deploy.setAttributeValue("xmlns:" + nsPrefix, key); - } - return deploy; - } -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.workflow.model.ode; +// +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.Map; +//import java.util.Set; +// +//import javax.xml.namespace.QName; +// +//import org.apache.airavata.workflow.model.graph.GraphException; +//import org.gpel.model.GpelPartnerLink; +//import org.gpel.model.GpelPartnerLinksContainer; +//import org.gpel.model.GpelProcess; +//import org.xmlpull.infoset.XmlAttribute; +//import org.xmlpull.infoset.XmlElement; +//import org.xmlpull.infoset.XmlInfosetBuilder; +//import org.xmlpull.infoset.XmlNamespace; +// +//import xsul5.XmlConstants; +//import xsul5.wsdl.WsdlDefinitions; +//import xsul5.wsdl.WsdlPort; +//import xsul5.wsdl.WsdlPortType; +//import xsul5.wsdl.WsdlService; +// +//public class ODEDeploymentDescriptor { +// +// /** +// * NAME +// */ +// private static final String NAME = "name"; +// /** +// * PROCESS +// */ +// private static final String PROCESS = "process"; +// +// private static XmlInfosetBuilder builder = XmlConstants.BUILDER; +// +// public ODEDeploymentDescriptor() { +// } +// +// public XmlElement generate(String workflowName, WsdlDefinitions workflowWSDL, GpelProcess gpelProcess, +// Map<String, WsdlDefinitions> wsdls) throws GraphException { +// +// Iterator<WsdlService> services = workflowWSDL.services().iterator(); +// WsdlService service = null; +// if (services.hasNext()) { +// service = services.next(); +// } else { +// throw new IllegalStateException("NO Service found in the workflow WSDL:" + workflowName); +// } +// +// Iterator<WsdlPort> ports = service.ports().iterator(); +// WsdlPort port = null; +// if (ports.hasNext()) { +// port = ports.next(); +// } else { +// throw new IllegalStateException("NO Port found in the workflow WSDL:" + workflowName); +// } +// String targetNamespace = gpelProcess.getTargetNamespace(); +// String targetNamespacePrefix = "wfns"; +// +// XmlNamespace odeNs = builder.newNamespace("http://www.apache.org/ode/schemas/dd/2007/03"); +// XmlElement deploy = builder.newFragment(odeNs, "deploy"); +// deploy.declareNamespace(PROCESS, targetNamespace); +// deploy.declareNamespace(targetNamespacePrefix, workflowWSDL.getTargetNamespace()); +// +// XmlElement process = deploy.addElement(odeNs, PROCESS); +// process.setAttributeValue(NAME, PROCESS + ":" + workflowName); +// // active +// XmlElement active = process.addElement(odeNs, "active"); +// active.addChild("true"); +// +// // provide +// XmlElement provide = process.addElement(odeNs, "provide"); +// provide.setAttributeValue("partnerLink", "workflowUserPartner"); +// XmlElement providerService = provide.addElement(odeNs, "service"); +// providerService.setAttributeValue("port", port.getName()); +// providerService.setAttributeValue(NAME, targetNamespacePrefix + ":" + service.getName()); +// +// org.xmlpull.infoset.XmlElement wsdlXml = workflowWSDL.xml(); +// Iterable<org.xmlpull.infoset.XmlElement> partnerLinkTypes = wsdlXml.elements(null, "partnerLinkType"); +// +// GpelPartnerLinksContainer partnerLinks = gpelProcess.getPartnerLinks(); +// Iterable<GpelPartnerLink> partnerLinkList = partnerLinks.partnerLinks(); +// +// HashMap<String, String> newNamespaceMap = new HashMap<String, String>(); +// +// for (GpelPartnerLink link : partnerLinkList) { +// String partnerRole = link.getPartnerRole(); +// if (null != partnerRole) { +// // These are the parrtner links that are non providers +// XmlElement invoke = process.addElement(odeNs, "invoke"); +// invoke.setAttributeValue("partnerLink", link.getName()); +// +// XmlElement invokeService = invoke.addElement(odeNs, "service"); +// // invokeService.addAttribute("name", arg1) +// QName partnerLinkTypeQName = link.getPartnerLinkTypeQName(); +// Iterator<org.xmlpull.infoset.XmlElement> plIterator = partnerLinkTypes.iterator(); +// while (plIterator.hasNext()) { +// org.xmlpull.infoset.XmlElement plType = plIterator.next(); +// XmlAttribute plTypeName = plType.attribute(NAME); +// if (plTypeName.getValue().equals(partnerLinkTypeQName.getLocalPart())) { +// // found the correct partnerlink type +// // now find the porttype +// +// XmlAttribute plPortType = plType.element("role").attribute("portType"); +// String portTypeQnameString = plPortType.getValue(); +// String[] portTypeSegs = portTypeQnameString.split(":"); +// Iterator<org.xmlpull.infoset.XmlNamespace> namespaceIterator = wsdlXml.namespaces().iterator(); +// QName portTypeQname = null; +// // find the qname of the porttype +// while (namespaceIterator.hasNext()) { +// org.xmlpull.infoset.XmlNamespace ns = (org.xmlpull.infoset.XmlNamespace) namespaceIterator +// .next(); +// if (ns.getPrefix().equals(portTypeSegs[0])) { +// portTypeQname = new QName(ns.getName(), portTypeSegs[1]); +// } +// +// } +// +// // now go through the WSDLS and find the one with the proper port type +// Set<String> keys = wsdls.keySet(); +// for (String key : keys) { +// WsdlDefinitions wsdl = wsdls.get(key); +// WsdlPortType portType = wsdl.getPortType(portTypeQname.getLocalPart()); +// if (null != portType && portType.getQName().equals(portTypeQname)) { +// // this is the right porttype so extract the service and you will be done +// Iterator<WsdlService> svcIterator = wsdl.services().iterator(); +// String nsPrefix = null; +// if (svcIterator.hasNext()) { +// WsdlService plService = svcIterator.next(); +// if (null == newNamespaceMap.get(wsdl.getTargetNamespace())) { +// nsPrefix = "p" + newNamespaceMap.size(); +// newNamespaceMap.put(wsdl.getTargetNamespace(), nsPrefix); +// } else { +// nsPrefix = newNamespaceMap.get(wsdl.getTargetNamespace()); +// } +// +// String portName = null; +// Iterator<WsdlPort> portItr = plService.ports().iterator(); +// if (portItr.hasNext()) { +// portName = portItr.next().getName(); +// } +// invokeService.setAttributeValue(NAME, nsPrefix + ":" + plService.getName()); +// invokeService.setAttributeValue("port", portName); +// +// } +// } +// } +// } +// } +// +// } +// } +// +// Set<String> keys = newNamespaceMap.keySet(); +// for (String key : keys) { +// String nsPrefix = newNamespaceMap.get(key); +// deploy.setAttributeValue("xmlns:" + nsPrefix, key); +// } +// return deploy; +// } +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/9a6eaaae/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEWSDLTransformer.java ---------------------------------------------------------------------- diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEWSDLTransformer.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEWSDLTransformer.java index 5998950..7d6c75f 100644 --- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEWSDLTransformer.java +++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/ODEWSDLTransformer.java @@ -1,436 +1,436 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.workflow.model.ode; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Set; - -import javax.xml.namespace.QName; - -import org.apache.airavata.common.utils.StringUtil; -import org.apache.airavata.common.utils.WSDLUtil; -import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; -import org.apache.airavata.workflow.model.gpel.DSCUtil; -import org.apache.airavata.workflow.model.utils.WorkflowConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xmlpull.infoset.XmlBuilderException; -import org.xmlpull.infoset.XmlInfosetBuilder; -import org.xmlpull.infoset.XmlNamespace; - -import xsul5.wsdl.WsdlBinding; -import xsul5.wsdl.WsdlBindingOperation; -import xsul5.wsdl.WsdlDefinitions; -import xsul5.wsdl.WsdlMessage; -import xsul5.wsdl.WsdlMessagePart; -import xsul5.wsdl.WsdlPort; -import xsul5.wsdl.WsdlPortType; -import xsul5.wsdl.WsdlPortTypeOperation; -import xsul5.wsdl.WsdlService; - -public class ODEWSDLTransformer { - - private static final Logger log = LoggerFactory.getLogger(ODEWSDLTransformer.class); - /** - * SCHEMA_LOCATION_URI - */ - private static final String SCHEMA_LOCATION_URI = "lead-context.xsd"; - /** - * SCHEMA - */ - private static final String SCHEMA = "schema"; - /** - * IMPORT - */ - private static final String IMPORT = "import"; - /** - * NAMESPACE - */ - private static final String NAMESPACE = "namespace"; - /** - * SCHEMA_LOCATION - */ - private static final String SCHEMA_LOCATION = "schemaLocation"; - /** - * LEAD_CONTEXT_HEADER_NS - */ - private static final String LEAD_CONTEXT_HEADER_NS = "http://lead.extreme.indiana.edu/namespaces/2005/10/lead-context-header"; - /** - * LC - */ - private static final String LC = "lc"; - /** - * LC_CONTEXT - */ - private static final String LC_CONTEXT = "lc:context"; - /** - * ELEMENT - */ - private static final String ELEMENT = "element"; - /** - * BODY - */ - private static final String BODY = "body"; - /** - * MESSAGE - */ - private static final String MESSAGE = "message"; - /** - * HEADER - */ - private static final String HEADER = "header"; - /** - * LITERAL - */ - private static final String LITERAL = "literal"; - /** - * USE - */ - private static final String USE = "use"; - /** - * LEAD_HEADER - */ - private static final String LEAD_HEADER = "leadHeader"; - /** - * PART - */ - private static final String PART = "part"; - /** - * INPUT - */ - private static final String INPUT = "input"; - /** - * PARTS - */ - private static final String PARTS = "parts"; - /** - * BUILDER - */ - private static final XmlInfosetBuilder BUILDER = xsul5.XmlConstants.BUILDER; - - /** - * Constructs a ODEWSDLTransformer. - * - */ - public ODEWSDLTransformer() { - - } - - /** - * @param workflowName - * @param dscUrl - * @param workflowWsdl - * @param wsdls - */ - public void trasnformToODEWsdls(String workflowName, URI dscUrl, WsdlDefinitions workflowWsdl, - Map<String, WsdlDefinitions> wsdls) { - - addCrosscutImportsIfNecessary(workflowWsdl); - makeWorkflowWSDLConcrete(workflowWsdl, workflowName, dscUrl); - changePartnerLinkNS(workflowWsdl); - addImportsAndHeaderMessage(workflowWsdl); - transformServiceWsdls(wsdls, dscUrl); - - } - - /** - * This is a safe or idempotant Operation - * - * @param workflowWsdl - * @param workflowName - */ - public void makeWorkflowWSDLConcrete(WsdlDefinitions workflowWsdl, String workflowName, URI dscUrl) { - - addBindings(workflowWsdl, dscUrl); - setODEAddress(workflowWsdl, workflowName); - } - - private void changePartnerLinkNS(WsdlDefinitions workflowWsdl) { - org.xmlpull.infoset.XmlElement xml = workflowWsdl.xml(); - Iterator<XmlNamespace> itr = xml.namespaces().iterator(); - - LinkedList<XmlNamespace> namespaces = new LinkedList<XmlNamespace>(); - while (itr.hasNext()) { - XmlNamespace ns = itr.next(); - if (!"http://schemas.xmlsoap.org/ws/2004/03/partner-link/".equals(ns.getName())) { - namespaces.add(ns); - } - } - - xml.removeAllNamespaceDeclarations(); - - for (XmlNamespace xmlNamespace : namespaces) { - xml.declareNamespace(xmlNamespace); - } - - xml.setAttributeValue("xmlns:plnk", "http://docs.oasis-open.org/wsbpel/2.0/plnktype"); - - Iterator<org.xmlpull.infoset.XmlElement> plItr = xml.elements(null, "partnerLinkType").iterator(); - while (plItr.hasNext()) { - org.xmlpull.infoset.XmlElement xmlElement = plItr.next(); - XmlNamespace plinkNs = BUILDER.newNamespace("http://docs.oasis-open.org/wsbpel/2.0/plnktype"); - xmlElement.setNamespace(plinkNs); - Iterator childItr = xmlElement.children().iterator(); - while (childItr.hasNext()) { - Object object = (Object) childItr.next(); - if (object instanceof org.xmlpull.infoset.XmlElement) { - ((org.xmlpull.infoset.XmlElement) object).setNamespace(plinkNs); - } - } - } - } - - private void transformServiceWsdls(Map<String, WsdlDefinitions> wsdls, URI dscUrl) { - Set<String> keys = wsdls.keySet(); - - for (String string : keys) { - WsdlDefinitions wsdl = wsdls.get(string); - // Replacing the gfac xsd remote urls - // this was done because avoid network inaccisibilities - WSDLUtil.replaceAttributeValue(wsdl.getTypes(), "schemaLocation", - "http://www.extreme.indiana.edu/gfac/gfac-simple-types.xsd", "gfac-simple-types.xsd"); - addBindings(wsdl, dscUrl); - addImportsAndHeaderMessage(wsdl); - } - } - - private void setODEAddress(WsdlDefinitions workflowWsdl, String workflowName) { - Iterator<WsdlService> serviceItr = workflowWsdl.services().iterator(); - if (serviceItr.hasNext()) { - Iterator<WsdlPort> portItr = serviceItr.next().ports().iterator(); - if (portItr.hasNext()) { - org.xmlpull.infoset.XmlElement address = portItr.next().xml().element("address"); - if (!(WorkflowConstants.DEFAULT_ODE_URL + "/ode/processes/" + StringUtil - .convertToJavaIdentifier(workflowName)).equals(address.attributeValue("location"))) { - address.removeAllAttributes(); - address.setAttributeValue("location", WorkflowConstants.DEFAULT_ODE_URL + "/ode/processes/" - + StringUtil.convertToJavaIdentifier(workflowName)); - } - } - } - } - - /** - * @param wsdl - */ - private void addBindings(WsdlDefinitions wsdl, URI dscUrl) { - Iterator<WsdlBinding> itr = wsdl.bindings().iterator(); - int count = 0; - while (itr.hasNext()) { - itr.next(); - ++count; - } - if (0 == count) { - DSCUtil.convertToCWSDL(wsdl, dscUrl); - } - - } - - private void addImportsAndHeaderMessage(WsdlDefinitions wsdl) { - try { - - // Add the namespace to the lead context - - org.xmlpull.infoset.XmlElement types = wsdl.getTypes(); - // get the ns of schema from existing element - XmlNamespace schemaNs = BUILDER.newNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); - - addCrosscutImportsIfNecessary(wsdl); - - org.xmlpull.infoset.XmlElement schema = BUILDER.newFragment(schemaNs, SCHEMA); - types.addElement(0, schema); - - org.xmlpull.infoset.XmlElement importElement = BUILDER.newFragment(schema.getNamespace(), IMPORT); - importElement.setAttributeValue(NAMESPACE, LEAD_CONTEXT_HEADER_NS); - importElement.setAttributeValue(SCHEMA_LOCATION, SCHEMA_LOCATION_URI); - schema.addElement(0, importElement); - - wsdl.xml().declareNamespace(BUILDER.newNamespace(LC, LEAD_CONTEXT_HEADER_NS)); - - Iterator<WsdlPortType> iterator = wsdl.portTypes().iterator(); - while (iterator.hasNext()) { - WsdlPortType portType = iterator.next(); - Iterator<WsdlPortTypeOperation> operations = portType.operations().iterator(); - while (operations.hasNext()) { - WsdlPortTypeOperation operation = operations.next(); - WsdlMessagePart leadHeaderPart = new WsdlMessagePart(LEAD_HEADER); - leadHeaderPart.setName(LEAD_HEADER); - // we hand set this element to xml because when you use the - // API it doent add the namespace correctly - leadHeaderPart.xml().setAttributeValue(ELEMENT, LC_CONTEXT); - - wsdl.getMessage(operation.getInput().getMessage().getLocalPart()).addPart(leadHeaderPart); - } - } - - Iterator<WsdlBinding> bindingItr = wsdl.bindings().iterator(); - while (bindingItr.hasNext()) { - WsdlBinding wsdlBinding = (WsdlBinding) bindingItr.next(); - Iterator<WsdlBindingOperation> operationsItr = wsdlBinding.operations().iterator(); - while (operationsItr.hasNext()) { - WsdlBindingOperation wsdlBindingOperation = (WsdlBindingOperation) operationsItr.next(); - org.xmlpull.infoset.XmlElement input = wsdlBindingOperation.xml().element(INPUT); - org.xmlpull.infoset.XmlElement body = input.element(BODY); - if (body == null) { - // This is a HTTP binding so continue with the next - continue; - - } - - body.setAttributeValue(PARTS, INPUT); - XmlNamespace ns = body.getNamespace(); - - org.xmlpull.infoset.XmlElement header = input.newElement(ns, HEADER); - header.setAttributeValue(PART, LEAD_HEADER); - header.setAttributeValue(USE, LITERAL); - String inputMessage = findInputMessage(wsdlBindingOperation, wsdl); - header.setAttributeValue(MESSAGE, inputMessage); - body.removeAttribute(body.attribute(PARTS)); - String inputPartName = null; - - WsdlMessage wsdlMessage = wsdl.getMessage(findInputMessaQname(wsdlBindingOperation, wsdl) - .getLocalPart()); - Iterable<WsdlMessagePart> parts = wsdlMessage.parts(); - Iterator<WsdlMessagePart> partsItr = parts.iterator(); - while (partsItr.hasNext()) { - WsdlMessagePart wsdlMessagePart = (WsdlMessagePart) partsItr.next(); - if (!LEAD_HEADER.equals(wsdlMessagePart.getName())) { - inputPartName = wsdlMessagePart.getName(); - break; - } - } - - if (null == inputPartName) { - throw new WorkflowRuntimeException("Could not find a partname in message :" + inputMessage - + " for binding :" + wsdlBindingOperation); - } - - body.setAttributeValue(PARTS, inputPartName); - - input.addChild(header); - - } - } - } catch (XmlBuilderException e) { - log.error(e.getMessage(), e); - } - } - - /** - * - * @param wsdl - */ - private void addCrosscutImportsIfNecessary(WsdlDefinitions wsdl) { - org.xmlpull.infoset.XmlElement types = wsdl.getTypes(); - XmlNamespace schemaNs = BUILDER.newNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); - Iterable<org.xmlpull.infoset.XmlElement> schemas = types.elements(null, SCHEMA); - for (org.xmlpull.infoset.XmlElement schema : schemas) { - - if (WSDLUtil.attributeExist(schema, "type", "crosscutns:LeadCrosscutParameters")) { - // so its there now check whether the impport is already there - boolean found = false; - Iterable<org.xmlpull.infoset.XmlElement> imports = schema.elements(schemaNs, IMPORT); - for (org.xmlpull.infoset.XmlElement importElement : imports) { - found = found - || WSDLUtil.attributeExist(importElement, "namespace", - "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/"); - } - if (!found) { - org.xmlpull.infoset.XmlElement crosscutImport = BUILDER.newFragment(schemaNs, "import"); - crosscutImport.setAttributeValue("namespace", - "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/"); - crosscutImport.setAttributeValue("schemaLocation", "lead-crosscut-parameters.xsd"); - schema.addChild(0, crosscutImport); - } - } - - if (WSDLUtil.attributeExist(schema, "type", "globalTypens:LEADFileIDArrayType")) { - // so its there now check whether the impport is already there - boolean found = false; - Iterable<org.xmlpull.infoset.XmlElement> imports = schema.elements(schemaNs, IMPORT); - for (org.xmlpull.infoset.XmlElement importElement : imports) { - found = found - || WSDLUtil.attributeExist(importElement, "namespace", - "http://www.extreme.indiana.edu/lead/xsd"); - } - if (!found) { - org.xmlpull.infoset.XmlElement crosscutImport = BUILDER.newFragment(schemaNs, "import"); - crosscutImport.setAttributeValue("namespace", "http://www.extreme.indiana.edu/lead/xsd"); - crosscutImport.setAttributeValue("schemaLocation", "gfac-simple-types.xsd"); - schema.addChild(0, crosscutImport); - } - } - } - } - - /** - * @param wsdlBindingOperation - * @param wsdl - * @return - */ - private String findInputMessage(WsdlBindingOperation wsdlBindingOperation, WsdlDefinitions wsdl) { - - QName message = findInputMessaQname(wsdlBindingOperation, wsdl); - return message.getPrefix() + ":" + message.getLocalPart(); - } - - private QName findInputMessaQname(WsdlBindingOperation wsdlBindingOperation, WsdlDefinitions wsdl) { - String operationName = wsdlBindingOperation.getName(); - WsdlPortType portType = wsdl.getPortType(wsdlBindingOperation.getBinding().getPortType().getLocalPart()); - WsdlPortTypeOperation operation = portType.getOperation(operationName); - QName message = operation.getInput().getMessage(); - return message; - } - - public void setOdeLocation(String ODEEprEndingWithPort, String workflowName, WsdlDefinitions wsdl) { - Iterator<WsdlService> serviceItr = wsdl.services().iterator(); - if (serviceItr.hasNext()) { - WsdlService service = serviceItr.next(); - Iterator<WsdlPort> portItr = service.ports().iterator(); - if (portItr.hasNext()) { - WsdlPort port = portItr.next(); - org.xmlpull.infoset.XmlElement address = port.xml().element("address"); - if (address != null) { - URI uri = null; - try { - uri = new URI(ODEEprEndingWithPort + "/ode/processes/" - + StringUtil.convertToJavaIdentifier(workflowName)); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - address.setAttributeValue("location", uri.toString()); - } else { - throw new IllegalStateException("No address found in :" + wsdl.xmlStringPretty()); - } - } else { - throw new IllegalStateException("No port found in :" + wsdl.xmlStringPretty()); - } - } else { - throw new IllegalStateException("No service found in :" + wsdl.xmlStringPretty()); - } - } - -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.workflow.model.ode; +// +//import java.net.URI; +//import java.net.URISyntaxException; +//import java.util.Iterator; +//import java.util.LinkedList; +//import java.util.Map; +//import java.util.Set; +// +//import javax.xml.namespace.QName; +// +//import org.apache.airavata.common.utils.StringUtil; +//import org.apache.airavata.common.utils.WSDLUtil; +//import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException; +//import org.apache.airavata.workflow.model.gpel.DSCUtil; +//import org.apache.airavata.workflow.model.utils.WorkflowConstants; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +//import org.xmlpull.infoset.XmlBuilderException; +//import org.xmlpull.infoset.XmlInfosetBuilder; +//import org.xmlpull.infoset.XmlNamespace; +// +//import xsul5.wsdl.WsdlBinding; +//import xsul5.wsdl.WsdlBindingOperation; +//import xsul5.wsdl.WsdlDefinitions; +//import xsul5.wsdl.WsdlMessage; +//import xsul5.wsdl.WsdlMessagePart; +//import xsul5.wsdl.WsdlPort; +//import xsul5.wsdl.WsdlPortType; +//import xsul5.wsdl.WsdlPortTypeOperation; +//import xsul5.wsdl.WsdlService; +// +//public class ODEWSDLTransformer { +// +// private static final Logger log = LoggerFactory.getLogger(ODEWSDLTransformer.class); +// /** +// * SCHEMA_LOCATION_URI +// */ +// private static final String SCHEMA_LOCATION_URI = "lead-context.xsd"; +// /** +// * SCHEMA +// */ +// private static final String SCHEMA = "schema"; +// /** +// * IMPORT +// */ +// private static final String IMPORT = "import"; +// /** +// * NAMESPACE +// */ +// private static final String NAMESPACE = "namespace"; +// /** +// * SCHEMA_LOCATION +// */ +// private static final String SCHEMA_LOCATION = "schemaLocation"; +// /** +// * LEAD_CONTEXT_HEADER_NS +// */ +// private static final String LEAD_CONTEXT_HEADER_NS = "http://lead.extreme.indiana.edu/namespaces/2005/10/lead-context-header"; +// /** +// * LC +// */ +// private static final String LC = "lc"; +// /** +// * LC_CONTEXT +// */ +// private static final String LC_CONTEXT = "lc:context"; +// /** +// * ELEMENT +// */ +// private static final String ELEMENT = "element"; +// /** +// * BODY +// */ +// private static final String BODY = "body"; +// /** +// * MESSAGE +// */ +// private static final String MESSAGE = "message"; +// /** +// * HEADER +// */ +// private static final String HEADER = "header"; +// /** +// * LITERAL +// */ +// private static final String LITERAL = "literal"; +// /** +// * USE +// */ +// private static final String USE = "use"; +// /** +// * LEAD_HEADER +// */ +// private static final String LEAD_HEADER = "leadHeader"; +// /** +// * PART +// */ +// private static final String PART = "part"; +// /** +// * INPUT +// */ +// private static final String INPUT = "input"; +// /** +// * PARTS +// */ +// private static final String PARTS = "parts"; +// /** +// * BUILDER +// */ +// private static final XmlInfosetBuilder BUILDER = xsul5.XmlConstants.BUILDER; +// +// /** +// * Constructs a ODEWSDLTransformer. +// * +// */ +// public ODEWSDLTransformer() { +// +// } +// +// /** +// * @param workflowName +// * @param dscUrl +// * @param workflowWsdl +// * @param wsdls +// */ +// public void trasnformToODEWsdls(String workflowName, URI dscUrl, WsdlDefinitions workflowWsdl, +// Map<String, WsdlDefinitions> wsdls) { +// +// addCrosscutImportsIfNecessary(workflowWsdl); +// makeWorkflowWSDLConcrete(workflowWsdl, workflowName, dscUrl); +// changePartnerLinkNS(workflowWsdl); +// addImportsAndHeaderMessage(workflowWsdl); +// transformServiceWsdls(wsdls, dscUrl); +// +// } +// +// /** +// * This is a safe or idempotant Operation +// * +// * @param workflowWsdl +// * @param workflowName +// */ +// public void makeWorkflowWSDLConcrete(WsdlDefinitions workflowWsdl, String workflowName, URI dscUrl) { +// +// addBindings(workflowWsdl, dscUrl); +// setODEAddress(workflowWsdl, workflowName); +// } +// +// private void changePartnerLinkNS(WsdlDefinitions workflowWsdl) { +// org.xmlpull.infoset.XmlElement xml = workflowWsdl.xml(); +// Iterator<XmlNamespace> itr = xml.namespaces().iterator(); +// +// LinkedList<XmlNamespace> namespaces = new LinkedList<XmlNamespace>(); +// while (itr.hasNext()) { +// XmlNamespace ns = itr.next(); +// if (!"http://schemas.xmlsoap.org/ws/2004/03/partner-link/".equals(ns.getName())) { +// namespaces.add(ns); +// } +// } +// +// xml.removeAllNamespaceDeclarations(); +// +// for (XmlNamespace xmlNamespace : namespaces) { +// xml.declareNamespace(xmlNamespace); +// } +// +// xml.setAttributeValue("xmlns:plnk", "http://docs.oasis-open.org/wsbpel/2.0/plnktype"); +// +// Iterator<org.xmlpull.infoset.XmlElement> plItr = xml.elements(null, "partnerLinkType").iterator(); +// while (plItr.hasNext()) { +// org.xmlpull.infoset.XmlElement xmlElement = plItr.next(); +// XmlNamespace plinkNs = BUILDER.newNamespace("http://docs.oasis-open.org/wsbpel/2.0/plnktype"); +// xmlElement.setNamespace(plinkNs); +// Iterator childItr = xmlElement.children().iterator(); +// while (childItr.hasNext()) { +// Object object = (Object) childItr.next(); +// if (object instanceof org.xmlpull.infoset.XmlElement) { +// ((org.xmlpull.infoset.XmlElement) object).setNamespace(plinkNs); +// } +// } +// } +// } +// +// private void transformServiceWsdls(Map<String, WsdlDefinitions> wsdls, URI dscUrl) { +// Set<String> keys = wsdls.keySet(); +// +// for (String string : keys) { +// WsdlDefinitions wsdl = wsdls.get(string); +// // Replacing the gfac xsd remote urls +// // this was done because avoid network inaccisibilities +// WSDLUtil.replaceAttributeValue(wsdl.getTypes(), "schemaLocation", +// "http://www.extreme.indiana.edu/gfac/gfac-simple-types.xsd", "gfac-simple-types.xsd"); +// addBindings(wsdl, dscUrl); +// addImportsAndHeaderMessage(wsdl); +// } +// } +// +// private void setODEAddress(WsdlDefinitions workflowWsdl, String workflowName) { +// Iterator<WsdlService> serviceItr = workflowWsdl.services().iterator(); +// if (serviceItr.hasNext()) { +// Iterator<WsdlPort> portItr = serviceItr.next().ports().iterator(); +// if (portItr.hasNext()) { +// org.xmlpull.infoset.XmlElement address = portItr.next().xml().element("address"); +// if (!(WorkflowConstants.DEFAULT_ODE_URL + "/ode/processes/" + StringUtil +// .convertToJavaIdentifier(workflowName)).equals(address.attributeValue("location"))) { +// address.removeAllAttributes(); +// address.setAttributeValue("location", WorkflowConstants.DEFAULT_ODE_URL + "/ode/processes/" +// + StringUtil.convertToJavaIdentifier(workflowName)); +// } +// } +// } +// } +// +// /** +// * @param wsdl +// */ +// private void addBindings(WsdlDefinitions wsdl, URI dscUrl) { +// Iterator<WsdlBinding> itr = wsdl.bindings().iterator(); +// int count = 0; +// while (itr.hasNext()) { +// itr.next(); +// ++count; +// } +// if (0 == count) { +// DSCUtil.convertToCWSDL(wsdl, dscUrl); +// } +// +// } +// +// private void addImportsAndHeaderMessage(WsdlDefinitions wsdl) { +// try { +// +// // Add the namespace to the lead context +// +// org.xmlpull.infoset.XmlElement types = wsdl.getTypes(); +// // get the ns of schema from existing element +// XmlNamespace schemaNs = BUILDER.newNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); +// +// addCrosscutImportsIfNecessary(wsdl); +// +// org.xmlpull.infoset.XmlElement schema = BUILDER.newFragment(schemaNs, SCHEMA); +// types.addElement(0, schema); +// +// org.xmlpull.infoset.XmlElement importElement = BUILDER.newFragment(schema.getNamespace(), IMPORT); +// importElement.setAttributeValue(NAMESPACE, LEAD_CONTEXT_HEADER_NS); +// importElement.setAttributeValue(SCHEMA_LOCATION, SCHEMA_LOCATION_URI); +// schema.addElement(0, importElement); +// +// wsdl.xml().declareNamespace(BUILDER.newNamespace(LC, LEAD_CONTEXT_HEADER_NS)); +// +// Iterator<WsdlPortType> iterator = wsdl.portTypes().iterator(); +// while (iterator.hasNext()) { +// WsdlPortType portType = iterator.next(); +// Iterator<WsdlPortTypeOperation> operations = portType.operations().iterator(); +// while (operations.hasNext()) { +// WsdlPortTypeOperation operation = operations.next(); +// WsdlMessagePart leadHeaderPart = new WsdlMessagePart(LEAD_HEADER); +// leadHeaderPart.setName(LEAD_HEADER); +// // we hand set this element to xml because when you use the +// // API it doent add the namespace correctly +// leadHeaderPart.xml().setAttributeValue(ELEMENT, LC_CONTEXT); +// +// wsdl.getMessage(operation.getInput().getMessage().getLocalPart()).addPart(leadHeaderPart); +// } +// } +// +// Iterator<WsdlBinding> bindingItr = wsdl.bindings().iterator(); +// while (bindingItr.hasNext()) { +// WsdlBinding wsdlBinding = (WsdlBinding) bindingItr.next(); +// Iterator<WsdlBindingOperation> operationsItr = wsdlBinding.operations().iterator(); +// while (operationsItr.hasNext()) { +// WsdlBindingOperation wsdlBindingOperation = (WsdlBindingOperation) operationsItr.next(); +// org.xmlpull.infoset.XmlElement input = wsdlBindingOperation.xml().element(INPUT); +// org.xmlpull.infoset.XmlElement body = input.element(BODY); +// if (body == null) { +// // This is a HTTP binding so continue with the next +// continue; +// +// } +// +// body.setAttributeValue(PARTS, INPUT); +// XmlNamespace ns = body.getNamespace(); +// +// org.xmlpull.infoset.XmlElement header = input.newElement(ns, HEADER); +// header.setAttributeValue(PART, LEAD_HEADER); +// header.setAttributeValue(USE, LITERAL); +// String inputMessage = findInputMessage(wsdlBindingOperation, wsdl); +// header.setAttributeValue(MESSAGE, inputMessage); +// body.removeAttribute(body.attribute(PARTS)); +// String inputPartName = null; +// +// WsdlMessage wsdlMessage = wsdl.getMessage(findInputMessaQname(wsdlBindingOperation, wsdl) +// .getLocalPart()); +// Iterable<WsdlMessagePart> parts = wsdlMessage.parts(); +// Iterator<WsdlMessagePart> partsItr = parts.iterator(); +// while (partsItr.hasNext()) { +// WsdlMessagePart wsdlMessagePart = (WsdlMessagePart) partsItr.next(); +// if (!LEAD_HEADER.equals(wsdlMessagePart.getName())) { +// inputPartName = wsdlMessagePart.getName(); +// break; +// } +// } +// +// if (null == inputPartName) { +// throw new WorkflowRuntimeException("Could not find a partname in message :" + inputMessage +// + " for binding :" + wsdlBindingOperation); +// } +// +// body.setAttributeValue(PARTS, inputPartName); +// +// input.addChild(header); +// +// } +// } +// } catch (XmlBuilderException e) { +// log.error(e.getMessage(), e); +// } +// } +// +// /** +// * +// * @param wsdl +// */ +// private void addCrosscutImportsIfNecessary(WsdlDefinitions wsdl) { +// org.xmlpull.infoset.XmlElement types = wsdl.getTypes(); +// XmlNamespace schemaNs = BUILDER.newNamespace("xsd", "http://www.w3.org/2001/XMLSchema"); +// Iterable<org.xmlpull.infoset.XmlElement> schemas = types.elements(null, SCHEMA); +// for (org.xmlpull.infoset.XmlElement schema : schemas) { +// +// if (WSDLUtil.attributeExist(schema, "type", "crosscutns:LeadCrosscutParameters")) { +// // so its there now check whether the impport is already there +// boolean found = false; +// Iterable<org.xmlpull.infoset.XmlElement> imports = schema.elements(schemaNs, IMPORT); +// for (org.xmlpull.infoset.XmlElement importElement : imports) { +// found = found +// || WSDLUtil.attributeExist(importElement, "namespace", +// "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/"); +// } +// if (!found) { +// org.xmlpull.infoset.XmlElement crosscutImport = BUILDER.newFragment(schemaNs, "import"); +// crosscutImport.setAttributeValue("namespace", +// "http://lead.extreme.indiana.edu/namespaces/2006/lead-crosscut-parameters/"); +// crosscutImport.setAttributeValue("schemaLocation", "lead-crosscut-parameters.xsd"); +// schema.addChild(0, crosscutImport); +// } +// } +// +// if (WSDLUtil.attributeExist(schema, "type", "globalTypens:LEADFileIDArrayType")) { +// // so its there now check whether the impport is already there +// boolean found = false; +// Iterable<org.xmlpull.infoset.XmlElement> imports = schema.elements(schemaNs, IMPORT); +// for (org.xmlpull.infoset.XmlElement importElement : imports) { +// found = found +// || WSDLUtil.attributeExist(importElement, "namespace", +// "http://www.extreme.indiana.edu/lead/xsd"); +// } +// if (!found) { +// org.xmlpull.infoset.XmlElement crosscutImport = BUILDER.newFragment(schemaNs, "import"); +// crosscutImport.setAttributeValue("namespace", "http://www.extreme.indiana.edu/lead/xsd"); +// crosscutImport.setAttributeValue("schemaLocation", "gfac-simple-types.xsd"); +// schema.addChild(0, crosscutImport); +// } +// } +// } +// } +// +// /** +// * @param wsdlBindingOperation +// * @param wsdl +// * @return +// */ +// private String findInputMessage(WsdlBindingOperation wsdlBindingOperation, WsdlDefinitions wsdl) { +// +// QName message = findInputMessaQname(wsdlBindingOperation, wsdl); +// return message.getPrefix() + ":" + message.getLocalPart(); +// } +// +// private QName findInputMessaQname(WsdlBindingOperation wsdlBindingOperation, WsdlDefinitions wsdl) { +// String operationName = wsdlBindingOperation.getName(); +// WsdlPortType portType = wsdl.getPortType(wsdlBindingOperation.getBinding().getPortType().getLocalPart()); +// WsdlPortTypeOperation operation = portType.getOperation(operationName); +// QName message = operation.getInput().getMessage(); +// return message; +// } +// +// public void setOdeLocation(String ODEEprEndingWithPort, String workflowName, WsdlDefinitions wsdl) { +// Iterator<WsdlService> serviceItr = wsdl.services().iterator(); +// if (serviceItr.hasNext()) { +// WsdlService service = serviceItr.next(); +// Iterator<WsdlPort> portItr = service.ports().iterator(); +// if (portItr.hasNext()) { +// WsdlPort port = portItr.next(); +// org.xmlpull.infoset.XmlElement address = port.xml().element("address"); +// if (address != null) { +// URI uri = null; +// try { +// uri = new URI(ODEEprEndingWithPort + "/ode/processes/" +// + StringUtil.convertToJavaIdentifier(workflowName)); +// } catch (URISyntaxException e) { +// throw new RuntimeException(e); +// } +// address.setAttributeValue("location", uri.toString()); +// } else { +// throw new IllegalStateException("No address found in :" + wsdl.xmlStringPretty()); +// } +// } else { +// throw new IllegalStateException("No port found in :" + wsdl.xmlStringPretty()); +// } +// } else { +// throw new IllegalStateException("No service found in :" + wsdl.xmlStringPretty()); +// } +// } +// +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/9a6eaaae/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/WSDLCleaner.java ---------------------------------------------------------------------- diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/WSDLCleaner.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/WSDLCleaner.java index 7a70049..068fcb0 100644 --- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/WSDLCleaner.java +++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/ode/WSDLCleaner.java @@ -1,98 +1,98 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.airavata.workflow.model.ode; - -import java.util.ArrayList; - -import org.xmlpull.infoset.XmlAttribute; -import org.xmlpull.infoset.XmlElement; - -import xsul5.wsdl.WsdlBinding; -import xsul5.wsdl.WsdlDefinitions; -import xsul5.wsdl.WsdlPort; -import xsul5.wsdl.WsdlService; - -/** - * ODE does not work well with the wsdls with SOAP 1.2 binding and HTTP bindings that are generated by wsdls generated - * by Axis2. This class is intended to remove the extra bindings and the extra ports. - * - */ -public class WSDLCleaner { - - public static void cleanWSDL(WsdlDefinitions definition) { - WsdlDefinitions wsdl = definition; - Iterable<WsdlBinding> bindings = wsdl.bindings(); - ArrayList<WsdlBinding> removedBindings = new ArrayList<WsdlBinding>(); - for (WsdlBinding wsdlBinding : bindings) { - XmlElement innerBinding = wsdlBinding.xml().element("binding"); - if (null != innerBinding - && !"http://schemas.xmlsoap.org/wsdl/soap/".equals(innerBinding.getNamespace().getName())) { - - removedBindings.add(wsdlBinding); - } - } - // to mitigate the Concurrent modifications this is done separately - for (WsdlBinding wsdlBinding : removedBindings) { - wsdl.xml().removeElement(wsdlBinding.xml()); - } - - ArrayList<WsdlPort> removePorts = new ArrayList<WsdlPort>(); - Iterable<WsdlService> services = wsdl.services(); - for (WsdlService wsdlService : services) { - Iterable<WsdlPort> ports = wsdlService.ports(); - for (WsdlPort wsdlPort : ports) { - for (WsdlBinding removedBinding : removedBindings) { - if (removedBinding.getName().equals(wsdlPort.getBinding().getLocalPart())) { - removePorts.add(wsdlPort); - break; - } - } - } - for (WsdlPort wsdlPort : removePorts) { - wsdlService.xml().removeElement(wsdlPort.xml()); - } - removePorts.clear(); - } - - // remove attributeFormDefault and elementFormDefault - Iterable<XmlElement> schemas = wsdl.getTypes().elements(null, "schema"); - for (XmlElement schema : schemas) { - XmlAttribute attributeFormDefault = schema.attribute("attributeFormDefault"); - schema.removeAttribute(attributeFormDefault); - - XmlAttribute elementFormDefault = schema.attribute("elementFormDefault"); - schema.removeAttribute(elementFormDefault); - } - } - - // - // public void addUniqueMessageNameIfNecessary(WsdlDefinitions definition){ - // - // - // Iterable<WsdlMessage> messages = definition.messages(); - // for (WsdlMessage wsdlMessage : messages) { - // String msgName = wsdlMessage.getName(); - // WSDLUtil.replaceAttributeValue(element, name, oldValue, newValue) - // } - // } - -} \ No newline at end of file +///* +// * +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// * +// */ +// +//package org.apache.airavata.workflow.model.ode; +// +//import java.util.ArrayList; +// +//import org.xmlpull.infoset.XmlAttribute; +//import org.xmlpull.infoset.XmlElement; +// +//import xsul5.wsdl.WsdlBinding; +//import xsul5.wsdl.WsdlDefinitions; +//import xsul5.wsdl.WsdlPort; +//import xsul5.wsdl.WsdlService; +// +///** +// * ODE does not work well with the wsdls with SOAP 1.2 binding and HTTP bindings that are generated by wsdls generated +// * by Axis2. This class is intended to remove the extra bindings and the extra ports. +// * +// */ +//public class WSDLCleaner { +// +// public static void cleanWSDL(WsdlDefinitions definition) { +// WsdlDefinitions wsdl = definition; +// Iterable<WsdlBinding> bindings = wsdl.bindings(); +// ArrayList<WsdlBinding> removedBindings = new ArrayList<WsdlBinding>(); +// for (WsdlBinding wsdlBinding : bindings) { +// XmlElement innerBinding = wsdlBinding.xml().element("binding"); +// if (null != innerBinding +// && !"http://schemas.xmlsoap.org/wsdl/soap/".equals(innerBinding.getNamespace().getName())) { +// +// removedBindings.add(wsdlBinding); +// } +// } +// // to mitigate the Concurrent modifications this is done separately +// for (WsdlBinding wsdlBinding : removedBindings) { +// wsdl.xml().removeElement(wsdlBinding.xml()); +// } +// +// ArrayList<WsdlPort> removePorts = new ArrayList<WsdlPort>(); +// Iterable<WsdlService> services = wsdl.services(); +// for (WsdlService wsdlService : services) { +// Iterable<WsdlPort> ports = wsdlService.ports(); +// for (WsdlPort wsdlPort : ports) { +// for (WsdlBinding removedBinding : removedBindings) { +// if (removedBinding.getName().equals(wsdlPort.getBinding().getLocalPart())) { +// removePorts.add(wsdlPort); +// break; +// } +// } +// } +// for (WsdlPort wsdlPort : removePorts) { +// wsdlService.xml().removeElement(wsdlPort.xml()); +// } +// removePorts.clear(); +// } +// +// // remove attributeFormDefault and elementFormDefault +// Iterable<XmlElement> schemas = wsdl.getTypes().elements(null, "schema"); +// for (XmlElement schema : schemas) { +// XmlAttribute attributeFormDefault = schema.attribute("attributeFormDefault"); +// schema.removeAttribute(attributeFormDefault); +// +// XmlAttribute elementFormDefault = schema.attribute("elementFormDefault"); +// schema.removeAttribute(elementFormDefault); +// } +// } +// +// // +// // public void addUniqueMessageNameIfNecessary(WsdlDefinitions definition){ +// // +// // +// // Iterable<WsdlMessage> messages = definition.messages(); +// // for (WsdlMessage wsdlMessage : messages) { +// // String msgName = wsdlMessage.getName(); +// // WSDLUtil.replaceAttributeValue(element, name, oldValue, newValue) +// // } +// // } +// +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/airavata/blob/9a6eaaae/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java ---------------------------------------------------------------------- diff --git a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java index dccd17d..51e1f11 100644 --- a/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java +++ b/modules/workflow-model/workflow-model-core/src/main/java/org/apache/airavata/workflow/model/wf/TridentTransformer.java @@ -29,33 +29,33 @@ import org.apache.airavata.workflow.model.xsd.LeadContextHeaderXSD; import org.apache.airavata.workflow.model.xsd.LeadCrosscutXSD; import org.xmlpull.infoset.XmlElement; -import xsul5.wsdl.WsdlDefinitions; +//import xsul5.wsdl.WsdlDefinitions; public class TridentTransformer { - public void process(WsdlDefinitions wsdl) { - XmlElement types = wsdl.getTypes(); - Iterable<XmlElement> schemas = types.elements(null, "schema"); - LinkedList<XmlElement> removeList = new LinkedList<XmlElement>(); - for (XmlElement schema : schemas) { - String tns = schema.attributeValue("targetNamespace"); - if (null != tns && -1 != tns.indexOf("http://www.extreme.indiana.edu/xbaya")) { - } else { - removeList.add(schema); - } - } - for (XmlElement schema : removeList) { - types.removeChild(schema); - } - - types.addChild(XMLUtil.stringToXmlElement(GFacSimpleTypesXSD.XSD)); - types.addChild(XMLUtil.stringToXmlElement(LeadCrosscutXSD.XSD)); - types.addChild(XMLUtil.stringToXmlElement(LeadContextHeaderXSD.XSD)); - - XmlElement xml = wsdl.xml(); - XMLUtil.removeElements(xml, "partnerLinkType"); - XMLUtil.removeElements(xml, "default"); - - } +// public void process(WsdlDefinitions wsdl) { +// XmlElement types = wsdl.getTypes(); +// Iterable<XmlElement> schemas = types.elements(null, "schema"); +// LinkedList<XmlElement> removeList = new LinkedList<XmlElement>(); +// for (XmlElement schema : schemas) { +// String tns = schema.attributeValue("targetNamespace"); +// if (null != tns && -1 != tns.indexOf("http://www.extreme.indiana.edu/xbaya")) { +// } else { +// removeList.add(schema); +// } +// } +// for (XmlElement schema : removeList) { +// types.removeChild(schema); +// } +// +// types.addChild(XMLUtil.stringToXmlElement(GFacSimpleTypesXSD.XSD)); +// types.addChild(XMLUtil.stringToXmlElement(LeadCrosscutXSD.XSD)); +// types.addChild(XMLUtil.stringToXmlElement(LeadContextHeaderXSD.XSD)); +// +// XmlElement xml = wsdl.xml(); +// XMLUtil.removeElements(xml, "partnerLinkType"); +// XMLUtil.removeElements(xml, "default"); +// +// } } \ No newline at end of file
