Author: jkaputin
Date: Mon Oct  1 13:39:10 2007
New Revision: 581066

URL: http://svn.apache.org/viewvc?rev=581066&view=rev
Log:
WODEN-65
Committing a further contribution from 
Sagara Gunathunga for Woden serialization.

Modified:
    incubator/woden/branches/woden65/src/org/apache/woden/WSDLWriter.java
    
incubator/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java
    
incubator/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java
    
incubator/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLWriter.java
    
incubator/woden/branches/woden65/src/org/apache/woden/internal/WriterFeatures.java

Modified: incubator/woden/branches/woden65/src/org/apache/woden/WSDLWriter.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/woden65/src/org/apache/woden/WSDLWriter.java?rev=581066&r1=581065&r2=581066&view=diff
==============================================================================
--- incubator/woden/branches/woden65/src/org/apache/woden/WSDLWriter.java 
(original)
+++ incubator/woden/branches/woden65/src/org/apache/woden/WSDLWriter.java Mon 
Oct  1 13:39:10 2007
@@ -1,9 +1,24 @@
-
+/**
+ * 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;
 
 import java.io.Writer;
 import java.io.OutputStream;
-import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
 /**
  * This interface describes a collection of methods
  * that allow a WSDL model to be written to a writer
@@ -47,20 +62,20 @@
     public boolean getFeature(String name) throws IllegalArgumentException;
 
     /**
-     * Write the specified WSDL definition to the specified Writer.
+     * Write the specified WSDL Description to the specified Writer.
      *
-     * @param wsdlDef the WSDL definition to be written.
+     * @param wsdlDes the WSDL description to be written.
      * @param sink the Writer to write the xml to.
      */
-    public void writeWSDL(Description wsdlDes, Writer sink)
+    public void writeWSDL(DescriptionElement wsdlDes, Writer sink)
       throws WSDLException;
     /**
-     * Write the specified WSDL definition to the specified OutputStream.
+     * Write the specified WSDL Description to the specified OutputStream.
      *
-     * @param wsdlDef the WSDL definition to be written.
+     * @param wsdlDes the WSDL description to be written.
      * @param sink the OutputStream to write the xml to.
      */
-    public void writeWSDL(Description wsdlDes, OutputStream sink)
+    public void writeWSDL(DescriptionElement wsdlDes, OutputStream sink)
       throws WSDLException;
 
 }

Modified: 
incubator/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java?rev=581066&r1=581065&r2=581066&view=diff
==============================================================================
--- 
incubator/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java
 (original)
+++ 
incubator/woden/branches/woden65/src/org/apache/woden/internal/BaseWSDLWriter.java
 Mon Oct  1 13:39:10 2007
@@ -1,4 +1,19 @@
-
+/**
+ * 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;
 
 import java.io.OutputStream;
@@ -25,14 +40,15 @@
 import org.apache.woden.internal.wsdl20.Constants;
 
 /**
- *   This class contains properties and methods common
- *   to WSDLWriter implementations.
+ * This abstract class contains properties and methods common
+ * to WSDLWriter implementations. This abstract class implements
+ * methods of the WSDLWriter interface that are common across all
+ * concrete Writer implementations such as setting and getting
+ * features and properties, ExtensionRegistry.
  *
- *   TODO Once the OMWSDLWriter implemantation is completed
- *   this class should be a abstract class.
  *   @author Sagara Gunathunga ([EMAIL PROTECTED])
- *
  */
+
  public abstract  class BaseWSDLWriter implements WSDLWriter{
 
      private String fFactoryImplName = null; //TODO deprecate/remove?

Modified: 
incubator/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java?rev=581066&r1=581065&r2=581066&view=diff
==============================================================================
--- 
incubator/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java
 (original)
+++ 
incubator/woden/branches/woden65/src/org/apache/woden/internal/DOMWSDLWriter.java
 Mon Oct  1 13:39:10 2007
@@ -1,3 +1,19 @@
+/**
+ * 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;
 
 import java.io.OutputStream;
@@ -26,9 +42,14 @@
 import org.apache.woden.internal.util.dom.DOM2Writer;
 import org.apache.woden.internal.util.dom.DOMUtils;
 import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
+import org.apache.woden.wsdl20.extensions.*;
 
 /**
- * WSDLWriter implemantation based on DOM
+ * This is a concrete class derived from BaseWSDLWriter
+ * class and implements method to serialize each WSDL2.0
+ * element based on DOM and also WriteWSDL() methods of
+ * the  WSDLWriter interface .
+ *
  *
  * @author Sagara Gunathunga ([EMAIL PROTECTED])
  */
@@ -41,7 +62,15 @@
 
     }
 
-    public void writeWSDL(Description wsdlDes, Writer sink)
+
+    /**
+     * This method write the specified WSDL Description to
+     * the specified Writer.
+     *
+     * @param wsdlDes the WSDL Description to be written.
+     * @param sink the Writer to write the xml to.
+     */
+    public void writeWSDL(DescriptionElement wsdlDes, Writer sink)
         throws WSDLException {
 
         PrintWriter pw = new PrintWriter(sink);
@@ -61,7 +90,16 @@
         printDescription(wsdlDes, pw);
     }
 
-    public void writeWSDL(Description wsdlDes, OutputStream sink)
+
+
+    /**
+     * This method write the specified WSDL Description to
+     * the specified Writer.
+     *
+     * @param wsdlDes the WSDL Description to be written.
+     * @param sink the OutputStream to write the xml to.
+     */
+    public void writeWSDL(DescriptionElement wsdlDes, OutputStream sink)
         throws WSDLException {
 
         Writer writer = null;
@@ -75,18 +113,24 @@
         writeWSDL(wsdlDes, writer);
     }
 
-    protected void printDescription(Description def, PrintWriter pw)
+
+    /**
+     * Write the specified WSDL DescriptionElement and it's
+     * child elements to  the specified Writer.
+     *
+     * @param desEle the WSDL Description to be written.
+     * @param sink the Writer to write the xml to.
+     */
+    protected void printDescription(DescriptionElement desEle, PrintWriter pw)
         throws WSDLException {
 
-        if (def == null){
+        if (desEle == null){
             return;
         }
-        DescriptionElement desEle=def.toElement();
         if (DOMUtils.getPrefix(Constants.NS_URI_WSDL20,desEle) == null){
-
             String prefix = "wsdl";
             int subscript = 0;
-            while (def.toElement().getNamespace(prefix) != null){
+            while (desEle.getNamespace(prefix) != null){
                 prefix = "wsdl" + subscript++;
             }
             try{
@@ -103,31 +147,29 @@
         DOMUtils.printAttribute(Constants.ATTR_TARGET_NAMESPACE,
                                 targetNamespace,
                                 pw);
-         //TODO
-        //printExtensibilityAttributes(DescriptionElement.class, desEle, def, 
pw);
 
+        printExtensibilityAttributes(desEle.getExtensionAttributes(), desEle, 
pw);
         printNamespaceDeclarations(namespaces, pw);
         pw.println('>');
-
+        printDocumentations(desEle.getDocumentationElements(), desEle, pw);
         printImports(desEle.getImportElements(), desEle, pw);
-
         printIncludes(desEle.getIncludeElements(), desEle, pw);
-
         printTypes(desEle.getTypesElement(), desEle, pw);
-
         printInterfaces(desEle.getInterfaceElements(), desEle, pw);
-
         printBindings(desEle.getBindingElements(), desEle, pw);
-
         printServices(desEle.getServiceElements(), desEle, pw);
-
-       //TODO
-       // printExtensibilityElements(Definition.class, extElements, def, pw);
-
+        printExtensibilityElements(desEle.getClass(), 
desEle.getExtensionElements(), desEle, pw);
         pw.println("</" + tagName + '>');
         pw.flush();
     }
 
+
+    /**
+     * Serialize  the namespace declarations of the  WSDL Description.
+     *
+     * @param namespaces a java.util.Map contains namespace of WSDL 
Description.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printNamespaceDeclarations(Map namespaces, PrintWriter pw)
         throws WSDLException {
 
@@ -148,25 +190,100 @@
 
     }
 
+
+    /**
+     * Serialize  the ImportElements of the  WSDL element model.
+     *
+     * @param imports an array of ImportElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printImports(ImportElement[] imports,
                                 DescriptionElement des,
                                 PrintWriter pw)
                                 throws WSDLException
     {
-            //      TODO
+        if (imports != null){
+            String tagName =
+                DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
+                           Constants.ELEM_IMPORT,
+                           des);
+            for(int ind=0;ind<imports.length;ind++){
+                ImportElement importEle = imports[ind];
+                if (importEle!=null){
+                    pw.print("  <" + tagName);
+
+                    String namespace = importEle.getNamespace().toString();
+                    if (namespace != null){
+                        DOMUtils.printAttribute(Constants.ATTR_NAMESPACE,
+                                namespace,
+                                pw);
+                    }
+                    String location = importEle.getLocation().toString();
+                    if (location != null){
+                        DOMUtils.printAttribute(Constants.ATTR_LOCATION,
+                                location,
+                                pw);
+                    }
+                    
printExtensibilityAttributes(importEle.getExtensionAttributes(), des, pw);
+                    pw.println('>');
+                    printDocumentations(importEle.getDocumentationElements(), 
des, pw);
+                    printExtensibilityElements(importEle.getClass(), 
importEle.getExtensionElements(), des, pw);
+                    pw.println("  </" + tagName + '>');
+                }
+            }
+        }
 
     }
 
-    protected void printIncludes(IncludeElement[] imports,
+    /**
+     * Serialize  the IncludeElements of the  WSDL element model.
+     *
+     * @param imports an array of IncludeElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
+    protected void printIncludes(IncludeElement[] includes,
                                  DescriptionElement des,
                                  PrintWriter pw)
                                  throws WSDLException
      {
-              //      TODO
+        if (includes != null){
+            String tagName =
+                DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
+                           Constants.ELEM_INCLUDE,
+                           des);
+            for(int ind=0;ind<includes.length;ind++){
+                IncludeElement includeEle = includes[ind];
+                if (includeEle!=null){
+                    pw.print("  <" + tagName);
+
+                    String location = includeEle.getLocation().toString();
+                    if (location != null){
+                        DOMUtils.printAttribute(Constants.ATTR_LOCATION,
+                                location,
+                                pw);
+                    }
+                    
printExtensibilityAttributes(includeEle.getExtensionAttributes(),des, pw);
+                    pw.println('>');
+                    printDocumentations(includeEle.getDocumentationElements(), 
des, pw);
+                    printExtensibilityElements(includeEle.getClass(), 
includeEle.getExtensionElements(), des, pw);
+                    pw.println("  </" + tagName + '>');
+                }
+            }
+        }
 
 
     }
 
+
+    /**
+     * Serialize  the InterfaceElements of the  WSDL element model.
+     *
+     * @param intrfaces an array of intrfacesElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printInterfaces(InterfaceElement[] intrfaces,
                                    DescriptionElement des,
                                    PrintWriter pw)
@@ -187,28 +304,53 @@
                                 name.getLocalPart(),
                                 pw);
                     }
-                    // TODO
-                    // printExtensibilityAttributes(InterfaceElement.class, 
portType, des, pw);
 
-                    pw.println('>');
+                    QName[] extendedInterfaces = 
intrface.getExtendedInterfaceNames();
+                    for(int i=0;i<extendedInterfaces.length;i++){
+                        if(extendedInterfaces[i]!=null){
+
+                            DOMUtils.printQualifiedAttribute(
+                                    Constants.ATTR_EXTENDS,
+                                    extendedInterfaces[i],
+                                    des, pw);
+                        }
+                    }
 
-                    // TODO
-                    //printDocumentation(portType.getDocumentationElement(), 
def, pw);
+                    URI[] styleDefaults = intrface.getStyleDefault();
+                    for(int i=0;i<styleDefaults.length;i++){
 
+                        URI styleDefault=styleDefaults[i];
 
-                    printOperations(intrface.getInterfaceOperationElements(), 
des, pw);
+                        if(styleDefault!=null){
+
+                            DOMUtils.printAttribute(
+                                    Constants.ATTR_STYLE_DEFAULT,
+                                    styleDefault.toString(),
+                                    pw);
+                        }
+                    }
 
-                    // TODO
-                    // printExtensibilityElements(PortType.class, extElements, 
def, pw);
 
+                    
printExtensibilityAttributes(intrface.getExtensionAttributes(), des, pw);
+                    pw.println('>');
+                    printDocumentations(intrface.getDocumentationElements(), 
des, pw);
+                    printOperations(intrface.getInterfaceOperationElements(), 
des, pw);
+                    printExtensibilityElements(intrface.getClass(), 
intrface.getExtensionElements(), des, pw);
                     pw.println("  </" + tagName + '>');
                 }
             }
         }
      }
 
+    /**
+     * Serialize  the InterfaceOperationElements of the  WSDL element model.
+     *
+     * @param operations an array of InterfaceOperationElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printOperations(InterfaceOperationElement[] operations,
-                                   DescriptionElement def,
+                                   DescriptionElement des,
                                    PrintWriter pw)
                                    throws WSDLException
      {
@@ -217,34 +359,47 @@
             String tagName =
                 DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
                           Constants.ELEM_OPERATION,
-                          def);
+                          des);
             for(int ind=0;ind<operations.length;ind++){
 
                 InterfaceOperationElement operation =operations[ind] ;
                 if (operation!=null){
 
                     pw.print("    <" + tagName);
-                    DOMUtils.printAttribute(Constants.ATTR_NAME,
-                             operation.getName().getLocalPart(),
-                             pw);
-
-                    //TODO
-                    // printExtensibilityAttributes(Operation.class, 
operation, def, pw);
-
-                    pw.println('>');
-
-                    //TODO
-                   //printDocumentation(operation.getDocumentationElement(), 
def, pw);
 
-                    
printInterfaceMessageReferenceElement(operation.getInterfaceMessageReferenceElements(),def,
 pw);
+                    QName name=operation.getName();
+                    if(name!=null){
+                        DOMUtils.printAttribute(Constants.ATTR_NAME,
+                                name.getLocalPart(),
+                                pw);
+                    }
 
+                    URI pattern=operation.getPattern();
+                    if(pattern!=null){
+                        DOMUtils.printAttribute(Constants.ATTR_PATTERN,
+                                pattern.toString(),
+                                pw);
+                    }
 
-                    
printInterfaceFaultReferenceElements(operation.getInterfaceFaultReferenceElements(),def,pw);
+                    URI[] styles=operation.getStyle();
+                    for(int i=0;i<styles.length;i++){
+                        if(styles[i]!=null){
+
+                            DOMUtils.printAttribute(
+                                    Constants.ATTR_STYLE,
+                                    styles[i].toString(),
+                                    pw);
+                        }
+                    }
 
 
-                    // TODO
-                    // printExtensibilityElements(Operation.class, 
extElements, def, pw);
 
+                    
printExtensibilityAttributes(operation.getExtensionAttributes(), des, pw);
+                    pw.println('>');
+                    printDocumentations(operation.getDocumentationElements(), 
des, pw);
+                    
printInterfaceMessageReferenceElement(operation.getInterfaceMessageReferenceElements(),des,
 pw);
+                    
printInterfaceFaultReferenceElements(operation.getInterfaceFaultReferenceElements(),des,pw);
+                    printExtensibilityElements(operation.getClass(), 
operation.getExtensionElements(), des, pw);
                     pw.println("    </" + tagName + '>');
 
                 }
@@ -258,6 +413,13 @@
 
      }
 
+    /**
+     * Serialize  the InterfaceMessageReferenceElements of the  WSDL element 
model.
+     *
+     * @param msgrefs an array of InterfaceMessageReferenceElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printInterfaceMessageReferenceElement( 
InterfaceMessageReferenceElement[] msgrefs,
             DescriptionElement des,
             PrintWriter pw)
@@ -280,32 +442,37 @@
                              des);            }
 
             pw.print("      <" + tagName);
+
             String msglable=msgRef.getMessageLabel().toString();
             DOMUtils.printAttribute(Constants.ATTR_MESSAGE_LABEL, msglable, 
pw);
-            QName attrQName=msgRef.getElementName();
-            String attrName=
-                
DOMUtils.getQualifiedValue(des.getNamespace(attrQName.getPrefix()).toString(),
-                    attrQName.getLocalPart(), des);
-            DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
-
-            // TODO
-            //printExtensibilityAttributes(Input.class, input, def, pw);
 
+            QName element=msgRef.getElementName();
+            URI ns=des.getNamespace(element.getPrefix());
+            String attrName;
+            if(ns!=null){
+                attrName=
+                    
DOMUtils.getQualifiedValue(des.getNamespace(element.getPrefix()).toString(),
+                            element.getLocalPart(), des);
+            }else{
+                attrName=element.getLocalPart();
+            }
+            DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
+            printExtensibilityAttributes(msgRef.getExtensionAttributes(), des, 
pw);
             pw.println('>');
-
-
-            // TODO
-            // printDocumentation(input.getDocumentationElement(), def, pw);
-
-
-            // TODO
-            // printExtensibilityElements(Input.class, extElements, def, pw);
-
+            printDocumentations(msgRef.getDocumentationElements(), des, pw);
+            printExtensibilityElements(msgRef.getClass(), 
msgRef.getExtensionElements(), des, pw);
             pw.println("    </" + tagName + '>');
         }
       }
     }
 
+    /**
+     * Serialize  the InterfaceFaultReferenceElements of the  WSDL element 
model.
+     *
+     * @param faulRefs an array of InterfaceFaultReferenceElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void 
printInterfaceFaultReferenceElements(InterfaceFaultReferenceElement[] faulRefs,
                                                         DescriptionElement des,
                                                         PrintWriter pw)
@@ -343,18 +510,12 @@
                           des);
                 DOMUtils.printAttribute(Constants.ATTR_ELEMENT, attrName, pw);
 
-               // TODO
-               // printExtensibilityAttributes(Input.class, input, def, pw);
-
-               pw.println('>');
-
-               // TODO
-               // printDocumentation(input.getDocumentationElement(), def, pw);
-
-              // TODO
-              //printExtensibilityElements(Input.class, extElements, def, pw);
 
-              pw.println("    </" + tagName + '>');
+                printExtensibilityAttributes(faulRef.getExtensionAttributes(), 
des, pw);
+                pw.println('>');
+                printDocumentations(faulRef.getDocumentationElements(), des, 
pw);
+                printExtensibilityElements(faulRef.getClass(), 
faulRef.getExtensionElements(), des, pw);
+                pw.println("    </" + tagName + '>');
             }
 
 
@@ -364,15 +525,22 @@
 
     }
 
+    /**
+     * Serialize  the printBindings of the  WSDL element model.
+     *
+     * @param bindings an array of printBindings.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printBindings(BindingElement[] bindings,
-                                 DescriptionElement def,
+                                 DescriptionElement des,
                                  PrintWriter pw)
                                  throws WSDLException
     {
         String tagName =
             DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
                         Constants.ELEM_BINDING,
-                        def);
+                        des);
         for(int ind=0;ind<bindings.length;ind++){
 
             BindingElement binding=bindings[ind];
@@ -389,50 +557,89 @@
                 InterfaceElement intrface = binding.getInterfaceElement();
                 if (intrface != null){
 
+
+                    QName interfaceName=intrface.getName();
+                    if(interfaceName!=null)
                     DOMUtils.printQualifiedAttribute(Constants.ATTR_INTERFACE,
-                            intrface.getName(),
-                            def,
+                            interfaceName,
+                            des,
                             pw);
+
+
+
                     DOMUtils.printAttribute(Constants.ATTR_TYPE,
                             binding.getType().toString(),
                             pw);
 
 
 
-                   // TODO write seralization to handle wsoap:protocol 
attribute
-                   // e.g. 
wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP";
+
+
+                   
printExtensibilityAttributes(binding.getExtensionAttributes(), des, pw);
                    pw.println('>');
                    printBindingOperationElements(
-                           binding.getBindingOperationElements(),def,pw);
+                           binding.getBindingOperationElements(),des,pw);
 
                 }
 
-                // TODO
-                // printDocumentation(binding.getDocumentationElement(), def, 
pw);
-
-
-                // TODO
-                // printExtensibilityElements(Binding.class, extElements, def, 
pw);
-
-
-                // 
printBindingOperationElements(binding.getBindingOperationElements(), def, pw);
-                // 
printBindingFaultElements(binding.getBindingFaultElements(), def, pw);
 
+                printDocumentations(binding.getDocumentationElements(), des, 
pw);
+                printExtensibilityElements(binding.getClass(), 
binding.getExtensionElements(), des, pw);
+                
printBindingOperationElements(binding.getBindingOperationElements(), des, pw);
+                printBindingFaultElements(binding.getBindingFaultElements(), 
des, pw);
                 pw.println("  </" + tagName + '>');
             }
         }
     }
 
+    /**
+     * Serialize  the BindingFaultElements of the  WSDL element model.
+     *
+     * @param faults an array of BindingFaultElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printBindingFaultElements(BindingFaultElement[] faults,
-                                             DescriptionElement def,
+                                             DescriptionElement des,
                                              PrintWriter pw)
                                              throws WSDLException{
-        // TODO
+        if (faults != null){
+
+            String tagName =
+                DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
+                          Constants.ELEM_FAULT,
+                          des);
+            for(int ind=0;ind<faults.length;ind++){
+
+                BindingFaultElement fault =faults[ind] ;
+                if (fault!=null){
+
+                    pw.print("    <" + tagName);
+                    DOMUtils.printQualifiedAttribute(Constants.ATTR_REF,
+                            fault.getRef(),
+                             des,
+                             pw);
+
+                    
printExtensibilityAttributes(fault.getExtensionAttributes(), des, pw);
+                    pw.println("/>");
+
+                }
+            }
+
+
+        }
 
     }
 
+    /**
+     * Serialize  the BindingOperationElements of the  WSDL element model.
+     *
+     * @param operations an array of BindingOperationElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printBindingOperationElements(BindingOperationElement[] 
operations,
-                                                 DescriptionElement def,
+                                                 DescriptionElement des,
                                                  PrintWriter pw)
                                                  throws WSDLException
      {
@@ -442,7 +649,7 @@
             String tagName =
                 DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
                           Constants.ELEM_OPERATION,
-                          def);
+                          des);
             for(int ind=0;ind<operations.length;ind++){
 
                 BindingOperationElement operation =operations[ind] ;
@@ -451,12 +658,10 @@
                     pw.print("    <" + tagName);
                     DOMUtils.printQualifiedAttribute(Constants.ATTR_REF,
                              operation.getRef(),
-                             def,
+                             des,
                              pw);
 
-                    //TODO write serialization to handle wsoap:mep attrubute
-                    // e.g. 
wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response
-
+                    
printExtensibilityAttributes(operation.getExtensionAttributes(), des, pw);
                     pw.println("/>");
 
                 }
@@ -467,15 +672,22 @@
 
      }
 
+    /**
+     * Serialize  the ServiceElements of the  WSDL element model.
+     *
+     * @param services an array of ServiceElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printServices(ServiceElement[] services,
-                                 DescriptionElement def,
+                                 DescriptionElement des,
                                  PrintWriter pw)
                                  throws WSDLException
      {
         String tagName =
             DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
                         Constants.ELEM_SERVICE,
-                        def);
+                        des);
         for(int ind=0;ind<services.length;ind++){
 
             ServiceElement service=services[ind];
@@ -488,23 +700,31 @@
                             name.getLocalPart(),
                             pw);
                 }
-                QName interName = service.getInterfaceName();
+                QName interfaceName = service.getInterfaceName();
                 if (name != null){
 
                     DOMUtils.printQualifiedAttribute(Constants.ATTR_INTERFACE,
-                            interName,def, pw);
+                            interfaceName,des, pw);
                 }
 
-                // TODO
-                // printExtensibilityAttributes(Service.class, service, def, 
pw);
 
+                printExtensibilityAttributes(service.getExtensionAttributes(), 
des, pw);
                 pw.println('>');
-
-                printEndpoint(service.getEndpointElements(), def, pw);
+                printEndpoint(service.getEndpointElements(), des, pw);
+                printDocumentations(service.getDocumentationElements(), des, 
pw);
+                
printExtensibilityElements(service.getClass(),service.getExtensionElements(), 
des, pw);
+                pw.println("    </" + tagName + '>');
             }
         }
      }
 
+    /**
+     * Serialize  the EndpointElements of the  WSDL element model.
+     *
+     * @param endpoints an array of IncludeElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printEndpoint(EndpointElement[] endpoints,
                                  DescriptionElement des,
                                  PrintWriter pw)
@@ -520,8 +740,10 @@
             if(endPoint!=null){
 
                 pw.print("    <" + tagName);
+                String name=endPoint.getName().toString();
                 DOMUtils.printAttribute(Constants.ATTR_NAME,
-                        endPoint.getName().toString(), pw);
+                        name, pw);
+
                 BindingElement binding =endPoint.getBindingElement();
                 if (binding != null){
                     DOMUtils.printQualifiedAttribute(Constants.ATTR_BINDING,
@@ -530,18 +752,31 @@
                             pw);
                 }
 
-                // TODO
-                // printExtensibilityAttributes(Port.class, port, def, pw);
+                URI address =endPoint.getAddress();
+                if (address != null){
+                    DOMUtils.printAttribute(Constants.ATTR_ADDRESS,
+                            address.toString(),
+                            pw);
+                }
+
+
+                
printExtensibilityAttributes(endPoint.getExtensionAttributes(), des, pw);
                 pw.println('>');
-                // TODO
-                // printDocumentation(endPoint.addDocumentationElement(), des, 
pw);
-                // TODO
-                // printExtensibilityElements(Endpoint.class, extElements, 
des, pw);
+                printDocumentations(endPoint.getDocumentationElements(), des, 
pw);
+                printExtensibilityElements(endPoint.getClass(), 
endPoint.getExtensionElements(), des, pw);
                 pw.println("    </" + tagName + '>');
             }
         }
       }
 
+    /**
+     * Serialize  the TypesElements of the  WSDL element model.
+     *
+     *
+     * @param types an array of TypesElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printTypes(TypesElement types,
                               DescriptionElement des,
                               PrintWriter pw)
@@ -555,7 +790,7 @@
                                            Constants.ELEM_TYPES,
                                            des);
             pw.print("<" + tagName);
-            printExtensibilityAttributes(types.getClass(), types, des, pw);
+            printExtensibilityAttributes(types.getExtensionAttributes(), des, 
pw);
             pw.println('>');
             ExtensionElement[] extElements = types.getExtensionElements();
             printExtensibilityElements(types.getClass(), extElements, des, pw);
@@ -566,7 +801,14 @@
     }
 
 
-    protected void printInlinedSchemaElements(InlinedSchema inlinedSchema[],
+    /**
+     * Serialize  the InlinedSchemas of the  WSDL element model.
+     *
+     * @param inlinedSchema an array of InlinedSchemas.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
+    protected void printInlinedSchemaElements(InlinedSchema[] inlinedSchema,
                                               DescriptionElement des,
                                               PrintWriter pw)
                                               throws WSDLException
@@ -580,7 +822,14 @@
         }
     }
 
-    protected void printImportedSchemaElements(ImportedSchema importedSchema[],
+    /**
+     * Serialize  the ImportedSchemas of the  WSDL element model.
+     *
+     * @param importedSchema an array of ImportedSchemas.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
+    protected void printImportedSchemaElements(ImportedSchema[] importedSchema,
                                                DescriptionElement des,
                                                PrintWriter pw )
                                                throws WSDLException
@@ -601,25 +850,28 @@
         }
     }
 
+    /**
+     * Serialize  the ExtensibilityElements of the  WSDL element model.
+     *
+     * @param parentType  parent class of the ExtensibilityElements.
+     * @param extensibilityElements an array of ExtensibilityElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
     protected void printExtensibilityElements(Class parentType,
                                               ExtensionElement[] 
extensibilityElements,
                                               DescriptionElement def,
                                               PrintWriter pw)
-                                              throws WSDLException
-      {
-
+                                              throws WSDLException{
         if (extensibilityElements != null){
-
             for(int ind=0;ind<extensibilityElements.length;ind++){
-
                 ExtensionElement ext =extensibilityElements[ind];
                 QName elementType = ext.getExtensionType();
                 ExtensionRegistry extReg = fWsdlContext.getExtensionRegistry();
                 if (extReg == null){
-
                     throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
                             "No ExtensionRegistry set for this " +
-                            "Definition, so unable to serialize a '" +
+                            "Description, so unable to serialize a '" +
                             elementType +
                             "' element in the context of a '" +
                             parentType.getName() + "'.");
@@ -628,82 +880,99 @@
                         elementType);
                 extSer.marshall(parentType, elementType, ext, pw, def, extReg);
             }
-        }
-      }
 
-    protected void printExtensibilityAttributes(Class parentType,
-                                                AttributeExtensible attrExt,
-                                                DescriptionElement def,
-                                                PrintWriter pw)
-                                                throws WSDLException
-    {
+        }
 
-        XMLAttr[] extensionAttributes=attrExt.getExtensionAttributes();
-        //Map extensionAttributes = attrExt.getExtensionAttributes()
-        for(int index=0;index<extensionAttributes.length;index++){
+    }
 
-            QName attrName = 
(QName)extensionAttributes[index].getAttributeType();
-            Object attrValue = extensionAttributes[index].getContent();
-            String attrStrValue = null;
-            QName attrQNameValue = null;
 
-            if (attrValue instanceof String){
 
-                attrStrValue = (String)attrValue;
+    /**
+     * Serialize  the printExtensibilityAttributess of the  WSDL element model.
+     *
+     * @param attrExts an array of XMLAttrs.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
+    protected void printExtensibilityAttributes(
+                                      XMLAttr[] attrExts,
+                                      DescriptionElement des,
+                                      PrintWriter pw)
+                                      throws WSDLException
+       {
+        if(attrExts!=null){
+            for(int index=0;index<attrExts.length;index++){
+                XMLAttr attrExt=attrExts[index];
+                if(attrExt!=null){
+                    QName ns=attrExt.getAttributeType();
+                    String attrName;
+                    String attrLocalName=ns.getLocalPart();
+                    String attrValue=attrExt.toExternalForm();
+                    if(ns!=null){
+                        String attrPrefix=ns.getPrefix();
+                        attrName=
+                            
DOMUtils.getQualifiedValue(des.getNamespace(attrPrefix).toString(),
+                                    attrLocalName, des);
+                    }else{
+                        attrName=attrLocalName;
+                    }
+                    DOMUtils.printAttribute(attrName, attrValue, pw);
+                }
             }
-            else if (attrValue instanceof QName){
 
-                attrQNameValue = (QName)attrValue;
-            }
-            else if (attrValue instanceof List){
+        }
+    }
 
-                List attrValueList = (List)attrValue;
-                int size = attrValueList.size();
-                if (size > 0){
 
-                    Object tempAttrVal = attrValueList.get(0);
-                    if (tempAttrVal instanceof String){
 
-                        //attrStrValue = 
StringUtils.getNMTokens(attrValueList);
-                    }
-                    else if (tempAttrVal instanceof QName){
-                        StringBuffer strBuf = new StringBuffer();
-                        for (int i = 0; i < size; i++){
-
-                            QName tempQName = (QName)attrValueList.get(i);
-                            strBuf.append((i > 0 ? " " : "") +
-                            
DOMUtils.getQualifiedValue(tempQName.getNamespaceURI(),
-                                             tempQName.getLocalPart(),
-                                             def));
-                        }
-                        attrStrValue = strBuf.toString();
-                    }else{
+    /**
+     * Serialize  the DocumentationElements of the  WSDL element model.
+     *
+     * @param docEles an array of DocumentationElements.
+     * @param des corresponding  DescriptionElement.
+     * @param pw the Writer to write the xml to.
+     */
+    protected void printDocumentations(DocumentationElement[] docEles,
+                                       DescriptionElement def,
+                                       PrintWriter pw)
+                                       throws WSDLException
+    {
+        if (docEles != null){
+
+            String tagName =
+                DOMUtils.getQualifiedValue(Constants.NS_URI_WSDL20,
+                          Constants.ELEM_DOCUMENTATION,
+                          def);
+            for(int ind=0;ind<docEles.length;ind++){
+                DocumentationElement docEle =docEles[ind] ;
+                if (docEle!=null){
+                    pw.print("    <" + tagName);
+
+                    // TODO
+                    //chek is documentation requred these two methods
+
+                    //printExtensibilityAttributes(Operation.class, 
docEles.get, def, pw);
+                    pw.println('>');
+
+Object o = docEle.getContent().getSource();
+org.w3c.dom.Element domEl = (org.w3c.dom.Element)o;
+String textContent = domEl.getTextContent();
+                    //String textContent=((org.w3c.dom.Element)
+                    //        
docEle.getContent().getSource()).getTextContent();
+                    pw.print(textContent);
+                  //  printExtensibilityElements(Operation.class, extElements, 
def, pw);
+                    pw.println("    </" + tagName + '>');
 
-                        throw new 
WSDLException(WSDLException.CONFIGURATION_ERROR,
-                                "Unknown type of extension attribute '" +
-                                attrName + "': " +
-                                tempAttrVal.getClass().getName());
-                    }
-                }
-                else{
-                    attrStrValue = "";
                 }
             }
-            else{
-                throw new WSDLException(WSDLException.CONFIGURATION_ERROR,
-                        "Unknown type of extension attribute '" +
-                        attrName + "': " +
-                        attrValue.getClass().getName());
-            }
-            if (attrQNameValue != null){
-                DOMUtils.printQualifiedAttribute(attrName, attrQNameValue, 
def, pw);
-            }
-            else{
-                DOMUtils.printQualifiedAttribute(attrName, attrStrValue, def, 
pw);
-            }
         }
     }
+
+
+
+
 }
+
 
 
 

Modified: 
incubator/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLWriter.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLWriter.java?rev=581066&r1=581065&r2=581066&view=diff
==============================================================================
--- 
incubator/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLWriter.java
 (original)
+++ 
incubator/woden/branches/woden65/src/org/apache/woden/internal/OMWSDLWriter.java
 Mon Oct  1 13:39:10 2007
@@ -9,7 +9,7 @@
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.woden.WSDLException;
-import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
 
 /**
  * @author Sagara Gunathunga ([EMAIL PROTECTED])
@@ -28,12 +28,12 @@
 
 
 
-    public void writeWSDL(Description wsdlDes, Writer sink)
+    public void writeWSDL(DescriptionElement wsdlDes, Writer sink)
     throws WSDLException{
 
     }
 
-    public void writeWSDL(Description wsdlDes, OutputStream sink){
+    public void writeWSDL(DescriptionElement wsdlDes, OutputStream sink){
 
     }
 }

Modified: 
incubator/woden/branches/woden65/src/org/apache/woden/internal/WriterFeatures.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/branches/woden65/src/org/apache/woden/internal/WriterFeatures.java?rev=581066&r1=581065&r2=581066&view=diff
==============================================================================
--- 
incubator/woden/branches/woden65/src/org/apache/woden/internal/WriterFeatures.java
 (original)
+++ 
incubator/woden/branches/woden65/src/org/apache/woden/internal/WriterFeatures.java
 Mon Oct  1 13:39:10 2007
@@ -1,3 +1,20 @@
+/**
+ * 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;
 
 import java.util.Hashtable;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to