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 13:20:15 UTC

svn commit: r627722 - in /webservices/woden/branches/woden62/src/org/apache/woden: internal/ internal/wsdl20/assertions/ internal/wsdl20/validation/ wsdl20/extensions/ wsdl20/validation/

Author: jkaputin
Date: Thu Feb 14 04:20:13 2008
New Revision: 627722

URL: http://svn.apache.org/viewvc?rev=627722&view=rev
Log:
Committing further work-in-progress:
* changed getAssertionID() to getAssertionId()
* added a new data object class AssertionInfo
* removed boolean return types from internal validate methods.
* removed assertion dependencies code and added TODO comments for them instead

Added:
    webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java   (with props)
Modified:
    webservices/woden/branches/woden62/src/org/apache/woden/internal/Messages.properties
    webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
    webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java
    webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java
    webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java
    webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java
    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
    webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/Messages.properties?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/Messages.properties (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/Messages.properties Thu Feb 14 04:20:13 2008
@@ -60,6 +60,7 @@
 WSDL023=The extension namespace cannot be null.
 WSDL024=The extension property name cannot be null.
 WSDL025=The parent WSDLComponent cannot be null.
+WSDL026=The "{0}" parameter cannot be null.
 
 # ------------ Parsing errors -------------------
 

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java Thu Feb 14 04:20:13 2008
@@ -5,7 +5,7 @@
 
 public class Description1001 implements Assertion {
 
-    public String getAssertionID() {
+    public String getAssertionId() {
         return "Description-1001".intern();
     }
 

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java Thu Feb 14 04:20:13 2008
@@ -5,7 +5,7 @@
 
 public class Description1002 implements Assertion {
 
-    public String getAssertionID() {
+    public String getAssertionId() {
         return "Description-1002".intern();
     }
 

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java Thu Feb 14 04:20:13 2008
@@ -5,7 +5,7 @@
 
 public class Description1003 implements Assertion {
 
-    public String getAssertionID() {
+    public String getAssertionId() {
         return "Description-1003".intern();
     }
 

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java Thu Feb 14 04:20:13 2008
@@ -36,7 +36,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.woden.wsdl20.validation.Assertion#getAssertionID()
 	 */
-	public String getAssertionID() {
+	public String getAssertionId() {
 		return ID;
 	}
 

Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java Thu Feb 14 04:20:13 2008
@@ -42,7 +42,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.woden.wsdl20.validation.Assertion#getAssertionID()
 	 */
-	public String getAssertionID() {
+	public String getAssertionId() {
 		return ID;
 	}
 

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=627722&r1=627721&r2=627722&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 04:20:13 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.woden.internal.wsdl20.validation;
 
-import java.util.List;
 import java.util.Map;
 
 import org.apache.woden.ErrorReporter;
@@ -29,23 +28,25 @@
 import org.apache.woden.wsdl20.Description;
 import org.apache.woden.wsdl20.Interface;
 import org.apache.woden.wsdl20.WSDLComponent;
-import org.apache.woden.wsdl20.validation.Assertion;
+import org.apache.woden.wsdl20.validation.AssertionInfo;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 
 /**
  * Validates a WSDL 2.0 Description component by walking the component model
  * <i>tree</i> and checking the relevant assertions for each component.
+ * <p>
+ * TODO add dependency checking for prereq assertions<br>
+ * TODO decide if a return value is needed indicating the result (boolean or err/warn/OK)
  * 
  * @author John Kaputin (jkaputin@apache.org)
  *
  */
 public class WSDLValidator {
     
-    Map fAssertions;      //map of assertionID->AssertionInfo
-    Map fTargets;         //map of targetClass->list of AssertionInfo
+    private Map fAssertions;      //map of assertion id string -> AssertionInfo
+    private Map fTargets;         //map of target Class -> list of AssertionInfo
     
-    public boolean validate(Description description, WSDLContext wsdlContext) {
-        boolean result = true;
+    public void validate(Description description, WSDLContext wsdlContext) {
                
         //add WSDL 2.0 assertions to fAssertions
         //TODO do this once per reader, not per document
@@ -62,49 +63,35 @@
         //walk the top-level component trees, calling checkAssertions for each component and for each 
         //component.toElement().
         
-        return result;
     }
     
     /*
-     * Invoke the validate() method on each assertion mapped to the target component
-     * after first checking for assertions they depend on and verifying that they have
-     * been validated.
-     * 
-     * TODO decide if 'warning' failures return true/false (i.e. 'SHOULD', 'MAY')
+     * Invoke the validate() method on each assertion mapped to the target WSDL 2.0 object.
+     * This object will be a WSDLComponent or a WSDLElement. 
+     * 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 boolean checkAssertions(WSDLComponent target, ErrorReporter errReporter) {
-        boolean result = true;
+    private void checkAssertions(Object target, ErrorReporter errReporter) {
         
+        //Check WSDL 2.0 assertions
+        
+        //Check extension assertions (get them from ExtensionRegistry)
         
         
-        return result;
-    }
-    
-    private class AssertionInfo {
-        private Assertion assertion;
-        private Class targetClass;
-        private List dependsOn;
-        private Boolean result = null;
-        
-        private AssertionInfo(Assertion assertion, Class targetClass, List dependsOn) {
-            this.assertion = assertion;
-            this.targetClass = targetClass;
-            this.dependsOn = dependsOn;
-        }
         
     }
     
     private void setupWSDL20Assertions() {
         fAssertions.put("Description-1001".intern(), 
-                new AssertionInfo(new Description1001(), DescriptionElement.class, null));
+                new AssertionInfo(new Description1001(), DescriptionElement.class));
         fAssertions.put("Description-1002".intern(), 
-                new AssertionInfo(new Description1002(), DescriptionElement.class, null));
+                new AssertionInfo(new Description1002(), DescriptionElement.class));
         fAssertions.put("Description-1003".intern(), 
-                new AssertionInfo(new Description1003(), DescriptionElement.class, null));
+                new AssertionInfo(new Description1003(), DescriptionElement.class));
         fAssertions.put(Interface1009.ID, 
-                new AssertionInfo(new Interface1009(), Interface.class, null));
+                new AssertionInfo(new Interface1009(), Interface.class));
         fAssertions.put(Interface1010.ID, 
-                new AssertionInfo(new Interface1010(), Description.class, null));
+                new AssertionInfo(new Interface1010(), Description.class));
         //TODO rest of WSDL 2.0 assertions defined in the spec
     }
 

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=627722&r1=627721&r2=627722&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 04:20:13 2008
@@ -19,6 +19,7 @@
 import java.lang.reflect.Constructor;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -31,6 +32,7 @@
 import org.apache.woden.XMLElement;
 import org.apache.woden.wsdl20.WSDLComponent;
 import org.apache.woden.wsdl20.validation.Assertion;
+import org.apache.woden.wsdl20.validation.AssertionInfo;
 import org.apache.woden.wsdl20.xml.WSDLElement;
 import org.apache.woden.xml.UnknownAttr;
 import org.apache.woden.xml.XMLAttr;
@@ -120,6 +122,12 @@
   {
       return this.errorReporter;
   }
+  
+  /*
+   * A Map of assertions, where the key is an assertion id string and 
+   * the value is an AssertionInfo object.
+   */
+  protected Map assertionReg = new Hashtable();
 
   /**
    * Set the serializer to be used when none is found for an extensibility
@@ -781,12 +789,34 @@
         return array;
     }
     
-    public void registerAssertion(Assertion assertion, Class target, String dependencies) {
-        //register each extension assertion, the target class it applies to and the assertions it depends on
+    /**
+     * Register an Assertion along with the target Class that the assertion applies to.
+     * TODO assertion dependencies.
+     * 
+     * @param assertion an Assertion object representing the assertion to be registered.
+     * @param targetClass the Class representing the component in the WSDL that the assertion applies to.
+     */
+    public void registerAssertion(Assertion assertion, Class targetClass) {
+        if(assertion == null) {
+            String msg = this.errorReporter.getFormattedMessage("WSDL026", new Object[] {"assertion"});
+            throw new NullPointerException(msg);
+        } else if(targetClass==null) {
+            String msg = this.errorReporter.getFormattedMessage("WSDL026", new Object[] {"targetClass"});
+            throw new NullPointerException(msg);
+        }
+        
+        this.assertionReg.put(assertion.getAssertionId(), new AssertionInfo(assertion, targetClass));
+    }
+    
+    public AssertionInfo[] queryAssertions() {
+        Collection values = this.assertionReg.values();
+        AssertionInfo[] array = new AssertionInfo[values.size()];
+        values.toArray(array);
+        return array;
     }
     
-    public void queryAssertions() {
-        //return details of all registered assertions - need a non-void array return type
+    public AssertionInfo queryAssertion(String assertionId) {
+        return (AssertionInfo) this.assertionReg.get(assertionId);
     }
     
 }

Modified: webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java?rev=627722&r1=627721&r2=627722&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java Thu Feb 14 04:20:13 2008
@@ -33,7 +33,7 @@
      * 
      * @return the String representing the ID of this assertion.
      */
-    public String getAssertionID();
+    public String getAssertionId();
     
     /**
      * Validates the specified WSDL object against this assertion.

Added: webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java?rev=627722&view=auto
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java (added)
+++ webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java Thu Feb 14 04:20:13 2008
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0 
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+package org.apache.woden.wsdl20.validation;
+
+
+
+/**
+ * Represents an immutable object containing the information about an assertion 
+ * which is needed to perform WSDL validation. 
+ * This information consists of the Assertion object and the target Class
+ * for the WSDL component that this assertion applies to.
+ * <p>
+ * TODO assertion dependencies to be added later.
+ * 
+ * @author John Kaputin (jkaputin@apache.org)
+ *
+ */
+public class AssertionInfo {
+
+    public final Assertion assertion;
+    public final Class targetClass;
+    //TODO private List dependencies;
+    
+    public AssertionInfo(Assertion assertion, Class targetClass) {
+        this.assertion = assertion;
+        this.targetClass = targetClass;
+    }
+    
+}

Propchange: webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native



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