ws-woden-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sag...@apache.org
Subject svn commit: r809831 [8/10] - in /webservices/woden/trunk/java/woden-commons: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/woden/ src/main/java/org/apache/woden/internal/ src/main/java/org/apache...
Date Tue, 01 Sep 2009 05:49:07 GMT
Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/extensions/soap/SOAPModuleImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/extensions/soap/SOAPModuleImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/extensions/soap/SOAPModuleImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/extensions/soap/SOAPModuleImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,236 @@
+/**
+ * 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.internal.wsdl20.extensions.soap;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.internal.wsdl20.extensions.AttributeExtensibleImpl;
+import org.apache.woden.internal.wsdl20.extensions.ElementExtensibleImpl;
+import org.apache.woden.wsdl20.WSDLComponent;
+import org.apache.woden.wsdl20.extensions.ExtensionElement;
+import org.apache.woden.wsdl20.extensions.soap.SOAPModule;
+import org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement;
+import org.apache.woden.wsdl20.xml.DocumentationElement;
+import org.apache.woden.wsdl20.xml.WSDLElement;
+import org.apache.woden.xml.XMLAttr;
+
+/**
+ * This class represents the SOAPModule Component and the <wsoap:module> 
+ * extension element that can appear within a Binding, Binding Fault, 
+ * Binding Operation, Binding Fault Reference or Binding Message Reference.
+ * 
+ * @author jkaputin@apache.org
+ */
+public class SOAPModuleImpl implements SOAPModule, SOAPModuleElement 
+{
+    private WSDLElement fParent = null;
+    private List fDocumentationElements = new Vector();
+    private QName fExtElementType = null;
+    private Boolean fRequired = null;
+    private AttributeExtensibleImpl fAttrExt = new AttributeExtensibleImpl();
+    private ElementExtensibleImpl fElemExt = new ElementExtensibleImpl();
+    private URI fRef = null;
+    
+
+    /* ***********************************************************************
+     *  Component model methods (SOAPModule interface), shared with Element model
+     * ***********************************************************************/
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModule#getRef()
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#getRef()
+     */
+    public URI getRef() {
+        return fRef;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModule#isRequired()
+     * @see org.apache.woden.wsdl20.extensions.ExtensionElement#isRequired()
+     */
+    public Boolean isRequired() {
+        return fRequired;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModule#getParent()
+     */
+    public WSDLComponent getParent() {
+        return (WSDLComponent)fParent;
+    }
+    
+    /* 
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModule#toElement()
+     */
+    public SOAPModuleElement toElement() {
+        return this;
+    }
+    
+
+    /* ***********************************************************************
+     *  Element model-only methods (SOAPModuleElement interface)
+     * ***********************************************************************/
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#setRef(java.net.URI)
+     */
+    public void setRef(URI uri) {
+        fRef = uri;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#setParentElement(org.apache.woden.wsdl20.xml.WSDLElement)
+     */
+    public void setParentElement(WSDLElement wsdlEl) {
+        fParent = wsdlEl;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#getParentElement()
+     */
+    public WSDLElement getParentElement() {
+        return fParent;
+    }
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#addDocumentationElement(org.apache.woden.wsdl20.xml.DocumentationElement)
+     */
+    public void addDocumentationElement(DocumentationElement docEl) 
+    {
+        if(docEl != null) {
+            fDocumentationElements.add(docEl);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.soap.SOAPModuleElement#getDocumentationElements()
+     */
+    public DocumentationElement[] getDocumentationElements() 
+    {
+        DocumentationElement[] array = new DocumentationElement[fDocumentationElements.size()];
+        fDocumentationElements.toArray(array);
+        return array;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ExtensionElement#setElementQName(javax.xml.namespace.QName)
+     */
+    public void setExtensionType(QName qname) {
+        fExtElementType = qname;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ExtensionElement#getElementQName()
+     */
+    public QName getExtensionType() {
+        return fExtElementType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ExtensionElement#setRequired(java.lang.Boolean)
+     */
+    public void setRequired(Boolean required) {
+        fRequired = required;
+    }
+    
+    /* ***********************************************************************
+     *  Extensibility methods
+     * ***********************************************************************/
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.AttributeExtensible#setExtensionAttribute(javax.xml.namespace.QName, org.apache.woden.xml.XMLAttr)
+     */
+    public void setExtensionAttribute(QName attrType, XMLAttr attr) 
+    {
+        fAttrExt.setExtensionAttribute(attrType, attr);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.AttributeExtensible#getExtensionAttribute(javax.xml.namespace.QName)
+     */
+    public XMLAttr getExtensionAttribute(QName attrType) 
+    {
+        return fAttrExt.getExtensionAttribute(attrType);
+    }
+
+    /* (non-Javadoc)
+     */
+    public XMLAttr[] getExtensionAttributesForNamespace(URI namespace) 
+    {
+        return fAttrExt.getExtensionAttributesForNamespace(namespace);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.AttributeExtensible#getExtensionAttributes()
+     */
+    public XMLAttr[] getExtensionAttributes() 
+    {
+        return fAttrExt.getExtensionAttributes();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.AttributeExtensible#hasExtensionAttributesForNamespace(java.net.URI)
+     */
+    public boolean hasExtensionAttributesForNamespace(URI namespace) 
+    {
+        return fAttrExt.hasExtensionAttributesForNamespace(namespace);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ElementExtensible#addExtensionElement(org.apache.woden.wsdl20.extensions.ExtensionElement)
+     */
+    public void addExtensionElement(ExtensionElement extEl) 
+    {
+        fElemExt.addExtensionElement(extEl);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ElementExtensible#removeExtensionElement(org.apache.woden.wsdl20.extensions.ExtensionElement)
+     */
+    public void removeExtensionElement(ExtensionElement extEl) 
+    {
+        fElemExt.removeExtensionElement(extEl);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ElementExtensible#getExtensionElements()
+     */
+    public ExtensionElement[] getExtensionElements() 
+    {
+        return fElemExt.getExtensionElements();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ElementExtensible#getExtensionElementsOfType(javax.xml.namespace.QName)
+     */
+    public ExtensionElement[] getExtensionElementsOfType(QName extType) 
+    {
+        return fElemExt.getExtensionElementsOfType(extType);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.extensions.ElementExtensible#hasExtensionElementsForNamespace(java.net.URI)
+     */
+    public boolean hasExtensionElementsForNamespace(URI namespace) 
+    {
+        return fElemExt.hasExtensionElementsForNamespace(namespace);
+    }
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidator.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,890 @@
+/**
+ * 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.internal.wsdl20.validation;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.types.NCName;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.Endpoint;
+import org.apache.woden.wsdl20.Interface;
+import org.apache.woden.wsdl20.InterfaceFault;
+import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.Service;
+import org.apache.woden.wsdl20.WSDLComponent;
+
+/**
+ * The WSDL component validator can validate a WSDL 2.0 component model
+ * against the assertions defined in the WSDL 2.0 specification. The
+ * WSDL 2.0 component assertions are currently available in the
+ * non-normative version of the WSDL 2.0 specification and can be viewed at
+ * http://dev.w3.org/cvsweb/~checkout~/2002/ws/desc/wsdl20/wsdl20.html?content-type=text/html;%20charset=utf-8#assertionsummary
+ */
+public class WSDLComponentValidator 
+{
+  /**
+   * Validate the WSDL 2.0 component model described by the
+   * description component.
+   * 
+   * @param desc The description component of the WSDL 2.0 component model.
+   * @param errorReporter An error reporter to be used for reporting errors found with the model.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the WSDL 2.0 component model.
+   */
+  public void validate(Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+    validateInterfaces(desc.getInterfaces(), errorReporter);
+    validateBindings(desc.getBindings(), desc, errorReporter);
+    validateServices(desc.getServices(), desc, errorReporter);	
+  }
+	
+  /**
+   * Validate the interfaces in the WSDL component model.
+   * 
+   * @param interfaces The interfaces in the WSDL component model.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the interface components.
+   */
+  protected void validateInterfaces(Interface[] interfaces, ErrorReporter errorReporter) throws WSDLException
+  {
+	testAssertionInterface1010(interfaces, errorReporter);
+	  
+	int numInterfaces = interfaces.length;
+	for(int i = 0; i < numInterfaces; i++)
+	{
+      Interface interfac = interfaces[i];
+      
+	  testAssertionInterface1009(interfac, errorReporter);
+	  
+	  validateInterfaceOperations(interfac, interfac.getInterfaceOperations(), errorReporter);
+	}
+  }
+  
+  /**
+   * Validate the interface operations in the WSDL component model.
+   * 
+   * @param interfac The interface that contains the interface operations.
+   * @param interfaceOperations An array of the interface operations.
+   * @param errorReporter An error reporter.
+   * @throws WSDLException
+   */
+  protected void validateInterfaceOperations(Interface interfac, InterfaceOperation[] interfaceOperations, ErrorReporter errorReporter) throws WSDLException
+  {
+	int numInterfaceOperations = interfaceOperations.length;
+	for(int j = 0; j < numInterfaceOperations; j++)
+	{
+      InterfaceOperation interfaceOperation = interfaceOperations[j];
+		
+      testAssertionMEP1022(interfaceOperation.getMessageExchangePattern(), errorReporter);
+		
+      validateInterfaceMessageReferences(interfaceOperation.getInterfaceMessageReferences(), errorReporter);
+		
+      validateInterfaceFaultReferences(interfaceOperation.getInterfaceFaultReferences(), errorReporter);
+    }
+  }
+  
+  /**
+   * Validate the interface message references in the WSDL component model.
+   * 
+   * @param messageReferences An array containing the interface message references.
+   * @param errorReporter An error reporter.
+   * @throws WSDLException
+   */
+  protected void validateInterfaceMessageReferences(InterfaceMessageReference[] messageReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+    testAssertionInterfaceMessageReference1029(messageReferences, errorReporter);
+		
+    int numMessageReferences = messageReferences.length;
+    for(int k = 0; k < numMessageReferences; k++)
+    {
+      InterfaceMessageReference messageReference = messageReferences[k];
+		  
+      testAssertionInterfaceMessageReference1028(messageReference, errorReporter);
+    }
+  }
+  
+  /**
+   * Validate the interface fault references in the WSDL component model.
+   * 
+   * @param faultReferences An array containing the interface fault references.
+   * @param errorReporter An error reporter.
+   * @throws WSDLException
+   */
+  protected void validateInterfaceFaultReferences(InterfaceFaultReference[] faultReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	testAssertionInterfaceFaultReference1039(faultReferences, errorReporter);
+		
+//    int numFaultReferences = faultReferences.length;
+//    for(int k = 0; k < numFaultReferences; k++)
+//    {
+//      InterfaceFaultReference faultReference = faultReferences[k];
+//      //TODO check if any validation is required here
+//    }
+  }
+  
+  /**
+   * Validate the bindings in the WSDL component model.
+   * 
+   * @param bindings The bindings in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the binding components.
+   */
+  protected void validateBindings(Binding[] bindings, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  testAssertionBinding1049(bindings, errorReporter);
+	  
+	  int numBindings = bindings.length;
+	  for(int i = 0; i < numBindings; i++)
+	  {
+		  Binding binding = bindings[i];
+		  testAssertionBinding1044(binding, errorReporter);
+		  testAssertionBinding1045(binding, errorReporter);
+		  testAssertionBinding1048(binding, errorReporter);
+		  
+		  validateBindingOperations(binding.getBindingOperations(), desc, errorReporter);
+		  
+		  validateBindingFaults(binding.getBindingFaults(), desc, errorReporter);
+	  }
+  }
+  
+  /**
+   * Validate the binding operations in the WSDL component model.
+   *  
+   * @param bindingOperations The bindings operations in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the binding operation components.
+   */
+  protected void validateBindingOperations(BindingOperation[] bindingOperations, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  testAssertionBindingOperation1051(bindingOperations, errorReporter);
+	  
+	  int numBindingOperations = bindingOperations.length;
+	  for(int i = 0; i < numBindingOperations; i++)
+	  {
+		  BindingOperation bindingOperation = bindingOperations[i];
+		  validateBindingMessageReferences(bindingOperation.getBindingMessageReferences(), desc, errorReporter);
+		  validateBindingFaultReferences(bindingOperation.getBindingFaultReferences(), desc, errorReporter);
+	  }
+	  
+  }
+  
+  /**
+   * Validate the binding message references in the WSDL component model.
+   * 
+   * @param bindingMessageReferences The bindings message references in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the binding message reference components.
+   */
+  protected void validateBindingMessageReferences(BindingMessageReference[] bindingMessageReferences, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  testAssertionBindingMessageReference1052(bindingMessageReferences, errorReporter);
+	  
+	  int numBindingMessageReferences = bindingMessageReferences.length;
+	  
+	  for(int i = 0; i < numBindingMessageReferences; i++)
+	  {
+		BindingMessageReference bindingMessageReference = bindingMessageReferences[i];
+        //TODO check if any validation is required here
+	  }
+  }
+  
+  /**
+   * Validate the binding fault references in the WSDL component model.
+   * 
+   * @param bindingFaultReferences The bindings fault references in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the binding fault reference components.
+   */
+  protected void validateBindingFaultReferences(BindingFaultReference[] bindingFaultReferences, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  testAssertionBindingFaultReference1055(bindingFaultReferences, errorReporter);
+	  
+	  int numBindingFaultReferences = bindingFaultReferences.length;
+	  for(int i = 0; i < numBindingFaultReferences; i++)
+	  {
+		BindingFaultReference bindingFaultReference = bindingFaultReferences[i];
+	    testAssertionBindingFaultReference1059(bindingFaultReference, errorReporter);
+	  }
+  }
+  
+  /**
+   * Validate the binding faults in the WSDL component model.
+   * 
+   * @param bindingFaults The bindings faults in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the binding fault components.
+   */
+  protected void validateBindingFaults(BindingFault[] bindingFaults, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	testAssertionBindingFault1050(bindingFaults, errorReporter);
+	
+	int numBindingFaults = bindingFaults.length;
+	
+	for(int i = 0; i < numBindingFaults; i++)
+	{
+	  BindingFault bindingFault = bindingFaults[i];
+      //TODO check if any validation is required here
+	}
+  }
+  
+  /**
+   * Validate the services in the WSDL component model.
+   * 
+   * @param services The services in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the service components.
+   */
+  protected void validateServices(Service[] services, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  testAssertionService1060(services, errorReporter);
+	  
+	  int numServices = services.length;
+	  for(int i = 0; i < numServices; i++)
+	  {
+		  Service service = services[i];
+		  
+		  validateEndpoints(service.getEndpoints(), desc, errorReporter);
+	  }
+  }
+  
+  /**
+   * Validate the endpoints in a service component in the WSDL component model.
+   * 
+   * @param endpoints The endpoints in a service in the WSDL component model.
+   * @param desc The WSDL 2.0 description component.
+   * @param errorReporter An error reporter to be used for reporting errors.
+   * @throws WSDLException A WSDLException is thrown if a problem occurs while validating the endpoint components.
+   */
+  protected void  validateEndpoints(Endpoint[] endpoints, Description desc, ErrorReporter errorReporter) throws WSDLException
+  {
+	  int numEndpoints = endpoints.length;
+	  for(int i = 0; i < numEndpoints; i++)
+	  {
+		  Endpoint endpoint = endpoints[i];
+		  testAssertionEndpoint1061(endpoint, errorReporter);
+		  testAssertionEndpoint1062(endpoint, errorReporter);
+	  }
+  }
+  
+  /**
+   * Test assertion Interface-1009. An interface cannot appear, either directly or indirectly,
+   * in the list of interfaces it extends.
+   * 
+   * @param interfac The interface to check.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterface1009(Interface interfac, ErrorReporter errorReporter) throws WSDLException
+  {
+	Interface[] extendedInterfaces = interfac.getExtendedInterfaces();
+	Interface extendedInterface = containsInterface(interfac, extendedInterfaces);
+	if(extendedInterface != null)
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "Interface-1009", new Object[]{extendedInterface.getName()}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+	return true;
+  }
+	
+  /**
+   * Helper method for testAssertionInterface0027.
+   * Check whether the specified interface is in the array of provided
+   * interfaces or in an array of interfaces one of the interfaces extends.
+   * 
+   * @param interfac The interface to check for.
+   * @param extendedInterfaces An array of extened interfaces to check for this interface.
+   * @return The interface that is equal to or extends this interface, or null if the interface is not contained.
+   */
+  private Interface containsInterface(Interface interfac, Interface[] extendedInterfaces)
+  {
+	int numExtInterfaces = extendedInterfaces.length;
+	for(int i = 0; i < numExtInterfaces; i++)
+	{
+	  if(interfac.equals(extendedInterfaces[i]))
+	    return extendedInterfaces[i];
+	  else if(containsInterface(interfac, extendedInterfaces[i].getExtendedInterfaces()) != null)
+		return extendedInterfaces[i];
+	}
+	return null;
+  }
+  
+  /**
+   * Test assertion Interface-1010. An interface must have a unique name out of all the interfaces
+   * in the description component.
+   * 
+   * @param interfaces The interfaces in the description component.
+   * @param errorReporter The error reporter.
+   * @return True if all the interfaces have unique names, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterface1010(Interface[] interfaces, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List names = new ArrayList();
+	int numInterfaces = interfaces.length;
+	for(int i = 0; i < numInterfaces; i++)
+	{
+	  QName name = interfaces[i].getName();
+      if(name == null)
+        continue;
+	  if(names.contains(name))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "Interface-1010", new Object[]{name}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		names.add(name);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion MEP-1022. A message exchange pattern must be an absolute IRI.
+   * 
+   * @param pattern The message exchange pattern to check.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionMEP1022(URI pattern, ErrorReporter errorReporter) throws WSDLException
+  {
+	if(!pattern.isAbsolute())
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "MEP-1022", new Object[]{pattern}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion InterfaceMessageReference-1028. When the {message content model} property 
+   * has the value #any or #none the {element declaration} property MUST be empty.
+   * 
+   * @param messageReference The interface message reference to check the message content model and element declarations.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterfaceMessageReference1028(InterfaceMessageReference messageReference, ErrorReporter errorReporter) throws WSDLException
+  {
+	String messContentModel = messageReference.getMessageContentModel();
+	if((messContentModel.equals(Constants.NMTOKEN_ANY) || messContentModel.equals(Constants.NMTOKEN_NONE)) 
+		&& messageReference.getElementDeclaration() != null)
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "InterfaceMessageReference-1028", new Object[]{}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion InterfaceMessageReference-1029. For each Interface Message Reference 
+   * component in the {interface message references} property of an Interface Operation 
+   * component, its {message label} property MUST be unique.
+   * 
+   * @param messageReferences The message references to check for duplicate names.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterfaceMessageReference1029(InterfaceMessageReference[] messageReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	List messageLabels = new ArrayList();
+	int numMessageReferences = messageReferences.length;
+	for(int i = 0; i < numMessageReferences; i++)
+	{
+	  NCName messageLabel = messageReferences[i].getMessageLabel();
+      if(messageLabel == null)
+          continue;
+	  if(messageLabels.contains(messageLabel))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "InterfaceMessageReference-1029", new Object[]{messageLabel}, ErrorReporter.SEVERITY_ERROR);
+		return false;
+	  }
+	  else
+	  {
+		messageLabels.add(messageLabel);
+	  }
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion InterfaceFaultReference-1039. For each Interface Fault Reference 
+   * component in the {interface fault references} property of an Interface Operation 
+   * component, the combination of its {interface fault} and {message label} properties 
+   * MUST be unique.
+   * 
+   * @param faultReferences The fault references to check for duplicate fault/message label pairs.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterfaceFaultReference1039(InterfaceFaultReference[] faultReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	Hashtable identifiers = new Hashtable();
+	
+	int numFaultReferences = faultReferences.length;
+	for(int i = 0; i < numFaultReferences; i++)
+	{
+	  InterfaceFault fault = faultReferences[i].getInterfaceFault();
+	  NCName messageLabel = faultReferences[i].getMessageLabel();
+      if(fault == null || messageLabel == null)
+    	continue;
+	  List messageLabels = (List)identifiers.get(fault);
+	  if(messageLabels != null && messageLabels.contains(messageLabel))
+	  {
+	    errorReporter.reportError(new ErrorLocatorImpl(), "InterfaceFaultReference-1039", new Object[]{fault, messageLabel}, ErrorReporter.SEVERITY_ERROR);
+		return false;
+      }
+	  else
+	  {
+		if(messageLabels == null)
+		  messageLabels = new ArrayList();
+		messageLabels.add(messageLabel);
+		identifiers.put(fault, messageLabels);
+	  }
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion Binding-1044. If a Binding component specifies any 
+   * operation-specific binding details (by including Binding Operation 
+   * components) or any fault binding details (by including Binding Fault 
+   * components) then it MUST specify an interface the Binding  component 
+   * applies to, so as to indicate which interface the operations come from.
+   * 
+   * @param binding The binding for which to check the contstraint.
+   * @param errorReporter The error Reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBinding1044(Binding binding, ErrorReporter errorReporter) throws WSDLException
+  {
+	BindingOperation[] bindingOperations = binding.getBindingOperations();
+	BindingFault[] bindingFaults = binding.getBindingFaults();
+	Interface bindingInterface = binding.getInterface();
+	if(((bindingOperations != null && bindingOperations.length > 0) || 
+		(bindingFaults != null && bindingFaults.length > 0)) && 
+		 bindingInterface == null)
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "Binding-1044", new Object[]{}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+    return true;
+  }
+  
+  /**
+   * Test assertion Binding-1045. A Binding component that defines bindings 
+   * for an Interface component MUST define bindings for all the operations 
+   * of that Interface component.
+   * 
+   * @param binding The binding of which to check the binding operations.
+   * @param errorReporter The error reporter.
+   * @return True if the all the operations specified on the interface have bindings defined, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBinding1045(Binding binding, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean allInterfaceOperationsHaveBinding = true;
+    QName bindingQN = binding.getName();
+	String bindingName = bindingQN != null ? bindingQN.getLocalPart() : null;
+	
+	Interface interfac = binding.getInterface();
+	if(interfac == null)
+	  return true;
+	
+	BindingOperation[] bindingOperations = binding.getBindingOperations();
+	int numBindingOperations = bindingOperations.length;
+	List usedInterfaceOperationList = new ArrayList();
+	for(int i = 0; i < numBindingOperations; i++)
+	{
+	  InterfaceOperation io = bindingOperations[i].getInterfaceOperation();
+	  if(io != null)
+		usedInterfaceOperationList.add(io);
+	}
+    // Check the interface operations.
+	if(!checkAllInterfaceOperationsHaveBinding(bindingName, interfac, usedInterfaceOperationList, errorReporter))
+	  allInterfaceOperationsHaveBinding = false;
+	
+	Interface[] extendedInterfaces = interfac.getExtendedInterfaces();
+	if(extendedInterfaces != null)
+	{
+	  int numExtendedInterfaces = extendedInterfaces.length;
+	  for(int i = 0; i < numExtendedInterfaces; i++)
+  	  {
+	    if(!checkAllInterfaceOperationsHaveBinding(bindingName, extendedInterfaces[i], usedInterfaceOperationList, errorReporter))
+	      allInterfaceOperationsHaveBinding = false;
+	  }
+	}
+	
+    return allInterfaceOperationsHaveBinding;
+  }
+  
+  /**
+   * Helper method for testAssertionBinding0055. This method checks that
+   * each interface operation in the provided interface has a binding 
+   * defined.
+   * 
+   * @param bindingName The name of the binding. Used in error reporting.
+   * @param interfac The interface of which to check the operations.
+   * @param usedInterfaceOperations A list of interface operations that have bindings specified.
+   * @param errorReporter The error reporter.
+   * @return True if all the interface operations have bindings defined, false otherwise.
+   * @throws WSDLException
+   */
+  private boolean checkAllInterfaceOperationsHaveBinding(String bindingName, Interface interfac, List usedInterfaceOperations, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean allInterfaceOperationsHaveBinding = true;
+	InterfaceOperation[] interfaceOperations = interfac.getInterfaceOperations();
+	if(interfaceOperations == null)
+	  return true;
+	
+	int numInterfaceOperations = interfaceOperations.length;
+	
+	// Check the interface operations.
+	for(int i = 0; i < numInterfaceOperations; i++)
+	{
+	  if(!usedInterfaceOperations.contains(interfaceOperations[i]))
+	  {
+	    errorReporter.reportError(new ErrorLocatorImpl(), "Binding-1045", new Object[]{bindingName, interfaceOperations[i].getName()}, ErrorReporter.SEVERITY_ERROR);
+		allInterfaceOperationsHaveBinding = false;
+	  }
+    }
+	return allInterfaceOperationsHaveBinding;
+  }
+  
+  /**
+   * Test assertion Binding-1048. The binding type xs:anyURI MUST be an 
+   * absolute IRI as defined by [IETF RFC 3987].
+   * 
+   * @param binding The binding of which to check the type.
+   * @param errorReporter The error reporter.
+   * @return True if the type is absolute, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBinding1048(Binding binding, ErrorReporter errorReporter) throws WSDLException
+  {
+	URI type = binding.getType();
+    if(type != null && !type.isAbsolute())
+    {
+      errorReporter.reportError(new ErrorLocatorImpl(), "Binding-1048", new Object[]{type}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+    }
+    return true;
+  }
+  
+  /**
+   * Test assertion Binding-1049. For each Binding component in the {bindings} property of a 
+   * Description component, the {name} property MUST be unique.
+   * 
+   * @param bindings The bindings in the description component.
+   * @param errorReporter The error reporter.
+   * @return True if the all the bindings have unique names, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBinding1049(Binding[] bindings, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List names = new ArrayList();
+	int numBindings = bindings.length;
+	for(int i = 0; i < numBindings; i++)
+	{
+	  QName name = bindings[i].getName();
+      if(name == null)
+        continue;
+	  if(names.contains(name))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "Binding-1049", new Object[]{name}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		names.add(name);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion BindingFault-1050. For each Binding Fault component in the 
+   * {binding faults} property of a Binding component, the {interface fault} 
+   * property MUST be unique.
+   * 
+   * @param bindingFaults The binding faults in the description component.
+   * @param errorReporter The error reporter.
+   * @return True if the all the bindings have unique names, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBindingFault1050(BindingFault[] bindingFaults, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List usedInterfaceFaults = new ArrayList();
+	int numBindingFaults = bindingFaults.length;
+	for(int i = 0; i < numBindingFaults; i++)
+	{
+	  InterfaceFault interfaceFault = bindingFaults[i].getInterfaceFault();
+	  if(interfaceFault == null) 
+	    continue;
+	  if(usedInterfaceFaults.contains(interfaceFault))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "BindingFault-1050", new Object[]{}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		usedInterfaceFaults.add(interfaceFault);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion BindingOperation-1051. For each Binding Operation component 
+   * in the {binding operations} property of a Binding component, the {interface 
+   * operation} property MUST be unique.
+   * 
+   * @param bindingOperations The binding operations to check for unique interface operations.
+   * @param errorReporter The error reporter.
+   * @return True if the all the binding operations have specified unique interface operations, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBindingOperation1051(BindingOperation[] bindingOperations, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List specifiedInterfaceOperations = new ArrayList();
+	int numBindingOperations = bindingOperations.length;
+	for(int i = 0; i < numBindingOperations; i++)
+	{
+	  InterfaceOperation interfaceOperation = bindingOperations[i].getInterfaceOperation();
+	  if(interfaceOperation == null)
+	    continue;
+	  if(specifiedInterfaceOperations.contains(interfaceOperation))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "BindingOperation-1051", new Object[]{interfaceOperation.getName()}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		specifiedInterfaceOperations.add(interfaceOperation);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion BindingMessageReference-1052. For each Binding Message 
+   * Reference component in the {binding message references} property of a 
+   * Binding Operation component, the {interface message reference} property 
+   * MUST be unique.
+   * 
+   * @param bindingMessageReferences The binding message references to check for unique interface message references.
+   * @param errorReporter The error reporter.
+   * @return True if the all the binding message references have specified unique interface message references, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBindingMessageReference1052(BindingMessageReference[] bindingMessageReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List specifiedInterfaceMessageReferences = new ArrayList();
+	int numBindingMessageReferences = bindingMessageReferences.length;
+	for(int i = 0; i < numBindingMessageReferences; i++)
+	{
+	  InterfaceMessageReference interfaceMessageReference = bindingMessageReferences[i].getInterfaceMessageReference();
+	  if(interfaceMessageReference == null)
+	    continue;
+	  if(specifiedInterfaceMessageReferences.contains(interfaceMessageReference))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "BindingMessageReference-1052", new Object[]{interfaceMessageReference.getMessageLabel()}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		specifiedInterfaceMessageReferences.add(interfaceMessageReference);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion BindingFaultReference-1055. For each Binding Fault Reference 
+   * component in the {binding fault references} property of a Binding Operation 
+   * component, the {interface fault reference} property MUST be unique.
+   * 
+   * @param bindingFaultReferences The binding fault references to check for unique interface fault references.
+   * @param errorReporter The error reporter.
+   * @return True if the all the binding fault references have specified unique interface fault references, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBindingFaultReference1055(BindingFaultReference[] bindingFaultReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean duplicateFound = false;
+	List specifiedInterfaceFaultReferences = new ArrayList();
+	int numBindingFaultReferences = bindingFaultReferences.length;
+	for(int i = 0; i < numBindingFaultReferences; i++)
+	{
+	  InterfaceFaultReference interfaceFaultReference = bindingFaultReferences[i].getInterfaceFaultReference();
+	  if(interfaceFaultReference == null)
+	    continue;
+	  if(specifiedInterfaceFaultReferences.contains(interfaceFaultReference))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "BindingFaultReference-1055", new Object[]{interfaceFaultReference.getMessageLabel()}, ErrorReporter.SEVERITY_ERROR);
+		duplicateFound = true;
+	  }
+	  else
+	  {
+		specifiedInterfaceFaultReferences.add(interfaceFaultReference);
+	  }
+	}
+	return !duplicateFound;
+  }
+  
+  /**
+   * Test assertion BindingFaultReference-1059. There MUST be an Interface Fault 
+   * Reference component in the {interface fault references} of the Interface 
+   * Operation being bound with {message label} equal to the effective message 
+   * label and with {interface fault} equal to an Interface Fault component with 
+   * {name} equal to the actual value of the ref attribute information item.
+   * 
+   * @param bindingFaultReference The binding fault reference to check if the specified interface fault reference exists.
+   * @param errorReporter The error reporter.
+   * @return True if the binding fault reference specifies a valid interface fault reference, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionBindingFaultReference1059(BindingFaultReference bindingFaultReference, ErrorReporter errorReporter) throws WSDLException
+  {
+	InterfaceFaultReference interfaceFaultReference = bindingFaultReference.getInterfaceFaultReference();
+	if(interfaceFaultReference == null)
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "BindingFaultReference-1059", new Object[]{}, ErrorReporter.SEVERITY_ERROR);
+      return false;
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion Service-1060. For each Service  component in the {services} property 
+   * of a Description component, the {name} property MUST be unique.
+   * 
+   * @param services An array containing all the services in the description component.
+   * @param errorReporter The error reporter.
+   * @return True if all services contain unique names, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionService1060(Service[] services, ErrorReporter errorReporter) throws WSDLException
+  {
+	List names = new ArrayList();
+	int numServices = services.length;
+	for(int i = 0; i < numServices; i++)
+	{
+	  QName name = services[i].getName();
+      if(name == null)
+        continue;
+	  if(names.contains(name))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "Service-1060", new Object[]{name}, ErrorReporter.SEVERITY_ERROR);
+		return false;
+	  }
+	  else
+	  {
+		names.add(name);
+	  }
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion Endpoint-1061. This xs:anyURI MUST be an absolute IRI as 
+   * defined by [IETF RFC 3987]. This xs:anyURI refers to the address IRI.
+   * 
+   * @param endpoint The endpoint of which the address should be checked.
+   * @param errorReporter The error reporter.
+   * @return True if the address IRI is absolute, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionEndpoint1061(Endpoint endpoint, ErrorReporter errorReporter) throws WSDLException
+  {
+	URI address = endpoint.getAddress();
+    if(address != null && !address.isAbsolute())
+    {
+      errorReporter.reportError(new ErrorLocatorImpl(), "Endpoint-1061", new Object[]{address}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+    }
+    return true;
+  }
+  
+  /**
+   * Test assertion Endpoint-1062. 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.
+   * 
+   * @param endpoint The endpoint of which the binding should be checked.
+   * @param errorReporter The error reporter.
+   * @return True if the binding specified the interface specified by the service or no interface, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionEndpoint1062(Endpoint endpoint, ErrorReporter errorReporter) throws WSDLException
+  {
+	Binding binding = endpoint.getBinding();
+	// If no binding has been specified this assertion does not apply.
+	if(binding == null)
+	  return true;
+	
+	Interface bindingInterface = binding.getInterface();
+	WSDLComponent parent = endpoint.getParent();
+	if(parent != null)
+	{
+	  Service service = (Service)parent;
+	  Interface serviceInterface = service.getInterface();
+	  
+	  // If an interface hasn't been specified on the service this assertion doesn't apply.
+	  // If the binding interface is null this assertion passes.
+	  if(serviceInterface != null && bindingInterface != null && !serviceInterface.equals(bindingInterface))
+	  {
+		errorReporter.reportError(new ErrorLocatorImpl(), "Endpoint-1062", new Object[]{binding, bindingInterface, serviceInterface}, ErrorReporter.SEVERITY_ERROR);
+		return false;  
+	  }
+	}
+	return true;
+  }
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,512 @@
+/**
+ * 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.internal.wsdl20.validation;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.wsdl20.Constants;
+import org.apache.woden.schema.ImportedSchema;
+import org.apache.woden.schema.InlinedSchema;
+import org.apache.woden.schema.Schema;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.ImportElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.TypesElement;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.XmlSchemaObjectTable;
+
+/**
+ * The WSDL document validator validates a WSDL XML model against the
+ * document assertions specified in the WSDL 2.0 specification.
+ */
+public class WSDLDocumentValidator 
+{
+  /**
+   * Validate the document representation of the WSDL document against
+   * the WSDL 2.0 specification.
+   * 
+   * @param descElement The WSDL 2.0 XML model description element.
+   * @param errorReporter The error reporter to use for any errors.
+   * @return True if the WSDL document representation is valid, false otherwise.
+   * @throws WSDLException
+   */
+  public boolean validate(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
+  {
+    boolean isValid = true;
+    
+    // Test the description element.
+    isValid = testAssertionDescription1006(descElement, errorReporter);
+    
+    // Test the import elements.
+    ImportElement[] imports = descElement.getImportElements();
+    int numImports = imports.length;
+    for(int i = 0; i < numImports; i++)
+    {
+      // TODO: Implement methods once import elements are supported.
+//	  if(!testAssertionImport0001(imports[i], errorReporter))
+//		isValid = false;
+//	  if(!testAssertionImport0003(imports[i], errorReporter))
+//		isValid = false;
+    }
+	if(!validateTypes(descElement.getTypesElement(), errorReporter))
+	  isValid = false;
+	
+	if(!validateInterfaces(descElement, descElement.getInterfaceElements(), errorReporter))
+	  isValid = false;
+
+		// 1. Call the validators for specific namespaces
+		//    - Does this need to be broken up into XML specific and compoent model?
+		// 2. Call post validators
+	//	validateTypes(descElement.getTypesElement(), errorReporter);
+//		Description descComponent = descElement.getDescriptionComponent();
+//		validateInterfaces(descComponent.getInterfaces(), errorReporter);
+//		
+		// TODO: validate bindings, services, and extension elements
+	  
+    return isValid;
+  }
+	
+  /**
+   * Validate the contents of the types element. This method runs the assertion
+   * tests for inline and imported types.
+   * 
+   * @param types The types element of which to validate the contents.
+   * @param errorReporter The error reporter.
+   * @return True if all the types related assertions pass, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean validateTypes(TypesElement types, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	
+	// If there is no types element all types assertions are true.
+	if(types == null)
+	  return true;
+	
+	// Test imported schema assertions.
+	ImportedSchema[] importedSchemas = types.getImportedSchemas();
+	int numImportedSchemas = importedSchemas.length;
+	for(int i = 0; i < numImportedSchemas; i++)
+	{
+	  ImportedSchema schema = (ImportedSchema)importedSchemas[i];
+		
+	  if(!testAssertionSchema1069(schema, errorReporter))
+		isValid = false;
+		
+	  if(!testAssertionSchema1070(schema, errorReporter))
+		isValid = false;
+		  
+	}
+	
+	// Test inlined schema assertions.
+	InlinedSchema[] inlinedSchemas = types.getInlinedSchemas();
+	if(!testAssertionSchema1073(inlinedSchemas, errorReporter))
+	  isValid = false;
+	return isValid;
+  }
+  
+  /**
+   * Validate the contents of the interface element. This method runs the assertion
+   * tests for interface element components.
+   * 
+   * @param interfaces An array of interface elements for which to validate the contents.
+   * @param errorReporter The error reporter.
+   * @return True if all the interface related assertions pass, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean validateInterfaces(DescriptionElement descElement, InterfaceElement[] interfaces, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	
+	int numInterfaceElements = interfaces.length;
+	for(int i = 0; i < numInterfaceElements; i++)
+	{
+	  InterfaceElement interfaceElem = interfaces[i];
+	  
+	  if(!testAssertionInterface1012(interfaceElem, errorReporter))
+		isValid = false;
+	  
+	  if(!validateInterfaceFaults(descElement, interfaceElem.getInterfaceFaultElements(), errorReporter))
+	    isValid = false;
+	  
+	  if(!validateInterfaceOperations(descElement, interfaceElem.getInterfaceOperationElements(), errorReporter))
+		isValid = false;
+	}
+	
+	return isValid;
+  }
+  
+  /**
+   * Validate the InterfaceFault elements.
+   * 
+   * @param descElement The root description element.
+   * @param faultElements An array of fault elements.
+   * @param errorReporter An error reporter.
+   * @return True if the interface fault elements are all valid, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean validateInterfaceFaults(DescriptionElement descElement, InterfaceFaultElement[] faultElements, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	int numFaultElements = faultElements.length;
+	for(int j = 0; j < numFaultElements; j++)
+	{
+	  InterfaceFaultElement faultElement = faultElements[j];
+	  if(!testAssertionSchema1066(descElement, faultElement.getElement().getQName(), errorReporter))
+	    isValid = false;
+	  }  
+	return isValid;
+  }
+  
+  /**
+   * Validate the InterfaceOperation elements.
+   * 
+   * @param descElement The root description element.
+   * @param interfaceOperations An array of interface operation elements.
+   * @param errorReporter An error reporter.
+   * @return True if the interface operation elements are all valid, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean validateInterfaceOperations(DescriptionElement descElement, InterfaceOperationElement[] interfaceOperations, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	int numInterfaceOperations = interfaceOperations.length;
+	for(int j = 0; j < numInterfaceOperations; j++)
+	{
+	  InterfaceOperationElement interfaceOperation = interfaceOperations[j];
+	  
+	  if(!validateInterfaceMessageReferences(descElement, interfaceOperation.getInterfaceMessageReferenceElements(), errorReporter))
+		isValid = false;
+	  
+	  if(!validateInterfaceFaultReferences(descElement, interfaceOperation.getInterfaceFaultReferenceElements(), errorReporter))
+			isValid = false;
+	}
+    return isValid;
+  }
+  
+  /**
+   * Validate the InterfaceMessageReference elements.
+   * 
+   * @param descElement The root description element.
+   * @param messageReferences An array of interface message reference elements.
+   * @param errorReporter An error reporter.
+   * @return True if the interface message reference elements are all valid, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean validateInterfaceMessageReferences(DescriptionElement descElement, InterfaceMessageReferenceElement[] messageReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+    //WODEN-149 removed assertion Schema-0020 from this method. InterfaceMessageReference assertions to be implemented.
+	return isValid;
+  }
+  
+   /**
+     * Validate the InterfaceFaultReference elements.
+     * 
+     * @param descElement The root description element.
+     * @param faultReferences An array of interface fault reference elements.
+     * @param errorReporter An error reporter.
+     * @return True if the interface fault reference elements are all valid, false otherwise.
+     * @throws WSDLException
+     */
+  protected boolean validateInterfaceFaultReferences(DescriptionElement descElement, InterfaceFaultReferenceElement[] faultReferences, ErrorReporter errorReporter) throws WSDLException
+  {
+     boolean isValid = true;
+     
+     int numFaultReferences = faultReferences.length;
+     for(int k = 0; k < numFaultReferences; k++)
+     {
+        InterfaceFaultReferenceElement faultReference = faultReferences[k];
+        if(!testAssertionQNameResolution1064ForInterfaceFaultReference(faultReference, errorReporter))
+          isValid = false;
+     }
+     
+     return isValid;
+  }
+  
+  /**
+   * Test assertion Description-1006. Tests whether the target namespace
+   * specified is an absolute IRI.
+   * 
+   * @param descElement The description element for which to check the target namespace.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionDescription1006(DescriptionElement descElement, ErrorReporter errorReporter) throws WSDLException
+  {
+    URI targetNS = descElement.getTargetNamespace();
+    if(!targetNS.isAbsolute())
+    {
+      errorReporter.reportError(new ErrorLocatorImpl(), "Description-1006", new Object[]{targetNS}, ErrorReporter.SEVERITY_ERROR);
+      return false;
+	}
+    return true;
+  }
+
+  /**
+   * Test assertion Schema-1069. An imported schema must contain a
+   * target namespace.
+   * 
+   * @param schema The imported schema to check.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema1069(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
+  {
+	XmlSchema schemaDef = schema.getSchemaDefinition();
+	// The assertion is true if the schema definition is not available.
+	// Problems locating the schema will be reported elseware and are
+	// not part of this assertion.
+	if(schemaDef == null)
+	  return true;
+	
+	String targetNS = schemaDef.getTargetNamespace();
+	if(targetNS == null || targetNS.equals(""))
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1069", new Object[]{schema.getSchemaLocation()}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion Schema-1070. An imported schema must specify the
+   * same target namespace as the import element.
+   * 
+   * @param schema The imported schema to check.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema1070(ImportedSchema schema, ErrorReporter errorReporter) throws WSDLException
+  {
+	XmlSchema schemaDef = schema.getSchemaDefinition();
+    // The assertion is true if the schema definition is not available.
+	// Problems locating the schema will be reported elseware and are
+	// not part of this assertion.
+	if(schemaDef == null)
+	  return true;
+	
+	String importedSchemaTargetNS = schemaDef.getTargetNamespace();
+	String specifiedTargetNS = schema.getNamespace().toString();
+	if(specifiedTargetNS != null && !specifiedTargetNS.equals(importedSchemaTargetNS))
+	{
+	  errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1070", new Object[]{specifiedTargetNS}, ErrorReporter.SEVERITY_ERROR);
+	  return false;
+	}
+	return true;
+  }
+  
+  /**
+   * Test assertion Schema-1073. Inlined XML Schemas must not define
+   * an element that has already been defined by another inline schema
+   * with the same target namespace.
+   * 
+   * @param schema An array containing all the inline schemas in the order in which they are defined.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema1073(InlinedSchema[] schema, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	int numInlineSchemas = schema.length;
+	Hashtable schemas = new Hashtable();
+	for(int i = 0; i < numInlineSchemas; i++)
+	{
+	  InlinedSchema iSchema = schema[i];
+	  URI iSchemaNs = iSchema.getNamespace();
+	  // If the namespace isn't defined this assertion doesn't apply.
+	  if(iSchemaNs == null)
+		continue;
+	  String ns = iSchemaNs.toString();
+	  
+	  if(schemas.containsKey(ns))
+	  {
+		List schemaList = (List)schemas.get(ns);
+		XmlSchemaObjectTable elements = iSchema.getSchemaDefinition().getElements();
+		Iterator elementNames = elements.getNames();
+		while(elementNames.hasNext())
+		{
+		  QName elementName = (QName)elementNames.next();
+		  Iterator otherInlineSchemas = schemaList.iterator();
+		  while(otherInlineSchemas.hasNext())
+		  {
+			if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getElementByName(elementName) != null)
+			{
+			  // Duplicate element defined.
+			  errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073", new Object[]{elementName, ns}, ErrorReporter.SEVERITY_ERROR);
+			  isValid = false;
+			}
+		  }
+		
+		}
+		
+		XmlSchemaObjectTable types = iSchema.getSchemaDefinition().getSchemaTypes();
+		Iterator typeNames = types.getNames();
+		while(typeNames.hasNext())
+		{
+		  QName typeName = (QName)typeNames.next();
+		  Iterator otherInlineSchemas = schemaList.iterator();
+		  while(otherInlineSchemas.hasNext())
+		  {
+		    if(((InlinedSchema)otherInlineSchemas.next()).getSchemaDefinition().getTypeByName(typeName) != null)
+		    {
+			  // Duplicate type defined.
+			  errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1073b", new Object[]{typeName, ns}, ErrorReporter.SEVERITY_ERROR);
+			  isValid = false;
+		    }
+		  }
+			
+		}
+		  //Check if another element has been defined.
+		  //check if another type has been defined.
+		  //add to the existing list of schemas
+		schemaList.add(iSchema);
+	  }
+	  else
+	  {
+		List schemaList = new ArrayList();
+		schemaList.add(iSchema);
+		schemas.put(ns, schemaList);
+	  }
+		 
+	}
+	return isValid;
+  }
+  
+  /**
+   * Test assertion Interface-1012. All style defaults specified on an interface
+   * element must be absolute.
+   * 
+   * @param interfaceElem The interface element to check the style default list.
+   * @param errorReporter The error reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionInterface1012(InterfaceElement interfaceElem, ErrorReporter errorReporter) throws WSDLException
+  {
+	boolean isValid = true;
+	
+	URI[] styleDefaults = interfaceElem.getStyleDefault();
+	int numStyleDefaults = styleDefaults.length;
+	for(int i = 0; i < numStyleDefaults; i++)
+	{
+	  if(!styleDefaults[i].isAbsolute())
+	  {
+	    errorReporter.reportError(new ErrorLocatorImpl(), "Interface-1012", new Object[]{styleDefaults[i].toString()}, ErrorReporter.SEVERITY_ERROR);
+	    isValid = false;
+	  }
+	}
+	return isValid;
+  }
+  
+  /**
+   * Test assertion Schema-1066. References to XML schema components must only refer
+   * to elements and types in namespaces that have been imported or inlined or that
+   * are part of the XML schema namespace.
+   * 
+   * @param descElement The description element of the document.
+   * @param namespace Check this namespace to see if it has been defined.
+   * @param errorReporter The error Reporter.
+   * @return True if the assertion passes, false otherwise.
+   * @throws WSDLException
+   */
+  protected boolean testAssertionSchema1066(DescriptionElement descElement, QName qualifiedName, ErrorReporter errorReporter) throws WSDLException
+  {
+	// If the qualifiedName is null it can't be checked.
+    if(qualifiedName != null && !qualifiedName.getNamespaceURI().equals(Constants.TYPE_XSD_2001))
+    {
+      //Get the namespace and the local name from the qualified name.
+      String namespace = qualifiedName.getNamespaceURI();
+	  String localname = qualifiedName.getLocalPart();    	
+
+      TypesElement types = descElement.getTypesElement();
+      if(types == null)
+      {
+    	errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
+        return false;
+      }
+      Schema[] schemas = types.getSchemas();
+      int numSchemas = schemas.length;
+      boolean schemaNotFound = true;
+      // TODO: This linear search should be improved for performance.
+      for(int i = 0; i < numSchemas; i++)
+      {
+    	URI schemaNs = schemas[i].getNamespace();
+    	// If the schema namespace is null continue to the next one. This is not the
+    	// schema we're looking for.
+    	if(schemaNs == null)
+    	  continue;
+    	if(schemaNs.toString().equals(namespace))
+    	{
+          schemaNotFound = false;
+    	  break;
+    	}
+      }
+      if(schemaNotFound)
+      {
+        errorReporter.reportError(new ErrorLocatorImpl(), "Schema-1066", new Object[]{localname, namespace}, ErrorReporter.SEVERITY_ERROR);
+      	return false;
+      } 
+    }
+    return true;
+  }
+  
+  /**
+   * Test assertion QName-resolution-1064 for an InterfaceFaultReference element. \
+   * A Description component must not contain broken QName references.
+   * 
+   * @param faultReference The interface fault reference to check for a broken reference.
+   * @param errorReporter An error reporter.
+   * @return True if the assertion passes, false otherwise. 
+   * @throws WSDLException
+   */
+  protected boolean testAssertionQNameResolution1064ForInterfaceFaultReference(InterfaceFaultReferenceElement faultReference, ErrorReporter errorReporter) throws WSDLException
+  {
+	QName ref = faultReference.getRef();
+	if(ref != null)
+	{
+	  InterfaceFaultElement fault = faultReference.getInterfaceFaultElement();
+	  if(fault == null)
+	  {
+	    errorReporter.reportError(new ErrorLocatorImpl(), 
+	            "QName-resolution-1064", 
+	            new Object[]{ref.toString(), "interface fault reference", "interface fault"}, 
+	            ErrorReporter.SEVERITY_ERROR);
+	    return false;
+	  }
+	}
+	return true;
+  }
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WSDLValidator.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,179 @@
+/**
+ * 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.internal.wsdl20.validation;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.woden.WSDLException;
+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.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.validation.Assertion;
+import org.apache.woden.wsdl20.validation.WodenContext;
+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 {
+    
+    private WSDLContext fWsdlCtx;
+    private WodenContext fWodenCtx;
+    
+    //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) throws WSDLException {
+        int len = 0;
+        this.fWsdlCtx = wsdlContext;
+        this.fWodenCtx = new WodenContextImpl(fWsdlCtx.errorReporter, fWsdlCtx.uriResolver);
+               
+        //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(DescriptionElement.class, descElem);
+        
+        //check assertions for the Description component
+        
+        checkAssertions(Description.class, 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(Interface.class, intfaces[i]);
+        }
+        
+    }
+    
+    /*
+     * 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 void checkAssertions(Class targetClass, Object target) throws WSDLException {
+        
+        Assertion a = null;
+        
+        //Check WSDL 2.0 assertions
+        List wsdlAsserts = (List)fWsdlAsserts.get(targetClass);
+        if (wsdlAsserts != null) {
+            for (Iterator i = wsdlAsserts.iterator(); i.hasNext();) {
+                a = (Assertion) i.next();
+                a.validate(target, fWodenCtx);
+            }
+        }
+        //Check extension assertions (get them from ExtensionRegistry)
+        List extAsserts = (List)fExtAsserts.get(targetClass);
+        if (extAsserts != null) {
+            for (Iterator i = extAsserts.iterator(); i.hasNext();) {
+                a = (Assertion) i.next();
+                a.validate(target, fWodenCtx);
+            }
+        }
+        
+    }
+    
+    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(), 
+                new AssertionInfo(new Description1002(), DescriptionElement.class));
+        fAssertions.put("Description-1003".intern(), 
+                new AssertionInfo(new Description1003(), DescriptionElement.class));
+        fAssertions.put(Interface1009.ID, 
+                new AssertionInfo(new Interface1009(), Interface.class));
+        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
+        
+        fWsdlAsserts = new HashMap();
+        
+        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() {
+        
+        fExtAsserts = new HashMap();
+
+        AssertionInfo[] infos = this.fWsdlCtx.extensionRegistry.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);
+        }
+    }
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/wsdl20/validation/WodenContextImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,51 @@
+/**
+ * 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.internal.wsdl20.validation;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.resolver.URIResolver;
+import org.apache.woden.wsdl20.validation.WodenContext;
+
+/**
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class WodenContextImpl implements WodenContext {
+    
+    private ErrorReporter errReporter;
+    private URIResolver uriResolver;
+    
+    //package private ctor
+    WodenContextImpl(ErrorReporter errReporter, URIResolver uriResolver) {
+        this.errReporter = errReporter;
+        this.uriResolver = uriResolver;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.validation.WodenContext#getErrorReporter()
+     */
+    public ErrorReporter getErrorReporter() {
+        return this.errReporter;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.woden.wsdl20.validation.WodenContext#getUriResolver()
+     */
+    public URIResolver getUriResolver() {
+        return this.uriResolver;
+    }
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/ArgumentArrayAttrImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,147 @@
+/**
+ * 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.internal.xml;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.internal.util.StringUtils;
+import org.apache.woden.wsdl20.extensions.rpc.Argument;
+import org.apache.woden.wsdl20.extensions.rpc.Direction;
+import org.apache.woden.xml.ArgumentArrayAttr;
+
+/**
+ * This class represents an XML attribute information items whose type is a list
+ * of pairs (xs:QName, xs:token) that obey the contraints of wrpc:signature as
+ * defined in Part 2 of the WSDL 2.0 spec.
+ * 
+ * @author Arthur Ryman (ryman@ca.ibm.com)
+ */
+
+public class ArgumentArrayAttrImpl extends XMLAttrImpl implements
+		ArgumentArrayAttr {
+	
+	public ArgumentArrayAttrImpl(XMLElement ownerEl, QName attrType,
+			String attrValue, ErrorReporter errRpt) throws WSDLException {
+
+		super(ownerEl, attrType, attrValue, errRpt);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.woden.xml.ArgumentArrayAttr#getArgumentArray()
+	 */
+	public Argument[] getArgumentArray() {
+
+		return (Argument[]) getContent();
+	}
+
+	protected Object convert(XMLElement ownerEl, String attrValue)
+			throws WSDLException {
+
+		setValid(false);
+
+		if (attrValue != null) {
+
+			List tokens = StringUtils.parseNMTokens(attrValue);
+			int length = tokens.size();
+
+			// list consists of (qname, token) pairs
+			if (length % 2 == 0) {
+
+				int argc = length / 2;
+				Argument[] args = new Argument[argc];
+
+				Iterator i = tokens.iterator();
+				for (int j = 0; j < argc; j++) {
+
+					String qnameStr = (String) i.next();
+					QName qname = convertQName(ownerEl, qnameStr);
+					if (qname == null)
+						return null;
+
+					String directionStr = (String) i.next();
+					Direction direction = convertDirection(directionStr);
+					if (direction == null)
+						return null;
+
+					args[j] = new Argument(qname, direction);
+				}
+
+				setValid(true);
+				return args;
+			}
+		}
+
+		// TODO: line&col nos.
+		// TODO: use correct error number
+		getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+				new Object[] { attrValue }, ErrorReporter.SEVERITY_ERROR,
+				new IllegalArgumentException());
+
+		return null;
+	}
+
+	private QName convertQName(XMLElement ownerEl, String qnameStr)
+			throws WSDLException {
+
+		QName qname = null;
+
+		try {
+			qname = ownerEl.getQName(qnameStr);
+		} catch (WSDLException e) {
+
+			// TODO: line&col nos.
+			// TODO: use correct error number
+			getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+					new Object[] { qnameStr }, ErrorReporter.SEVERITY_ERROR, e);
+		}
+
+		return qname;
+	}
+
+	private Direction convertDirection(String directionStr)
+			throws WSDLException {
+
+		Direction[] directions = new Direction[] { Direction.IN,
+				Direction.INOUT, Direction.OUT, Direction.RETURN };
+
+        for (int i = 0; i < directions.length; i++) {
+            if (directionStr.equals(directions[i].toString())) {
+                return directions[i];
+            }
+        }
+
+		// TODO: line&col nos.
+		// TODO: use correct error number
+		getErrorReporter().reportError(new ErrorLocatorImpl(), "WSDL510",
+				new Object[] { directionStr }, ErrorReporter.SEVERITY_ERROR,
+				new IllegalArgumentException());
+
+		return null;
+
+	}
+
+}

Added: webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/BooleanAttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/BooleanAttrImpl.java?rev=809831&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/BooleanAttrImpl.java (added)
+++ webservices/woden/trunk/java/woden-commons/src/main/java/org/apache/woden/internal/xml/BooleanAttrImpl.java Tue Sep  1 05:49:02 2009
@@ -0,0 +1,78 @@
+/**
+ * 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.internal.xml;
+
+import javax.xml.namespace.QName;
+
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.WSDLException;
+import org.apache.woden.XMLElement;
+import org.apache.woden.internal.ErrorLocatorImpl;
+import org.apache.woden.xml.BooleanAttr;
+
+/**
+ * This class represents XML attribute information items of type xs:boolean.
+ * If the attribute value is not "true" or "false" the Boolean content will
+ * be initialized to "false" by default, but the isValid() method will
+ * return "false".
+ * 
+ * @author jkaputin@apache.org
+ */
+public class BooleanAttrImpl extends XMLAttrImpl implements BooleanAttr 
+{
+    public BooleanAttrImpl(XMLElement ownerEl, QName attrType, 
+            String attrValue, ErrorReporter errRpt) throws WSDLException
+    {
+        super(ownerEl, attrType, attrValue, errRpt);
+    }
+    
+    /* ************************************************************
+     *  BooleanAttr interface declared methods 
+     * ************************************************************/
+    
+    public Boolean getBoolean() {
+        return (Boolean)getContent();
+    }
+    
+    /* ************************************************************
+     *  Non-API implementation methods 
+     * ************************************************************/
+
+    /*
+     * Convert a string of type xs:boolean to a java.lang.Boolean.
+     * An empty string or a null argument will initialize the Boolean to false.
+     * Any conversion error will be reported and will initialize the Boolean to false.
+     * If the attrValue does not match the Boolean value the Attr is marked invalid.
+     */
+    protected Object convert(XMLElement ownerEl, String attrValue) throws WSDLException
+    {
+        Boolean bool = Boolean.valueOf(attrValue);
+        
+        if(attrValue == null || !attrValue.equals(bool.toString()) )
+        {
+            setValid(false);
+            getErrorReporter().reportError(
+                    new ErrorLocatorImpl(),  //TODO line&col nos.
+                    "WSDL511", 
+                    new Object[] {attrValue}, 
+                    ErrorReporter.SEVERITY_ERROR);
+        }
+        
+        return bool;
+    }
+
+}



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


Mime
View raw message