Author: jkaputin
Date: Wed Feb 20 06:26:23 2008
New Revision: 629471

URL: http://svn.apache.org/viewvc?rev=629471&view=rev
Log:
Fixed some NPEs in WSDLValidator and changed DOMWSDLReader to use WSDLValidator 
for assertion checking.

Modified:
    
webservices/woden/branches/woden62/src/org/apache/woden/internal/DOMWSDLReader.java
    
webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java

Modified: 
webservices/woden/branches/woden62/src/org/apache/woden/internal/DOMWSDLReader.java
URL: 
http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/DOMWSDLReader.java?rev=629471&r1=629470&r2=629471&view=diff
==============================================================================
--- 
webservices/woden/branches/woden62/src/org/apache/woden/internal/DOMWSDLReader.java
 (original)
+++ 
webservices/woden/branches/woden62/src/org/apache/woden/internal/DOMWSDLReader.java
 Wed Feb 20 06:26:23 2008
@@ -41,6 +41,7 @@
 import org.apache.woden.internal.wsdl20.Constants;
 import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidator;
 import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidator;
+import org.apache.woden.internal.wsdl20.validation.WSDLValidator;
 import org.apache.woden.internal.xpointer.DOMXMLElementEvaluator;
 import org.apache.woden.schema.Schema;
 import org.apache.woden.wsdl20.Description;
@@ -189,6 +190,7 @@
         // Validate the model if validation is enabled.
         if(features.getValue(WSDLReader.FEATURE_VALIDATION))
         {
+            /*
             if(docValidator == null)
             {
                 docValidator = new WSDLDocumentValidator();
@@ -201,6 +203,8 @@
                 }
                 compValidator.validate(descComp, getErrorReporter());
             }
+            */
+            (new WSDLValidator()).validate(descComp, fWsdlContext);
         }
         
         return descComp;

Modified: 
webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
URL: 
http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java?rev=629471&r1=629470&r2=629471&view=diff
==============================================================================
--- 
webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
 (original)
+++ 
webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
 Wed Feb 20 06:26:23 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.woden.internal.wsdl20.validation;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -51,7 +52,7 @@
     
     //not needed? ... private Map fAssertions;    //map of assertion id string 
-> AssertionInfo
     
-    private Map fWSDLAsserts;   //map of target Class -> list of WSDL 2.0 
Assertions
+    private Map fWsdlAsserts;   //map of target Class -> list of WSDL 2.0 
Assertions
     private Map fExtAsserts;    //map of target Class -> list of extension 
Assertions
     
     public void validate(Description description, WSDLContext wsdlContext) 
throws WSDLException {
@@ -73,11 +74,11 @@
         
         DescriptionElement descElem = description.toElement();
         
-        checkAssertions(descElem);
+        checkAssertions(DescriptionElement.class, descElem);
         
         //check assertions for the Description component
         
-        checkAssertions(description);
+        checkAssertions(Description.class, description);
         
         //walk the top-level component trees, calling checkAssertions for each 
component and for each 
         //component.toElement().
@@ -85,7 +86,7 @@
         Interface[] intfaces = description.getInterfaces();
         len = intfaces.length;
         for(int i=0; i<len; i++) {
-            checkAssertions(intfaces[i]);
+            checkAssertions(Interface.class, intfaces[i]);
         }
         
     }
@@ -96,23 +97,25 @@
      * Note: with the outstanding API review issue about merging the two WSDL 
models, might be
      * able to change the Object paramater to a Woden-specific type.
      */
-    private void checkAssertions(Object target) throws WSDLException {
+    private void checkAssertions(Class targetClass, Object target) throws 
WSDLException {
         
-        Class targetClass = target.getClass();
         Assertion a = null;
         
         //Check WSDL 2.0 assertions
-        List wsdlAsserts = (List)fWSDLAsserts.get(targetClass);
-        for(Iterator i=wsdlAsserts.iterator(); i.hasNext(); ) {
-            a = (Assertion) i.next();
-            a.validate(target, fAssertionCtx);
+        List wsdlAsserts = (List)fWsdlAsserts.get(targetClass);
+        if (wsdlAsserts != null) {
+            for (Iterator i = wsdlAsserts.iterator(); i.hasNext();) {
+                a = (Assertion) i.next();
+                a.validate(target, fAssertionCtx);
+            }
         }
-        
         //Check extension assertions (get them from ExtensionRegistry)
         List extAsserts = (List)fExtAsserts.get(targetClass);
-        for(Iterator i=extAsserts.iterator(); i.hasNext(); ) {
-            a = (Assertion) i.next();
-            a.validate(target, fAssertionCtx);
+        if (extAsserts != null) {
+            for (Iterator i = extAsserts.iterator(); i.hasNext();) {
+                a = (Assertion) i.next();
+                a.validate(target, fAssertionCtx);
+            }
         }
         
     }
@@ -137,26 +140,29 @@
         
         //Populate the Map of targetClass->List of WSDL 2.0 Assertions
         
+        fWsdlAsserts = new HashMap();
+        
         List descElem = new Vector();
         descElem.add(new Description1001());
         descElem.add(new Description1002());
         descElem.add(new Description1002());
-        fWSDLAsserts.put(DescriptionElement.class, descElem);
+        fWsdlAsserts.put(DescriptionElement.class, descElem);
         
         List desc = new Vector();
         desc.add(new Interface1010());
-        fWSDLAsserts.put(Description.class, desc);
+        fWsdlAsserts.put(Description.class, desc);
         
         List intf = new Vector();
         intf.add(new Interface1009());
-        fWSDLAsserts.put(Interface.class, intf);
+        fWsdlAsserts.put(Interface.class, intf);
         
     }
     
     private void setupExtensionAssertions() {
         
+        fExtAsserts = new HashMap();
+
         AssertionInfo[] infos = 
this.fWsdlCtx.extensionRegistry.queryAssertions();
-        
         List asserts;
         int len = infos.length;
         for(int i=0; i<len; i++) {



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

Reply via email to