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 hu...@apache.org on 2006/07/12 12:41:33 UTC

svn commit: r421228 - in /incubator/woden/branches/WODEN-40: src/org/apache/woden/internal/ src/org/apache/woden/internal/wsdl20/ src/org/apache/woden/wsdl20/xml/ test/org/apache/woden/internal/wsdl20/validation/

Author: hughesj
Date: Wed Jul 12 03:41:23 2006
New Revision: 421228

URL: http://svn.apache.org/viewvc?rev=421228&view=rev
Log:
No need to be able to create types element from DescriptionElement as there can only be one type element. So getTypesElement now creates the single types element if it there isn't already one.

setTypesElement() is also not needed as the only types element ever associated with an DescriptionElement is the one created in the getTypesElement

Modified:
    incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/OMWSDLReader.java
    incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
    incubator/woden/branches/WODEN-40/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
    incubator/woden/branches/WODEN-40/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java

Modified: incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/DOMWSDLReader.java?rev=421228&r1=421227&r2=421228&view=diff
==============================================================================
--- incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/DOMWSDLReader.java Wed Jul 12 03:41:23 2006
@@ -378,7 +378,7 @@
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl))
             {
-                desc.setTypesElement(parseTypes(tempEl, desc));
+                parseTypes(tempEl, desc);
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_INTERFACE, tempEl))
             {
@@ -409,11 +409,10 @@
         // statement in a WSDL 2.0 document. This method also does not work for when building the
         // model programmatically.
         // This method should be reevaluated at a later point.
-        if(desc.getTypesElement() == null)
+        TypesElement types = desc.getTypesElement();
+        if (types.getTypeSystem() == null)
         {
-          TypesElement types = desc.createTypesElement();
           types.setTypeSystem(Constants.TYPE_XSD_2001);
-          desc.setTypesElement(types);
         }
         try
         {
@@ -519,7 +518,7 @@
                                     DescriptionElement desc) 
                                     throws WSDLException
     {
-        TypesElement types = desc.createTypesElement();
+        TypesElement types = desc.getTypesElement();
         
         //TODO for now set to W3 XML Schema. Later, add support for non-XML Schema type systems
         types.setTypeSystem(Constants.TYPE_XSD_2001);

Modified: incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/OMWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/OMWSDLReader.java?rev=421228&r1=421227&r2=421228&view=diff
==============================================================================
--- incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/OMWSDLReader.java (original)
+++ incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/OMWSDLReader.java Wed Jul 12 03:41:23 2006
@@ -166,7 +166,7 @@
                 desc.addDocumentationElement(parseDocumentation(wsdlComponent, desc));
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, wsdlComponent)){
-                desc.setTypesElement(parseTypes(wsdlComponent, desc));
+                parseTypes(wsdlComponent, desc);
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_INTERFACE, wsdlComponent)){
                 parseInterface(wsdlComponent, desc);
@@ -227,7 +227,7 @@
                                     DescriptionElement desc)
                                     throws WSDLException {
 
-        TypesElement types = desc.createTypesElement();
+        TypesElement types = desc.getTypesElement();
 
         //TODO for now set to W3 XML Schema. Later, add support for non-XML Schema type systems
         types.setTypeSystem(Constants.TYPE_XSD_2001);

Modified: incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java?rev=421228&r1=421227&r2=421228&view=diff
==============================================================================
--- incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java (original)
+++ incubator/woden/branches/WODEN-40/src/org/apache/woden/internal/wsdl20/DescriptionImpl.java Wed Jul 12 03:41:23 2006
@@ -447,14 +447,12 @@
         return array;
     }
 
-    public void setTypesElement(TypesElement typesEl)
-    {
-        fTypesElement = typesEl;
-        typesEl.setParentElement(this);
-    }
-
     public TypesElement getTypesElement() 
     {
+        if (fTypesElement == null) {
+            fTypesElement = new TypesImpl();
+            fTypesElement.setParentElement(this);
+        }
         return fTypesElement;    
     }
     
@@ -495,10 +493,6 @@
         IncludeElement include = new IncludeImpl();
         fIncludeElements.add(include);
         return include;
-    }
-    
-    public TypesElement createTypesElement() {
-        return new TypesImpl();
     }
     
     public InterfaceElement createInterfaceElement() {

Modified: incubator/woden/branches/WODEN-40/src/org/apache/woden/wsdl20/xml/DescriptionElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-40/src/org/apache/woden/wsdl20/xml/DescriptionElement.java?rev=421228&r1=421227&r2=421228&view=diff
==============================================================================
--- incubator/woden/branches/WODEN-40/src/org/apache/woden/wsdl20/xml/DescriptionElement.java (original)
+++ incubator/woden/branches/WODEN-40/src/org/apache/woden/wsdl20/xml/DescriptionElement.java Wed Jul 12 03:41:23 2006
@@ -83,8 +83,6 @@
     
     public IncludeElement createIncludeElement();
 
-    public TypesElement createTypesElement();
-
     /**
      * Create a new InterfaceElement in this DescriptionElement
      * @return the InterfaceElement created
@@ -129,7 +127,6 @@
     
     public IncludeElement[] getIncludeElements();
     
-    public void setTypesElement(TypesElement typesEl);
     public TypesElement getTypesElement();
     
     public InterfaceElement[] getInterfaceElements();

Modified: incubator/woden/branches/WODEN-40/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-40/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java?rev=421228&r1=421227&r2=421228&view=diff
==============================================================================
--- incubator/woden/branches/WODEN-40/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java (original)
+++ incubator/woden/branches/WODEN-40/test/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidatorTest.java Wed Jul 12 03:41:23 2006
@@ -1074,18 +1074,18 @@
    */
   public void testTestAssertionSchema0020()
   {
-	// Create a schema for use in the tests and add it to a types section.
-	TypesElement types = new DescriptionImpl().createTypesElement();
-	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
-		  + "<complexType name=\"myType\">"     
-		  + "<sequence>"     
-          + "<element  name=\"element\" type=\"string\"/>"      
-          + "</sequence>"     
-          + "</complexType>" 
-          +	"<element name=\"myElement\" type=\"string\"/>"
-          + "</schema>";
+    // Create a schema for use in the tests and add it to a types section.
+    InlinedSchema schema = new InlinedSchemaImpl();
 	try
 	{
+      String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+              + "<complexType name=\"myType\">"     
+              + "<sequence>"     
+              + "<element  name=\"element\" type=\"string\"/>"      
+              + "</sequence>"     
+              + "</complexType>" 
+              + "<element name=\"myElement\" type=\"string\"/>"
+              + "</schema>";
 	  DOMParser builder = new DOMParser();
 	  Reader reader = new StringReader(schemaString);
       XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
@@ -1094,9 +1094,9 @@
       XmlSchemaCollection xsc = new XmlSchemaCollection();
       XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
       URI schemaNS = new URI("http://www.sample.org");
-      InlinedSchema schema = new InlinedSchemaImpl();
       schema.setSchemaDefinition(xs1);
       schema.setNamespace(schemaNS);
+      TypesElement types = new DescriptionImpl().getTypesElement();
       types.addSchema(schema);
 	}
 	catch(Exception e)
@@ -1109,7 +1109,6 @@
 	try
 	{
 	  DescriptionElement descElem = new DescriptionImpl();
-	  descElem.setTypesElement(types);
 	  InterfaceElement interfaceElem = descElem.createInterfaceElement();
 	  InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
 	  InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
@@ -1135,7 +1134,8 @@
 	{
       DescriptionElement descElem = new DescriptionImpl();
       descElem.setExtensionRegistry(new PopulatedExtensionRegistry());
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
       InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
@@ -1161,7 +1161,8 @@
 	{
       DescriptionElement descElem = new DescriptionImpl();
       descElem.setExtensionRegistry(new PopulatedExtensionRegistry());
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
       InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
@@ -1186,7 +1187,8 @@
 	{
       DescriptionElement descElem = new DescriptionImpl();
       descElem.setExtensionRegistry(new PopulatedExtensionRegistry());
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceOperationElement interfaceOperation = descElem.createInterfaceOperationElement();
       InterfaceMessageReferenceElement messageRef = descElem.createInterfaceMessageReferenceElement();
@@ -1237,17 +1239,17 @@
   public void testTestAssertionSchema0020b()
   {
 	// Create a schema for use in the tests and add it to a types section.
-	TypesElement types = new DescriptionImpl().createTypesElement();
-	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
-		  + "<complexType name=\"myType\">"     
-		  + "<sequence>"     
-          + "<element  name=\"element\" type=\"string\"/>"      
-          + "</sequence>"     
-          + "</complexType>" 
-          +	"<element name=\"myElement\" type=\"string\"/>"
-          + "</schema>";
+    InlinedSchema schema = new InlinedSchemaImpl();
 	try
 	{
+      String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+              + "<complexType name=\"myType\">"     
+              + "<sequence>"     
+              + "<element  name=\"element\" type=\"string\"/>"      
+              + "</sequence>"     
+              + "</complexType>" 
+              + "<element name=\"myElement\" type=\"string\"/>"
+              + "</schema>";
 	  DOMParser builder = new DOMParser();
 	  Reader reader = new StringReader(schemaString);
       XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
@@ -1256,9 +1258,9 @@
       XmlSchemaCollection xsc = new XmlSchemaCollection();
       XmlSchema xs1 = xsc.read(schemaDoc1.getDocumentElement());
       URI schemaNS = new URI("http://www.sample.org");
-      InlinedSchema schema = new InlinedSchemaImpl();
       schema.setSchemaDefinition(xs1);
       schema.setNamespace(schemaNS);
+      TypesElement types = new DescriptionImpl().getTypesElement();
       types.addSchema(schema);
 	}
 	catch(Exception e)
@@ -1272,7 +1274,8 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
       fault.setElementName(new QName("http://www.sample.org", "myElement"));
@@ -1295,7 +1298,8 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
       fault.setElementName(new QName("http://www.sample.org", "myElement2"));
@@ -1317,7 +1321,8 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       InterfaceElement interfaceElem = descElem.createInterfaceElement();
       InterfaceFaultElement fault = descElem.createInterfaceFaultElement();
       fault.setElementName(new QName("http://www.sample.org", "myType"));
@@ -1368,20 +1373,20 @@
   public void testTestAssertionSchema0016()
   {
 	// Create a schema for use in the tests and add it to a types section.
-	TypesElement types = new DescriptionImpl().createTypesElement();
-	String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
-		  + "<complexType name=\"myType\">"     
-		  + "<sequence>"     
-          + "<element  name=\"element\" type=\"string\"/>"      
-          + "</sequence>"     
-          + "</complexType>" 
-          +	"<element name=\"myElement\" type=\"string\"/>"
-          + "</schema>";
-	XmlSchema xs1 = null;
-	URI schemaNS = null;
+    InlinedSchema schema = new InlinedSchemaImpl();
+    XmlSchema xs1 = null;
+    URI schemaNS = null;
 	try
 	{
-	  DOMParser builder = new DOMParser();
+      String schemaString = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"http://www.sample.org\">"
+              + "<complexType name=\"myType\">"     
+              + "<sequence>"     
+              + "<element  name=\"element\" type=\"string\"/>"      
+              + "</sequence>"     
+              + "</complexType>" 
+              + "<element name=\"myElement\" type=\"string\"/>"
+              + "</schema>";
+      DOMParser builder = new DOMParser();
 	  Reader reader = new StringReader(schemaString);
       XMLInputSource is = new XMLInputSource(null,null,null,reader,null);
       builder.parse(is);
@@ -1389,9 +1394,9 @@
       XmlSchemaCollection xsc = new XmlSchemaCollection();
       xs1 = xsc.read(schemaDoc1.getDocumentElement());
       schemaNS = new URI("http://www.sample.org");
-      InlinedSchema schema = new InlinedSchemaImpl();
       schema.setSchemaDefinition(xs1);
       schema.setNamespace(schemaNS);
+      TypesElement types = new DescriptionImpl().getTypesElement();
       types.addSchema(schema);
 	}
 	catch(Exception e)
@@ -1404,7 +1409,8 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       
 	  if(!val.testAssertionSchema0016(descElem, null, reporter))
 	  {
@@ -1422,7 +1428,8 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      descElem.setTypesElement(types);
+      TypesElement types = descElem.getTypesElement();
+      types.addSchema(schema);
       
 	  if(!val.testAssertionSchema0016(descElem, "http://www.sample.org", reporter))
 	  {
@@ -1440,12 +1447,11 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      TypesElement typesImported = descElem.createTypesElement();
+      TypesElement typesImported = descElem.getTypesElement();
       ImportedSchema importedSchema = new ImportedSchemaImpl();
       importedSchema.setSchemaDefinition(xs1);
       importedSchema.setNamespace(schemaNS);
       typesImported.addSchema(importedSchema);
-      descElem.setTypesElement(typesImported);
       
 	  if(!val.testAssertionSchema0016(descElem, "http://www.sample.org", reporter))
 	  {
@@ -1499,13 +1505,12 @@
     try
 	{
       DescriptionElement descElem = new DescriptionImpl();
-      TypesElement typesImported = descElem.createTypesElement();
+      TypesElement typesImported = descElem.getTypesElement();
       InlinedSchema inlinedSchema = new InlinedSchemaImpl();
       typesImported.addSchema(inlinedSchema);
       InlinedSchema inlinedSchema2 = new InlinedSchemaImpl();
       inlinedSchema2.setNamespace(schemaNS);
       typesImported.addSchema(inlinedSchema2);
-      descElem.setTypesElement(typesImported);
       
 	  if(!val.testAssertionSchema0016(descElem, "http://www.sample.org", reporter))
 	  {



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