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/27 17:26:29 UTC

svn commit: r631635 - in /webservices/woden/trunk/java: src/org/apache/woden/internal/ src/org/apache/woden/internal/wsdl20/assertions/ src/org/apache/woden/internal/wsdl20/validation/ src/org/apache/woden/wsdl20/extensions/ src/org/apache/woden/wsdl20...

Author: jkaputin
Date: Wed Feb 27 08:26:22 2008
New Revision: 631635

URL: http://svn.apache.org/viewvc?rev=631635&view=rev
Log:
WODEN-62
Merge the new validation and assertion code from the woden62 branch into trunk.

Added:
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/
      - copied from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1002.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1003.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1009.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Interface1010.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java
    webservices/woden/trunk/java/src/org/apache/woden/wsdl20/validation/
      - copied from r631611, webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/
    webservices/woden/trunk/java/src/org/apache/woden/wsdl20/validation/Assertion.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/Assertion.java
    webservices/woden/trunk/java/src/org/apache/woden/wsdl20/validation/AssertionInfo.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/AssertionInfo.java
    webservices/woden/trunk/java/src/org/apache/woden/wsdl20/validation/WodenContext.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/src/org/apache/woden/wsdl20/validation/WodenContext.java
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/
      - copied from r631611, webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/AssertionTestSuite.java
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/TestInterface1009.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestInterface1009.java
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/TestInterface1010.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestInterface1010.java
    webservices/woden/trunk/java/test/org/apache/woden/internal/wsdl20/assertions/WodenContextImpl.java
      - copied unchanged from r631611, webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/WodenContextImpl.java
Modified:
    webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLFactory.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
    webservices/woden/trunk/java/src/org/apache/woden/internal/Messages.properties
    webservices/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java
    webservices/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
    webservices/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java

Modified: webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLFactory.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLFactory.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLFactory.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLFactory.java Wed Feb 27 08:26:22 2008
@@ -39,7 +39,7 @@
         ErrorReporter errRpt = new ErrorReporterImpl();
         ExtensionRegistry extReg = new PopulatedExtensionRegistry(errRpt);
         ((ErrorReporterImpl)errRpt).setExtensionRegistry(extReg);
-        fWsdlContext = new WSDLContext(this, errRpt, extReg);
+        fWsdlContext = new WSDLContext(this, errRpt, extReg, null);
     }
     
     abstract public WSDLReader newWSDLReader() throws WSDLException;

Modified: webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java Wed Feb 27 08:26:22 2008
@@ -84,15 +84,13 @@
 	private final String DEFAULT_RESOLVER_PROPERTY="org.apache.woden.resolver.default";
     
     private String fFactoryImplName = null; //TODO deprecate/remove?
-    private URIResolver fResolver = null;
     
     protected WSDLContext fWsdlContext;
     final protected ReaderFeatures features;
 
     protected BaseWSDLReader(WSDLContext wsdlContext) throws WSDLException {
-        fWsdlContext = wsdlContext;
         //TODO decide what to do with fact impl name...re- only known use case is to change newDescription factory method
-        fFactoryImplName = fWsdlContext.wsdlFactory.getClass().getName();
+        fFactoryImplName = wsdlContext.wsdlFactory.getClass().getName();
         features = new ReaderFeatures();
 
         /* Establish the default URIResolver.
@@ -109,18 +107,19 @@
          */
        
         String defaultURIResolver = PropertyUtils.findProperty(DEFAULT_RESOLVER_PROPERTY);
+        URIResolver resolver;
         if (defaultURIResolver == null)
         {
         	// property not set (an allowable condition)
         	// use the "default default" URI resolver
-        	fResolver = new SimpleURIResolver();
+        	resolver = new SimpleURIResolver();
         }
         else
         {
 	        try 
 	        {
 	        	Class resolverClass = Class.forName(defaultURIResolver);
-	        	fResolver = (URIResolver) resolverClass.newInstance();
+	        	resolver = (URIResolver) resolverClass.newInstance();
 	        } 
 	        catch (Exception e)
 	        {
@@ -137,6 +136,12 @@
                        e);
            }
         }
+        
+        fWsdlContext = new WSDLContext(
+                wsdlContext.wsdlFactory,
+                wsdlContext.errorReporter,
+                wsdlContext.extensionRegistry,
+                resolver);
     }
     
     /* ************************************************************
@@ -197,7 +202,8 @@
         fWsdlContext = new WSDLContext(
                 fWsdlContext.wsdlFactory,
                 fWsdlContext.errorReporter,
-                extReg);
+                extReg,
+                fWsdlContext.uriResolver);
     }
     
     public ExtensionRegistry getExtensionRegistry() {
@@ -1638,11 +1644,24 @@
             throws WSDLException;
 
     /**
-     * Provides the capability of setting a supplied URI Resolver.
+     * Provides the capability of setting a custom URI Resolver.
      * 
+     * @param resolver the custom URIResolver
+     * @throws NullPointerException if the 'resolver' parameter is null.
      */
     public void setURIResolver(URIResolver resolver) {
-        fResolver = resolver;
+       
+        if(resolver == null) {
+            String msg = fWsdlContext.errorReporter.getFormattedMessage(
+                    "WSDL026", new Object[] {"resolver"});
+            throw new NullPointerException(msg);
+        }
+        
+        fWsdlContext = new WSDLContext(
+                fWsdlContext.wsdlFactory,
+                fWsdlContext.errorReporter,
+                fWsdlContext.extensionRegistry,
+                resolver);
     }
 
     /*
@@ -1697,7 +1716,7 @@
      * Find the current URI Resolver
      */
     public URIResolver getURIResolver() {
-        return fResolver;
+        return fWsdlContext.uriResolver;
     }
     
     

Modified: webservices/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/DOMWSDLReader.java Wed Feb 27 08:26:22 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/trunk/java/src/org/apache/woden/internal/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/Messages.properties?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/Messages.properties (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/Messages.properties Wed Feb 27 08:26:22 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 -------------------
 
@@ -102,6 +103,9 @@
 
 # ---------------- WSDL Document Level Assertions -------------------
 
+Description-1001 = The targetNamespace ''{0}'' is not dereferencable.
+Description-1001.assertion = The value of the targetNamespace attribute information item SHOULD be dereferencable.
+
 Description-1006 = The target namespace ''{0}'' is not an absolute IRI. The target namespace must be an absolute IRI.
 Description-1006.assertion = The type of the targetNamespace attribute information item is xs:anyURI. Its value MUST be an absolute IRI (see [IETF RFC 3987]).
 
@@ -220,7 +224,7 @@
 # For each Endpoint component in the {endpoints} property of a Service component, the {binding} property MUST either be a Binding component with an unspecified {interface} property or a Binding component with an {interface} property equal to the {interface} property of the Service component.
 Endpoint-1062 = The binding ''{0}'' specified for this endpoint specifies the interface ''{1}'' and not the interface ''{2}'' specified by the service. The binding specified for this endpoint must either not specify an interface or specify the same interface as the service.
 
-Interface-1009 = This interface extends itself via the extended interface ''{0}''. An interface cannot appear in the list of interfaces it extends.
+Interface-1009 = The interface ''{0}'' appears in the list of interfaces it extends.
 Interface-1009.ref = 2.2.1
 Interface-1009.assertion = To avoid circular definitions, an interface MUST NOT appear as an element of the set of interfaces it extends, either directly or indirectly.
 

Modified: webservices/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/internal/WSDLContext.java Wed Feb 27 08:26:22 2008
@@ -19,13 +19,24 @@
 
 import org.apache.woden.ErrorReporter;
 import org.apache.woden.WSDLFactory;
+import org.apache.woden.resolver.URIResolver;
 import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
 
 /**
- * A container of objects shared across Woden within the context of a WSDLFactory.
- * 
- * TODO may need to be API, if so interface is WSDLContext, class name is WSDLContextImpl, add getters and make variables private
- * TODO check for use cases that break the WSDLFactory context concept (ie WSDLReader.setFactoryImplName).
+ * A container of objects shared internally across the Woden implementation.
+ * Intially, within the context of a WSDLFactory, the properties of this object are
+ * passed by the WSDLFactory implementation to the constructor, with a null value
+ * for the <code>uriResolver</code> property (as this is set by the WSDLReader, not the
+ * factory).
+ * <p>
+ * Within the finer grained context of a WSDLReader, the <code>uriResolver</code> property
+ * will reference the resolver used by the reader and if the reader's extension registry 
+ * reference changes, the <code>extensionRegistry</code> property will reflect that new reference.
+ * <p>
+ * TODO if this needs to be made public on the API, either keep it as an immutable data object as-is,
+ * or create an API interface called WSDLContext with getters instead of public variables and create
+ * an implementation class called WSDLContextImpl.<br>
+ * TODO check for use cases that break the WSDLFactory context concept (ie WSDLReader.setFactoryImplName).<br>
  * TODO decide if anything else should be kept here (e.g. woden feats & props, Description factory)
  *  
  * @author John Kaputin (jkaputin@apache.org)
@@ -34,13 +45,16 @@
     final public WSDLFactory wsdlFactory;
     final public ErrorReporter errorReporter;
     final public ExtensionRegistry extensionRegistry;
+    final public URIResolver uriResolver;
     
     //package private ctor
     WSDLContext(WSDLFactory wsdlFactory,
             ErrorReporter errorReporter,
-            ExtensionRegistry extensionRegistry) {
+            ExtensionRegistry extensionRegistry,
+            URIResolver uriResolver) {
         this.wsdlFactory = wsdlFactory;
         this.errorReporter = errorReporter;
         this.extensionRegistry = extensionRegistry;
+        this.uriResolver = uriResolver;
     }
 }

Modified: webservices/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java (original)
+++ webservices/woden/trunk/java/src/org/apache/woden/wsdl20/extensions/ExtensionRegistry.java Wed Feb 27 08:26:22 2008
@@ -19,10 +19,13 @@
 import java.lang.reflect.Constructor;
 import java.net.URI;
 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;
 
@@ -30,10 +33,13 @@
 import org.apache.woden.WSDLException;
 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;
 
+
 /**
  * This class is used to associate serializers, deserializers, and
  * Java implementation types with extension elements.
@@ -119,6 +125,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
@@ -777,6 +789,36 @@
     public String[] queryResourceBundleNames() {
         String[] array = new String[fResourceBundleNames.size()];
         fResourceBundleNames.toArray(array);
+        return array;
+    }
+    
+    /**
+     * 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.getId(), 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;
     }
     

Modified: webservices/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java?rev=631635&r1=631634&r2=631635&view=diff
==============================================================================
--- webservices/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java (original)
+++ webservices/woden/trunk/java/test/org/apache/woden/tests/AllWodenTestsDOM.java Wed Feb 27 08:26:22 2008
@@ -23,6 +23,7 @@
 import org.apache.woden.WSDLFactoryTest;
 import org.apache.woden.WSDLReaderTest;
 import org.apache.woden.internal.ReaderFeaturesTest;
+import org.apache.woden.internal.wsdl20.assertions.AssertionTestSuite;
 import org.apache.woden.internal.wsdl20.validation.WSDLComponentValidatorTest;
 import org.apache.woden.internal.wsdl20.validation.WSDLDocumentValidatorTest;
 import org.apache.woden.resolver.SimpleURIResolverTest;
@@ -111,6 +112,7 @@
 	addTestSuite(ReaderFeaturesTest.class);
 	addTest(WSDLDocumentValidatorTest.suite());
 	addTest(WSDLComponentValidatorTest.suite());
+	addTest(AssertionTestSuite.suite());
     addTest(ServiceElementTest.suite());
     addTest(EndpointElementTest.suite());
     addTest(NameAttributeTest.suite());



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