Author: jkaputin
Date: Sun Oct  2 06:39:37 2005
New Revision: 293112

URL: http://svn.apache.org/viewcvs?rev=293112&view=rev
Log:
Modified the messages and error handling of namespace

errors for description, shemaImport and schema.

Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/java/src/org/apache/woden/internal/Messages.properties
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/TypesImpl.java

Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=293112&r1=293111&r2=293112&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Sun 
Oct  2 06:39:37 2005
@@ -137,7 +137,25 @@
         

         String targetNamespace = 

             DOMUtils.getAttribute(descEl, Constants.ATTR_TARGET_NAMESPACE);

-        desc.setTargetNamespace(targetNamespace);

+        

+        if(targetNamespace != null)

+        {

+            desc.setTargetNamespace(targetNamespace);

+        }

+        else

+        {

+            //The targetNamespace attribute is REQUIRED on wsdl:description.

+            //(WSDL 2.0 W3C spec, Part 2: 2.1.2)

+            

+            getErrorReporter().reportError(

+                "WSDL009", 

+                new Object[] {documentBaseURI}, 

+                ErrorReporter.SEVERITY_FATAL_ERROR);

+            

+            //Won't be able to create qnames for other elements during the

+            //rest of the parse so don't continue.

+            return desc;

+        }

         

         //parse the namespace declarations

         

@@ -189,7 +207,7 @@
             }

             else if (QNameUtils.matches(Constants.Q_ELEM_INTERFACE, tempEl))

             {

-                desc.addInterfaceElement(parseInterface(tempEl, desc));

+                //desc.addInterfaceElement(parseInterface(tempEl, desc));

             }

             else

             {

@@ -223,7 +241,20 @@
                                             DescriptionElement desc) 

                                             throws WSDLException

     {

-        //TODO complete this method

+        InterfaceElement interfaceElement = desc.createInterfaceElement();

+

+        String localName = 

+            DOMUtils.getAttribute(interfaceEl, Constants.ATTR_NAME);

+        

+        if(localName != null)

+        {

+            QName qname = new QName(desc.getTargetNamespace(), localName);

+            interfaceElement.setName(qname);

+        }

+        //TODO what if name null? Handle here or leave to validator?

+        

+        

+        

         return null;

     }

     

@@ -241,6 +272,19 @@
         schema.setTargetNamespace(

             DOMUtils.getAttribute(schemaEl, Constants.ATTR_TARGET_NAMESPACE));

         

+        if(schema.getTargetNamespace() == null)

+        {

+            //Schema imported or inlined by WSDL must have a target namespace.

+            //(WSDL 2.0 W3C spec, Part 2: 3.1.1 and 3.1.2)

+            

+            getErrorReporter().reportError(

+                    "WSDL503", new Object[] {schema.getId()}, 
ErrorReporter.SEVERITY_ERROR);

+

+            //We will not be able to retrieve the elements and types for the 

+            //target NS so no point in continuing to parse the schema.

+            return schema;

+        }

+        

         /*

          * TODO Limitations in ws-commons XmlSchema slowing down Woden progress

          * for M1, so reverting to Xerces XMLSchema API for the time being.

@@ -346,22 +390,19 @@
             //The namespace attribute is REQUIRED on xs:import.

             //(WSDL 2.0 W3C spec, Part 2: 3.1.1 'Importing XML Schema')

             

-            String schemaURI = schemaImport.getSchemaLocation() != null ?

-                               schemaImport.getSchemaLocation() : "null";

-            String baseURI = desc.getDocumentBaseURI() != null ?

-                             desc.getDocumentBaseURI() : "null";

-                          

+            

             getErrorReporter().reportError(

                 "WSDL500", 

-                new Object[] {schemaURI, baseURI}, 

+                new Object[] {schemaImport.getSchemaLocation(), 
desc.getDocumentBaseURI()}, 

                 ErrorReporter.SEVERITY_ERROR);

             

+            //namespace import has failed, so don't continue

             return schemaImport;

         }

         

         if(schemaImport.getSchemaLocation() == null)

         {

-            //no location URI so we cannot retrieve a schema

+            //No schema doc to retrieve, importing namespace only.

             return schemaImport;

         }

         

@@ -384,10 +425,11 @@
             String baseURI = desc.getDocumentBaseURI() != null ?

                              desc.getDocumentBaseURI() : "null";

                     

-            //the bad URL is a non-terminating error.

             getErrorReporter().reportError("WSDL013", 

                 new Object[] {baseURI, locURI}, 

                 ErrorReporter.SEVERITY_ERROR);

+            

+            //can't continue schema retrieval with a bad URL.

             return schemaImport;

         }

 

@@ -405,24 +447,28 @@
                 

             } catch (IOException e4) {

                 

-                //the failed retrieval is reported as a warning, not an error.

+                //schema retrieval failed (e.g. 'not found')

                 getErrorReporter().reportError(

                         "WSDL015", new Object[] {schemaURL}, 
ErrorReporter.SEVERITY_WARNING, e4);

+                

+                //cannot continue without an imported schema

                 return schemaImport;

             }

             schemaEl = importedSchemaDoc.getDocumentElement();

             schema = parseSchema(schemaEl, desc);

             justImported = true;

-        }

-        

-        if(schema.getTargetNamespace() == null)

-        {

-            //Schema imported by WSDL must have a target namespace.

-            //(WSDL 2.0 W3C spec, Part 2: 3.1.1 'Importing XML Schema')

             

-            getErrorReporter().reportError(

-                    "WSDL501", new Object[] {schemaURL}, 
ErrorReporter.SEVERITY_ERROR);

-            return schemaImport;

+            if(schema.getTargetNamespace() == null)

+            {

+                //Schema imported by WSDL must have a target namespace.

+                //(WSDL 2.0 W3C spec, Part 2: 3.1.1 'Importing XML Schema')

+                

+                getErrorReporter().reportError(

+                        "WSDL501", new Object[] {schemaURL}, 
ErrorReporter.SEVERITY_ERROR);

+                

+                //Can't use the imported schema, so don't continue.

+                return schemaImport;

+            }

         }

         

         if(!schema.getTargetNamespace().equals(schemaImport.getNamespace()))

@@ -437,9 +483,11 @@
                                   schema.getTargetNamespace(),

                                   schemaURL},

                     ErrorReporter.SEVERITY_ERROR);

+            

+            //Can't use the imported schema, so don't continue.

             return schemaImport;

         }

-        

+

         schemaImport.setSchema(schema);

         

         if(justImported) {


Modified: incubator/woden/java/src/org/apache/woden/internal/Messages.properties
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/Messages.properties?rev=293112&r1=293111&r2=293112&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/Messages.properties 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/Messages.properties Sun 
Oct  2 06:39:37 2005
@@ -43,7 +43,7 @@
 WSDL006=The feature name "{0}" is not recognized.

 WSDL007=The property name must not be null when attempting to get or set a 
named property.

 WSDL008=The property name "{0}" is not recognized.

-WSDL009=###Not used yet###

+WSDL009=The WSDL description at location "{0}" is missing its target namespace 
attribute. 

 WSDL013=Could not create a URL from context URI "{0}" and location URI "{1}".

 WSDL014=Could not locate the WSDL document at URL "{0}".

 WSDL015=Could not locate the schema document at URL "{0}"

@@ -57,7 +57,8 @@
 

 WSDL500=The namespace attribute is missing from a schema import element 
<xs:import>. The schemaLocation attribute is "{0}". The base document URI of 
the importing WSDL is "{1}".

 WSDL501=The XML schema imported from "{0}" must specify a target namespace.

-WSDL502=The namespace "{0}" specified on the schema import element must match 
the target namespace "{1}" of the schema imported from "{2}".

+WSDL502=The namespace "{0}" specified on a schema import element does not 
match the target namespace "{1}" of the schema at the schemaLocation "{2}".

+WSDL503=An XML schema is missing its target namespace attribute. Schema id is 
"{0}".

 

 

 


Modified: 
incubator/woden/java/src/org/apache/woden/internal/wsdl20/TypesImpl.java
URL: 
http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/TypesImpl.java?rev=293112&r1=293111&r2=293112&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/TypesImpl.java 
(original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/TypesImpl.java 
Sun Oct  2 06:39:37 2005
@@ -18,6 +18,7 @@
 import java.util.HashMap;

 import java.util.Map;

 

+import org.apache.woden.internal.ErrorReporter;

 import org.apache.woden.schema.Schema;

 import org.apache.woden.schema.SchemaImport;

 import org.apache.woden.wsdl20.xml.DocumentationElement;

@@ -70,33 +71,39 @@
      * Schema imports <xs:import>

      * 

      * We store a SchemaImport for each <xs:import> element in a Map

-     * of SchemaImport[] keyed by namespace.

+     * of SchemaImport[] keyed by namespace. If the namespace is missing

+     * discard the SchemaImport.

      */

     

     public void addSchemaImport(SchemaImport schemaImport)

     {

-        SchemaImport[] oldArray, newArray;

         String namespace = schemaImport.getNamespace();

-        Object schemaImports = fSchemaImports.get(namespace);

-        

-        if(schemaImports == null)

-        {

-            newArray = new SchemaImport[] {schemaImport};

-        }

-        else

+

+        if(namespace != null)

         {

-            oldArray = (SchemaImport[]) schemaImports;

-            int len = oldArray.length;

-            newArray = new SchemaImport[len+1];

+            SchemaImport[] oldArray, newArray;

+            Object schemaImports = fSchemaImports.get(namespace);

             

-            for(int i=0; i < len; i++)

+            if(schemaImports == null)

             {

-               newArray[i] = oldArray[i]; 

+                newArray = new SchemaImport[] {schemaImport};

             }

-            newArray[len] = schemaImport;

+            else

+            {

+                oldArray = (SchemaImport[]) schemaImports;

+                int len = oldArray.length;

+                newArray = new SchemaImport[len+1];

+                

+                for(int i=0; i < len; i++)

+                {

+                    newArray[i] = oldArray[i]; 

+                }

+                newArray[len] = schemaImport;

+            }

+            

+            fSchemaImports.put(namespace, newArray);

         }

-        

-        fSchemaImports.put(namespace, newArray);

+        //TODO report a warning if discarded due to missing namespace?

         

     }

     

@@ -127,34 +134,40 @@
      * Inline schemas <xs:schema>

      * 

      * We store a Schema for each <xs:schema> element in a Map

-     * of Schema[] keyed by targetNamespace.

+     * of Schema[] keyed by targetNamespace. Discard the Schema

+     * if the target namespace is missing.

      */

     

     public void addSchema(Schema schema)

     {

-        Schema[] oldArray, newArray;

         String targetNamespace = schema.getTargetNamespace();

-        Object schemas = fSchemas.get(targetNamespace);

         

-        if(schemas == null)

-        {

-            newArray = new Schema[] {schema};

-        }

-        else

+        if(targetNamespace != null)

         {

-            oldArray = (Schema[]) schemas;

-            int len = oldArray.length;

-            newArray = new Schema[len+1];

+            Schema[] oldArray, newArray;

+            Object schemas = fSchemas.get(targetNamespace);

             

-            for(int i=0; i < len; i++)

+            if(schemas == null)

             {

-               newArray[i] = oldArray[i]; 

+                newArray = new Schema[] {schema};

             }

-            newArray[len] = schema;

+            else

+            {

+                oldArray = (Schema[]) schemas;

+                int len = oldArray.length;

+                newArray = new Schema[len+1];

+                

+                for(int i=0; i < len; i++)

+                {

+                    newArray[i] = oldArray[i]; 

+                }

+                newArray[len] = schema;

+            }

+            

+            fSchemas.put(targetNamespace, newArray);

         }

+        //TODO report a warning if discarded due to missing namespace?

         

-        fSchemas.put(targetNamespace, newArray);

-

     }

     

     




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to