You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/08/17 08:35:53 UTC

svn commit: r686587 - in /tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml: BPELDocumentProcessor.java BPELImplementationProcessor.java

Author: jsdelfino
Date: Sat Aug 16 23:35:52 2008
New Revision: 686587

URL: http://svn.apache.org/viewvc?rev=686587&view=rev
Log:
Fixed a number of NPEs when a contribution contains multiple WSDLs in a namespace used by a BPEL process.

Modified:
    tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
    tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java

Modified: tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java?rev=686587&r1=686586&r2=686587&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java Sat Aug 16 23:35:52 2008
@@ -70,6 +70,7 @@
     private static final String SCA_BPEL_NS = "http://docs.oasis-open.org/ns/opencsa/sca-bpel/200801";
     private static final String BPEL_NS = "http://schemas.xmlsoap.org/ws/2004/03/business-process/";
     private static final String BPEL_PLINK_NS = "http://schemas.xmlsoap.org/ws/2004/03/partner-link/";
+    private static final String WSDL_NS = "http://schemas.xmlsoap.org/wsdl/";
     private static final QName PROCESS_ELEMENT = new QName(BPEL_NS, "process");
     private static final QName PARTNERLINK_ELEMENT = new QName(BPEL_NS, "partnerLink");
     private static final QName ONEVENT_ELEMENT = new QName(BPEL_NS, "onEvent");
@@ -137,22 +138,22 @@
         for (BPELImportElement theImport : theImports) {
 
             // Deal with WSDL imports
-            if (theImport.getImportType().equals("http://schemas.xmlsoap.org/wsdl/")) {
-                String WSDLLocation = theImport.getLocation();
-                String WSDLNamespace = theImport.getNamespace();
+            if (theImport.getImportType().equals(WSDL_NS)) {
+                String wsdlLocation = theImport.getLocation();
+                String wsdlNamespace = theImport.getNamespace();
 
                 // Resolve the WSDL definition
                 WSDLDefinition proxy = WSDLfactory.createWSDLDefinition();
                 proxy.setUnresolved(true);
-                proxy.setNamespace(WSDLNamespace);
-                if (WSDLLocation != null) {
-                    proxy.setLocation(URI.create(WSDLLocation));
+                proxy.setNamespace(wsdlNamespace);
+                if (wsdlLocation != null) {
+                    proxy.setLocation(URI.create(wsdlLocation));
                 }
                 WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, proxy);
                 if (resolved != null && !resolved.isUnresolved()) {
                     theImport.setWSDLDefinition(resolved);
                 } else {
-                    error("CannotResolveWSDLReference", resolver, WSDLLocation, WSDLNamespace);
+                    error("CannotResolveWSDLReference", resolver, wsdlLocation, wsdlNamespace);
                     return;
                 } // end if
             } // end if
@@ -193,48 +194,57 @@
         // We must find the partner link type elements from amongst the imported
         // WSDLs
         for (BPELImportElement theImport : theImports) {
-            WSDLDefinition theWSDL = theImport.getWSDLDefinition();
-            Definition WSDLDefinition = theWSDL.getDefinition();
+            if (theImport.getImportType().equals(WSDL_NS)) {
 
-            // The BPEL partnerLinkType elements are extension elements within
-            // the WSDL
-            List<ExtensibilityElement> extensibilityElements = WSDLDefinition.getExtensibilityElements();
-
-            for (ExtensibilityElement theElement : extensibilityElements) {
-                QName elementType = theElement.getElementType();
-                if (elementType.equals(LINKTYPE_ELEMENT)) {
-                    BPELPartnerLinkTypeExt pLinkExt = (BPELPartnerLinkTypeExt)theElement;
-                    // Fetch the name of the partnerLinkType
-                    String name = pLinkExt.getName();
-                    QName qName = new QName(WSDLDefinition.getTargetNamespace(), name);
-                    BPELPartnerLinkTypeElement pLinkElement = new BPELPartnerLinkTypeElement(qName);
-
-                    // The partnerLinkType must have one and may have 2 role
-                    // child elements
-                    int count = 0;
-                    for (int i = 0; i < 2; i++) {
-                        if (pLinkExt.getRoleName(i) == null)
-                            continue;
-                        PortType pType = WSDLDefinition.getPortType(pLinkExt.getRolePortType(i));
-                        if (count == 0) {
-                            pLinkElement.setRole1(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
-                            count++;
-                        } else if (count == 1) {
-                            pLinkElement.setRole2(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
-                            count++;
-                        } else {
-                            break;
-                        } // end if
-                    } // end for
+                // Find all the WSDL definitions matching the imported namespace
+                List<Definition> wsdlDefinitions = new ArrayList<Definition>();
+                WSDLDefinition theWSDL = theImport.getWSDLDefinition();
+                wsdlDefinitions.add(theWSDL.getDefinition());
+                for (WSDLDefinition importedWSDL: theWSDL.getImportedDefinitions()) {
+                    wsdlDefinitions.add(importedWSDL.getDefinition());
+                }
 
-                    if (count == 0) {
-                        error("PartnerLinkTypeNoRoles", theElement, pLinkElement.getName());
-                        throw new ContributionResolveException("partnerLinkType " + pLinkElement.getName() + " has no Roles defined");
-                    } else
-                        thePLinks.add(pLinkElement);
-                } // end if
+                // The BPEL partnerLinkType elements are extension elements within
+                // the WSDL definitions
+                for (Definition wsdlDefinition: wsdlDefinitions) {
+                    for (ExtensibilityElement theElement : (List<ExtensibilityElement>)wsdlDefinition.getExtensibilityElements()) {
+                        QName elementType = theElement.getElementType();
+                        if (elementType.equals(LINKTYPE_ELEMENT)) {
+                            BPELPartnerLinkTypeExt pLinkExt = (BPELPartnerLinkTypeExt)theElement;
+                            
+                            // Fetch the name of the partnerLinkType
+                            String name = pLinkExt.getName();
+                            QName qName = new QName(wsdlDefinition.getTargetNamespace(), name);
+                            BPELPartnerLinkTypeElement pLinkElement = new BPELPartnerLinkTypeElement(qName);
+
+                            // The partnerLinkType must have one and may have 2 role
+                            // child elements
+                            int count = 0;
+                            for (int i = 0; i < 2; i++) {
+                                if (pLinkExt.getRoleName(i) == null)
+                                    continue;
+                                PortType pType = wsdlDefinition.getPortType(pLinkExt.getRolePortType(i));
+                                if (count == 0) {
+                                    pLinkElement.setRole1(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
+                                    count++;
+                                } else if (count == 1) {
+                                    pLinkElement.setRole2(pLinkExt.getRoleName(i), pLinkExt.getRolePortType(i), pType);
+                                    count++;
+                                } else {
+                                    break;
+                                } // end if
+                            } // end for
+
+                            if (count == 0) {
+                                error("PartnerLinkTypeNoRoles", theElement, pLinkElement.getName());
+                                throw new ContributionResolveException("partnerLinkType " + pLinkElement.getName() + " has no Roles defined");
+                            } else
+                                thePLinks.add(pLinkElement);
+                        } // end if
 
-            } // end for
+                    } // end for
+                }
+            }
         } // end for
         return thePLinks;
     } // end getPartnerLinkTypes
@@ -253,35 +263,42 @@
 
         Collection<PortType> thePortTypes = (Collection<PortType>)new ArrayList<PortType>();
         for (BPELImportElement theImport : theImports) {
-            WSDLDefinition theWSDL = theImport.getWSDLDefinition();
-            Definition wsdlDefinition = theWSDL.getDefinition();
-
-            Collection<PortType> portTypes = (Collection<PortType>)wsdlDefinition.getPortTypes().values();
-            thePortTypes.addAll(portTypes);
-
-            // Create WSDLInterface elements for each PortType found
-            for (PortType portType : portTypes) {
-                WSDLObject<PortType> wsdlPortType = theWSDL.getWSDLObject(PortType.class, portType.getQName());
-                WSDLInterface wsdlInterface;
-                if (wsdlPortType != null) {
-                    // Introspect the WSDL portType and add the resulting
-                    // WSDLInterface to the resolver
-                    try {
-                        theWSDL.setDefinition(wsdlPortType.getDefinition());
-                        wsdlInterface = WSDLfactory.createWSDLInterface(wsdlPortType.getElement(), theWSDL, resolver);
-                        wsdlInterface.setWsdlDefinition(theWSDL);
-                    } catch (InvalidInterfaceException e) {
-                        ContributionResolveException ce = new ContributionResolveException(e);
-                        error("ContributionResolveException", resolver, ce);
-                        throw ce;
-                    } // end try
-                    resolver.addModel(wsdlInterface);
-                    theInterfaces.add(wsdlInterface);
-                } // end if
-            } // end for
+            if (theImport.getImportType().equals(WSDL_NS)) {
+                
+                // Find all the WSDL definitions matching the imported namespace
+                List<Definition> wsdlDefinitions = new ArrayList<Definition>();
+                WSDLDefinition theWSDL = theImport.getWSDLDefinition();
+                wsdlDefinitions.add(theWSDL.getDefinition());
+                for (WSDLDefinition importedWSDL: theWSDL.getImportedDefinitions()) {
+                    wsdlDefinitions.add(importedWSDL.getDefinition());
+                }
+                for (Definition wsdlDefinition: wsdlDefinitions) {
 
-            // -----------------------
+                    Collection<PortType> portTypes = (Collection<PortType>)wsdlDefinition.getPortTypes().values();
+                    thePortTypes.addAll(portTypes);
 
+                    // Create WSDLInterface elements for each PortType found
+                    for (PortType portType : portTypes) {
+                        WSDLObject<PortType> wsdlPortType = theWSDL.getWSDLObject(PortType.class, portType.getQName());
+                        WSDLInterface wsdlInterface;
+                        if (wsdlPortType != null) {
+                            // Introspect the WSDL portType and add the resulting
+                            // WSDLInterface to the resolver
+                            try {
+                                theWSDL.setDefinition(wsdlPortType.getDefinition());
+                                wsdlInterface = WSDLfactory.createWSDLInterface(wsdlPortType.getElement(), theWSDL, resolver);
+                                wsdlInterface.setWsdlDefinition(theWSDL);
+                            } catch (InvalidInterfaceException e) {
+                                ContributionResolveException ce = new ContributionResolveException(e);
+                                error("ContributionResolveException", resolver, ce);
+                                throw ce;
+                            } // end try
+                            resolver.addModel(wsdlInterface);
+                            theInterfaces.add(wsdlInterface);
+                        } // end if
+                    } // end for
+                }
+            }
         } // end for
 
         return thePortTypes;

Modified: tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java?rev=686587&r1=686586&r2=686587&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java Sat Aug 16 23:35:52 2008
@@ -194,11 +194,11 @@
             // check that the partner link has been designated as service or
             // reference in SCA terms
             if (pLink.isSCATyped()) {
-                String SCAName = pLink.getSCAName();
+                String scaName = pLink.getSCAName();
                 if (pLink.querySCAType().equals("reference")) {
-                    componentType.getReferences().add(generateReference(SCAName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces()));
+                    componentType.getReferences().add(generateReference(scaName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces()));
                 } else {
-                    componentType.getServices().add(generateService(SCAName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces()));
+                    componentType.getServices().add(generateService(scaName, pLink.getMyRolePortType(), pLink.getPartnerRolePortType(), theProcess.getInterfaces()));
                 } // end if
             } // end if
         } // end for