You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by hu...@apache.org on 2007/01/17 17:24:00 UTC

svn commit: r497064 - in /incubator/woden/trunk/java/src/org/apache/woden/internal: OMWSDLReader.java util/om/OMUtils.java

Author: hughesj
Date: Wed Jan 17 08:24:00 2007
New Revision: 497064

URL: http://svn.apache.org/viewvc?view=rev&rev=497064
Log:
Fix for failing unit test: OMW3CTestSuiteTest.testTicketAgent1BFromOM

Modified:
    incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java
    incubator/woden/trunk/java/src/org/apache/woden/internal/util/om/OMUtils.java

Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java?view=diff&rev=497064&r1=497063&r2=497064
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/OMWSDLReader.java Wed Jan 17 08:24:00 2007
@@ -16,6 +16,7 @@
 package org.apache.woden.internal;
 
 import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -72,10 +73,18 @@
                             "WSDL502", new Object[] {null, wsdlURI});
             throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
         }
+        String wsdlURL = url.toString();
 
-        // perform URI Resolution here
-        OMElement wsdlDescription = OMUtils.getElement(resolveURI(url.toString()));
-
+        OMElement wsdlDescription = null;
+        try {
+            // perform URI Resolution here
+            wsdlDescription = OMUtils.getElement(resolveURI(wsdlURL));
+        } catch (IOException e) {
+            String msg = getErrorReporter().getFormattedMessage("WSDL503",
+                    new Object[] { wsdlURL });
+            throw new WSDLException(WSDLException.PARSER_ERROR, msg, e);
+        }
+        
         XMLElement descEl = createXMLElement(wsdlDescription);
         return parseDescription(url.toString(), descEl, null);
     }
@@ -184,7 +193,22 @@
 
         if(schemaDef == null){
             //not previously imported, so retrieve it now.
-            importedSchemaDoc = OMUtils.getElement(schemaURL);
+            try {
+                importedSchemaDoc = OMUtils.getElement(schemaURL);
+            } catch (IOException e4) {
+                
+                //schema retrieval failed (e.g. 'not found')
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  //TODO line&col nos.
+                        "WSDL504", 
+                        new Object[] {schemaURL}, 
+                        ErrorReporter.SEVERITY_WARNING, 
+                        e4);
+                
+                //cannot continue without an imported schema
+                schema.setReferenceable(false);
+                return schema;
+            }
 
             /*
             * First get the first element and serialize that into a byte array.
@@ -390,8 +414,23 @@
         referencedDesc = (DescriptionElement)wsdlModules.get(locationStr);
 
         if(referencedDesc == null){
-            //not previously imported or included, so retrieve the WSDL.
-            docEl = OMUtils.getElement(locationStr);
+            // not previously imported or included, so retrieve the WSDL.
+            try {
+                docEl = OMUtils.getElement(locationStr);
+            }
+            catch (IOException e) 
+            {
+                // document retrieval failed (e.g. 'not found')
+                getErrorReporter().reportError(
+                        new ErrorLocatorImpl(),  // TODO line&col nos.
+                        "WSDL503", 
+                        new Object[] {locationStr}, 
+                        ErrorReporter.SEVERITY_WARNING, 
+                        e);
+                
+                // cannot continue without the referenced document
+                return null;
+            }
 
             //The referenced document should contain a WSDL <description>
             if(!OMQNameUtils.matches(Constants.Q_ELEM_DESCRIPTION, docEl)){

Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/util/om/OMUtils.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/util/om/OMUtils.java?view=diff&rev=497064&r1=497063&r2=497064
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/util/om/OMUtils.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/util/om/OMUtils.java Wed Jan 17 08:24:00 2007
@@ -45,8 +45,9 @@
     /**
      * @param strUri The URI where the WSDL can be found
      * @return A StAXOMBuilder which could be used in obtaining the document object
+     * @throws IOException 
      */
-    public static StAXOMBuilder getOMBuilder(String strUri) {
+    public static StAXOMBuilder getOMBuilder(String strUri) throws IOException {
         StAXOMBuilder builder = null;
         try {
             URI uri = new URI(strUri);
@@ -54,8 +55,8 @@
 
             InputStream in = url.openStream();
             builder = new StAXOMBuilder(in);
-        } catch (IOException e) {
-            e.printStackTrace();
+//        } catch (IOException e) {
+//            e.printStackTrace();
         } catch (XMLStreamException e) {
             e.printStackTrace();
         } catch (URISyntaxException e) {
@@ -69,10 +70,11 @@
      * todo add validation
      * @param uri of the OMDocument
      * @return an OMElement representing the document just read
+     * @throws IOException 
      */
-    public static OMElement getElement(String uri){
+    public static OMElement getElement(String uri) throws IOException {
         StAXOMBuilder builder = OMUtils.getOMBuilder(uri);
-        return builder.getDocumentElement();
+        return builder == null ? null : builder.getDocumentElement();
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org