Author: edwardsmj
Date: Thu May  8 13:53:54 2008
New Revision: 654619

URL: http://svn.apache.org/viewvc?rev=654619&view=rev
Log:
Fixes with additional checks for exception situations in processing BPEL 
process files.

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

Modified: 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java?rev=654619&r1=654618&r2=654619&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java
 Thu May  8 13:53:54 2008
@@ -153,17 +153,20 @@
                if ( 
theImport.getImportType().equals("http://schemas.xmlsoap.org/wsdl/";) ) {
                        String WSDLLocation = theImport.getLocation();
                        String WSDLNamespace = theImport.getNamespace();
-                       // FIXME both Location & Namespace attributes are 
optional - for the present
-                       // we don't deal with these cases - they are skipped
-                       if ( WSDLLocation == null || WSDLNamespace == null ) 
continue;
+                       
                        // Resolve the WSDL definition
                 WSDLDefinition proxy = WSDLfactory.createWSDLDefinition();
                 proxy.setUnresolved(true);
                 proxy.setNamespace(WSDLNamespace);
-                proxy.setLocation(URI.create(WSDLLocation));
+                if ( WSDLLocation != null ) 
proxy.setLocation(URI.create(WSDLLocation));
                 WSDLDefinition resolved = 
resolver.resolveModel(WSDLDefinition.class, proxy);
                 if (resolved != null && !resolved.isUnresolved()) {
                     theImport.setWSDLDefinition( resolved );
+                } else {
+                       throw new 
ContributionResolveException("BPELDocumentProcessor:resolve -" +
+                                       " unable to resolve WSDL referenced by 
BPEL import" +
+                                       "WSDL location: " + WSDLLocation + " 
WSDLNamespace: " +
+                                       WSDLNamespace );
                 } // end if    
                } // end if
        } // end for

Modified: 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java?rev=654619&r1=654618&r2=654619&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java
 Thu May  8 13:53:54 2008
@@ -181,7 +181,8 @@
     
     // Calculates the component type of the supplied implementation and 
attaches it to the
     // implementation
-    private void generateComponentType(BPELImplementation impl ) {
+    private void generateComponentType(BPELImplementation impl ) 
+       throws ContributionResolveException {
         // Create a ComponentType and mark it unresolved
         ComponentType componentType = assemblyFactory.createComponentType();
         componentType.setUnresolved(true);
@@ -226,11 +227,30 @@
      * @return
      */
     private Reference generateReference( String name, PortType myRolePT, 
-               PortType partnerRolePT, Collection<WSDLInterface> theInterfaces 
 ) {
+               PortType partnerRolePT, Collection<WSDLInterface> theInterfaces 
 ) 
+               throws ContributionResolveException {
         Reference reference = assemblyFactory.createReference();
         WSDLInterfaceContract interfaceContract = 
wsdlFactory.createWSDLInterfaceContract();
         reference.setInterfaceContract(interfaceContract);
         
+        // Establish whether there is just a call interface or a call + 
callback interface
+        PortType callPT = null;
+        PortType callbackPT = null;
+        if( myRolePT != null ) {
+               callPT = myRolePT;
+               if( partnerRolePT != null ) {
+                       if( !myRolePT.equals(partnerRolePT) ){
+                               callbackPT = partnerRolePT;
+                       } // end if
+               } // end if
+        } else if ( partnerRolePT != null ) {
+               callPT = partnerRolePT;
+        } // end if
+        // No interfaces mean an error - throw an exception
+        if( callPT == null && callbackPT == null ) {
+               throw new ContributionResolveException("Error: myRole and 
partnerRole port types are both null");
+        } // end if 
+        
         // Set the name of the reference to the supplied name and the 
multiplicity of the reference
         // to 1..1 
         // TODO: support other multiplicities 
@@ -240,20 +260,28 @@
         // Set the call interface and, if present, the callback interface
         WSDLInterface callInterface = null;
         for( WSDLInterface anInterface : theInterfaces ) {
-               if( anInterface.getPortType().equals(myRolePT)) callInterface = 
anInterface;
+               if( anInterface.getPortType().equals(callPT)) callInterface = 
anInterface;
         } // end for
-        //TODO need to throw an exception here if no interface is found
+        // Throw an exception if no interface is found
+        if( callInterface == null ) {
+               throw new ContributionResolveException("Interface not found for 
port type " +
+                               callPT.getQName().toString() );
+        } // end if 
         reference.getInterfaceContract().setInterface(callInterface);
  
         // There is a callback if the partner role is not null and if the 
partner role port type
         // is not the same as the port type for my role
-        if (partnerRolePT != null && !myRolePT.equals(partnerRolePT) ) {
+        if ( callbackPT != null ) {
             WSDLInterface callbackInterface = null;
             for( WSDLInterface anInterface : theInterfaces ) {
-               if( anInterface.getPortType().equals(myRolePT)) 
callbackInterface = anInterface;
+               if( anInterface.getPortType().equals(callbackPT)) 
callbackInterface = anInterface;
             } // end for
-            //TODO need to throw an exception here if no interface is found
-             
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+            // Throw an exception if no interface is found
+            if( callbackInterface == null ) {
+               throw new ContributionResolveException("Interface not found for 
port type " +
+                               callbackPT.getQName().toString() );
+            } // end if 
+            
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
         } // end if
        
        return reference;
@@ -268,30 +296,60 @@
      * @return
      */
     private Service generateService( String name, PortType myRolePT, 
-               PortType partnerRolePT, Collection<WSDLInterface> theInterfaces 
) {
+               PortType partnerRolePT, Collection<WSDLInterface> theInterfaces 
) 
+               throws ContributionResolveException {
         Service service = assemblyFactory.createService();
         WSDLInterfaceContract interfaceContract = 
wsdlFactory.createWSDLInterfaceContract();
         service.setInterfaceContract(interfaceContract);
         
         // Set the name of the service to the supplied name 
         service.setName(name);
+        
+        // Establish whether there is just a call interface or a call + 
callback interface
+        PortType callPT = null;
+        PortType callbackPT = null;
+        if( myRolePT != null ) {
+               callPT = myRolePT;
+               if( partnerRolePT != null ) {
+                       if( !myRolePT.equals(partnerRolePT) ){
+                               callbackPT = partnerRolePT;
+                       } // end if
+               } // end if
+        } else if ( partnerRolePT != null ) {
+               callPT = partnerRolePT;
+        } // end if
+        // No interfaces mean an error - throw an exception
+        if( callPT == null && callbackPT == null ) {
+               throw new ContributionResolveException("Error: myRole and 
partnerRole port types are both null");
+        } // end if 
+
 
         // Set the call interface and, if present, the callback interface
         WSDLInterface callInterface = null;
         for( WSDLInterface anInterface : theInterfaces ) {
-               if( anInterface.getPortType().equals(myRolePT)) callInterface = 
anInterface;
+               if( anInterface.getPortType().equals(callPT)) callInterface = 
anInterface;
         } // end for
-        //TODO need to throw an exception here if no interface is found
+        // Throw an exception if no interface is found
+        if( callInterface == null ) {
+               throw new ContributionResolveException("Interface not found for 
port type " +
+                               callPT.getQName().toString() );
+        } // end if 
+
         service.getInterfaceContract().setInterface(callInterface);    
         
         // There is a callback if the partner role is not null and if the 
partner role port type
         // is not the same as the port type for my role
-        if (partnerRolePT != null && !myRolePT.equals(partnerRolePT) ) {
+        if ( callbackPT != null ) {
             WSDLInterface callbackInterface = null;
             for( WSDLInterface anInterface : theInterfaces ) {
-               if( anInterface.getPortType().equals(myRolePT)) 
callbackInterface = anInterface;
+               if( anInterface.getPortType().equals(callbackPT)) 
callbackInterface = anInterface;
             } // end for
-            //TODO need to throw an exception here if no interface is found
+            // Throw an exception if no interface is found
+            if( callbackInterface == null ) {
+               throw new ContributionResolveException("Interface not found for 
port type " +
+                               callbackPT.getQName().toString() );
+            } // end if 
+
             
service.getInterfaceContract().setCallbackInterface(callbackInterface);
         } // end if
        

Modified: 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java?rev=654619&r1=654618&r2=654619&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java
 Thu May  8 13:53:54 2008
@@ -77,9 +77,10 @@
     }
     
     private PortType getRolePortType( String theRole ) {
-       if ( pLinkType.getRole1Name().equals(theRole) ) {
+       if( theRole == null ) return null;
+       if ( theRole.equals( pLinkType.getRole1Name() ) ) {
                return pLinkType.getRole1pType();
-       } else if ( pLinkType.getRole2Name().equals(theRole) ) {
+       } else if ( theRole.equals( pLinkType.getRole2Name() ) ) {
                return pLinkType.getRole2pType();
        } // end if 
        return null;


Reply via email to