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 jk...@apache.org on 2008/02/14 15:49:38 UTC

svn commit: r627765 - in /webservices/woden/branches/woden62/src/org/apache/woden: internal/wsdl20/validation/WSDLValidator.java wsdl20/extensions/ExtensionRegistry.java

Author: jkaputin
Date: Thu Feb 14 06:49:28 2008
New Revision: 627765

URL: http://svn.apache.org/viewvc?rev=627765&view=rev
Log:
Committing work in progress. Initial implementation of WSDLValidator.

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

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=627765&r1=627764&r2=627765&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 Thu Feb 14 06:49:28 2008
@@ -16,18 +16,21 @@
  */
 package org.apache.woden.internal.wsdl20.validation;
 
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.Vector;
 
 import org.apache.woden.ErrorReporter;
 import org.apache.woden.internal.WSDLContext;
 import org.apache.woden.internal.wsdl20.assertions.Description1001;
 import org.apache.woden.internal.wsdl20.assertions.Description1002;
-import org.apache.woden.internal.wsdl20.assertions.Description1003;
 import org.apache.woden.internal.wsdl20.assertions.Interface1009;
 import org.apache.woden.internal.wsdl20.assertions.Interface1010;
 import org.apache.woden.wsdl20.Description;
 import org.apache.woden.wsdl20.Interface;
-import org.apache.woden.wsdl20.WSDLComponent;
+import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.validation.Assertion;
 import org.apache.woden.wsdl20.validation.AssertionInfo;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 
@@ -43,26 +46,48 @@
  */
 public class WSDLValidator {
     
-    private Map fAssertions;      //map of assertion id string -> AssertionInfo
-    private Map fTargets;         //map of target Class -> list of AssertionInfo
+    private ExtensionRegistry extReg;
+    private ErrorReporter errReporter;
+    
+    //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 fExtAsserts;    //map of target Class -> list of extension Assertions
     
     public void validate(Description description, WSDLContext wsdlContext) {
+        int len = 0;
+        this.extReg = wsdlContext.extensionRegistry;
+        this.errReporter = wsdlContext.errorReporter;
                
-        //add WSDL 2.0 assertions to fAssertions
-        //TODO do this once per reader, not per document
-        setupWSDL20Assertions();
-        
-        //get ExtReg from wsdlCtx and extract registered extension assertions to add to fAssertions
-        
-        //create map targetClass->ListOfAssertionInfo, based on fAssertions
+        //setup the WSDL 2.0 assertions
+        //TODO do this once per wsdl reader object, not per document
+        setupWSDLAssertions();
+        
+        //setup the extension assertions. 
+        //TODO check - must be done per document in case ext reg has changed
+        setupExtensionAssertions();
         
         //walk the parts of the xml tree not represented in the component model, calling checkAssertions
         //method for each element.
         // - i.e. description(s), import, include, types, documentation?
         
+        DescriptionElement descElem = description.toElement();
+        
+        checkAssertions(descElem);
+        
+        //check assertions for the Description component
+        
+        checkAssertions(description);
+        
         //walk the top-level component trees, calling checkAssertions for each component and for each 
         //component.toElement().
         
+        Interface[] intfaces = description.getInterfaces();
+        len = intfaces.length;
+        for(int i=0; i<len; i++) {
+            checkAssertions(intfaces[i]);
+        }
+        
     }
     
     /*
@@ -71,17 +96,31 @@
      * 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, ErrorReporter errReporter) {
+    private void checkAssertions(Object target) {
+        
+        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, this.errReporter);
+        }
         
         //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, this.errReporter);
+        }
         
     }
     
-    private void setupWSDL20Assertions() {
+    private void setupWSDLAssertions() {
+        
+        /* This map of WSDL 2.0 assertions might not be needed
+         * 
         fAssertions.put("Description-1001".intern(), 
                 new AssertionInfo(new Description1001(), DescriptionElement.class));
         fAssertions.put("Description-1002".intern(), 
@@ -93,6 +132,42 @@
         fAssertions.put(Interface1010.ID, 
                 new AssertionInfo(new Interface1010(), Description.class));
         //TODO rest of WSDL 2.0 assertions defined in the spec
+         * 
+         */
+        
+        //Populate the Map of targetClass->List of WSDL 2.0 Assertions
+        
+        List descElem = new Vector();
+        descElem.add(new Description1001());
+        descElem.add(new Description1002());
+        descElem.add(new Description1002());
+        fWSDLAsserts.put(DescriptionElement.class, descElem);
+        
+        List desc = new Vector();
+        desc.add(new Interface1010());
+        fWSDLAsserts.put(Description.class, desc);
+        
+        List intf = new Vector();
+        intf.add(new Interface1009());
+        fWSDLAsserts.put(Interface.class, intf);
+        
+    }
+    
+    private void setupExtensionAssertions() {
+        
+        AssertionInfo[] infos = this.extReg.queryAssertions();
+        
+        List asserts;
+        int len = infos.length;
+        for(int i=0; i<len; i++) {
+            Class target = infos[i].targetClass;
+            asserts = (List) fExtAsserts.get(target);
+            if(asserts == null) {
+                asserts = new Vector();
+            }
+            asserts.add(infos[i].assertion);
+            fExtAsserts.put(target, asserts);
+        }
     }
 
 }

Modified: webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java?rev=627765&r1=627764&r2=627765&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java Thu Feb 14 06:49:28 2008
@@ -21,9 +21,11 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Vector;
 
 import javax.xml.namespace.QName;
 
@@ -37,6 +39,7 @@
 import org.apache.woden.xml.UnknownAttr;
 import org.apache.woden.xml.XMLAttr;
 
+
 /**
  * This class is used to associate serializers, deserializers, and
  * Java implementation types with extension elements.
@@ -808,15 +811,15 @@
         this.assertionReg.put(assertion.getAssertionId(), new AssertionInfo(assertion, targetClass));
     }
     
+    public AssertionInfo queryAssertion(String assertionId) {
+        return (AssertionInfo) this.assertionReg.get(assertionId);
+    }
+    
     public AssertionInfo[] queryAssertions() {
         Collection values = this.assertionReg.values();
         AssertionInfo[] array = new AssertionInfo[values.size()];
         values.toArray(array);
         return array;
-    }
-    
-    public AssertionInfo queryAssertion(String assertionId) {
-        return (AssertionInfo) this.assertionReg.get(assertionId);
     }
     
 }



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