axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r1378528 - in /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl: GsonXMLStreamReader.java utils/JsonUtils.java utils/XmlNodeGenerator.java
Date Wed, 29 Aug 2012 13:04:09 GMT
Author: amilas
Date: Wed Aug 29 13:04:09 2012
New Revision: 1378528

URL: http://svn.apache.org/viewvc?rev=1378528&view=rev
Log:
applying patches for AXIS2-5404,AXIS2-5403,AXIS2-5402

Modified:
    axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/GsonXMLStreamReader.java
    axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
    axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/XmlNodeGenerator.java

Modified: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/GsonXMLStreamReader.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/GsonXMLStreamReader.java?rev=1378528&r1=1378527&r2=1378528&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/GsonXMLStreamReader.java
(original)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/GsonXMLStreamReader.java
Wed Aug 29 13:04:09 2012
@@ -82,11 +82,6 @@ public class GsonXMLStreamReader impleme
     private String namespace;
 
 
-    // Default namespace
-    final static private String DEFAULT_NAMESPACE = "http://axis2.apache.org/axis/json";
-
-    final static private String DEFAULT_NAMESPACE_PREFIX = "ns";
-
     public GsonXMLStreamReader(JsonReader jsonReader) {
         this.jsonReader = jsonReader;
     }
@@ -653,7 +648,7 @@ public class GsonXMLStreamReader impleme
                 namespace = jsonObj.getNamespaceUri();
                 stackObj.push(miniStack.pop());
             } else {
-                throw new XMLStreamException(JsonConstant.IN_JSON_MESSAGE_NOT_VALID + "required
: " + jsonObj.getName() + " but get : " + name);
+                throw new XMLStreamException(JsonConstant.IN_JSON_MESSAGE_NOT_VALID + "expected
: " + jsonObj.getName() + " but found : " + name);
             }
         } else if (!queue.isEmpty()) {
             JsonObject jsonObj = queue.peek();
@@ -661,7 +656,7 @@ public class GsonXMLStreamReader impleme
                 namespace = jsonObj.getNamespaceUri();
                 stackObj.push(queue.poll());
             } else {
-                throw new XMLStreamException(JsonConstant.IN_JSON_MESSAGE_NOT_VALID + "required
: " + jsonObj.getName() + " but get : " + name);
+                throw new XMLStreamException(JsonConstant.IN_JSON_MESSAGE_NOT_VALID + "expected
: " + jsonObj.getName() + " but found : " + name);
             }
         } else {
             throw new XMLStreamException(JsonConstant.IN_JSON_MESSAGE_NOT_VALID);
@@ -692,6 +687,7 @@ public class GsonXMLStreamReader impleme
                     value = String.valueOf(jsonReader.nextDouble());
                 }
             } else if (tokenType == JsonToken.NULL) {
+                jsonReader.nextNull();
                 value = null;
             } else {
                 log.error("Couldn't read the value, Illegal state exception");

Modified: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java?rev=1378528&r1=1378527&r2=1378528&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
(original)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/JsonUtils.java
Wed Aug 29 13:04:09 2012
@@ -46,21 +46,19 @@ public class JsonUtils {
             jsonReader.setLenient(true);
         }
         jsonReader.beginObject();
-        String requestMethodName=jsonReader.nextName();     // get request method name from
input json stream
-        if (paramCount > 1) {
-            jsonReader.beginArray();
-        }
+        String messageName=jsonReader.nextName();     // get message name from input json
stream
+        jsonReader.beginArray();
+
         int i = 0;
         for (Class paramType : paramClasses) {
             jsonReader.beginObject();
             argNames[i] = jsonReader.nextName();
-            methodParam[i] = gson.fromJson(jsonReader, paramType);   // gson handle all types
well and retuen an object from it
+            methodParam[i] = gson.fromJson(jsonReader, paramType);   // gson handle all types
well and return an object from it
             jsonReader.endObject();
             i++;
         }
-        if (paramCount > 1) {
-            jsonReader.endArray();
-        }
+
+        jsonReader.endArray();
         jsonReader.endObject();
 
         return  operation.invoke(service, methodParam);

Modified: axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/XmlNodeGenerator.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/XmlNodeGenerator.java?rev=1378528&r1=1378527&r2=1378528&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/XmlNodeGenerator.java
(original)
+++ axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/impl/utils/XmlNodeGenerator.java
Wed Aug 29 13:04:09 2012
@@ -57,56 +57,58 @@ public class XmlNodeGenerator {
     private void processSchemaList() {
         // get the operation schema and process.
         XmlSchema operationSchema = getXmlSchema(elementQname);
-        XmlSchemaElement methodElement = operationSchema.getElementByName(elementQname.getLocalPart());
-        mainXmlNode = new XmlNode(elementQname.getLocalPart(), elementQname.getNamespaceURI()
, false, (methodElement.getMaxOccurs() == 1 ? false : true) , "");
-        QName methodSchemaTypeName = methodElement.getSchemaTypeName();
+        XmlSchemaElement messageElement = operationSchema.getElementByName(elementQname.getLocalPart());
+        mainXmlNode = new XmlNode(elementQname.getLocalPart(), elementQname.getNamespaceURI()
, false, (messageElement.getMaxOccurs() == 1 ? false : true) , "");
+
+        QName messageSchemaTypeName = messageElement.getSchemaTypeName();
         XmlSchemaType schemaType = null;
-        if (methodSchemaTypeName != null){
-            schemaType = getXmlSchema(methodSchemaTypeName).getTypeByName(methodSchemaTypeName.getLocalPart());
+        XmlSchema schemaOfType = null;
+        if (messageSchemaTypeName != null) {
+            schemaType = operationSchema.getTypeByName(messageSchemaTypeName);
+            if (schemaType == null) {
+                schemaOfType = getXmlSchema(messageSchemaTypeName);
+                schemaType = schemaOfType.getTypeByName(messageSchemaTypeName.getLocalPart());
+            } else {
+                schemaOfType = operationSchema;
+            }
         } else {
-            schemaType = methodElement.getSchemaType();
+            schemaType = messageElement.getSchemaType();
+            schemaOfType = operationSchema;
         }
 
         if (schemaType != null) {
-            processSchemaType(schemaType, mainXmlNode , operationSchema);
+            processSchemaType(schemaType, mainXmlNode, schemaOfType);
         } else {
             // nothing to do
         }
     }
 
     private void processElement(XmlSchemaElement element, XmlNode parentNode , XmlSchema
schema) {
+        String targetNamespace = schema.getTargetNamespace();
+        XmlNode xmlNode;
         QName schemaTypeName = element.getSchemaTypeName();
-        QName qName = element.getQName();
-        String pref = schemaTypeName.getPrefix();
-        XmlNode tempNode;
-        if (qName == null) {
-            tempNode = new XmlNode(element.getName(), parentNode.getNamespaceUri(), false,
(element.getMaxOccurs() == 1 ? false : true), schemaTypeName.getLocalPart());
-
-        } else {
-            tempNode = new XmlNode(qName.getLocalPart(), qName.getNamespaceURI(), false,
(element.getMaxOccurs() == 1 ? false : true), schemaTypeName.getLocalPart());
-        }
-        parentNode.addChildtoList(tempNode);
-        if (("xs").equals(pref)) {
-            // this element doesn't has child elements
-        } else {
-            XmlSchema childSchema = null;
-            XmlSchemaElement childEle = schema.getElementByName(schemaTypeName);
-            XmlSchemaType childType = schema.getTypeByName(schemaTypeName);
-            if (childEle == null && childType == null) {
-                childSchema = getXmlSchema(schemaTypeName);
-                childEle = childSchema.getElementByName(schemaTypeName);
-                childType = childSchema.getTypeByName(schemaTypeName);
-            } else {
-                childSchema = schema;
-            }
-
-            if (childEle == null) {
-                processSchemaType(childType, tempNode, childSchema);
+        XmlSchemaType schemaType = element.getSchemaType();
+        if (schemaTypeName != null) {
+            xmlNode = new XmlNode(element.getName(), targetNamespace, false, (element.getMaxOccurs()
== 1 ? false : true), schemaTypeName.getLocalPart());
+            parentNode.addChildtoList(xmlNode);
+            if (("http://www.w3.org/2001/XMLSchema").equals(schemaTypeName.getNamespaceURI()))
{
             } else {
-                processElement(childEle, tempNode, childSchema);
+                XmlSchema schemaOfType;
+                // see whether Schema type is in the same schema
+                XmlSchemaType childSchemaType = schema.getTypeByName(schemaTypeName.getLocalPart());
+                if (childSchemaType == null) {
+                    schemaOfType = getXmlSchema(schemaTypeName);
+                    childSchemaType = schemaOfType.getTypeByName(schemaTypeName.getLocalPart());
+                }else{
+                    schemaOfType = schema;
+                }
+                processSchemaType(childSchemaType, xmlNode, schemaOfType);
             }
+        }else if (schemaType != null) {
+            xmlNode = new XmlNode(element.getName(), targetNamespace, false, (element.getMaxOccurs()
== 1 ? false : true), schemaType.getQName().getLocalPart());
+            parentNode.addChildtoList(xmlNode);
+            processSchemaType(schemaType, xmlNode, schema);
         }
-
     }
 
 
@@ -122,9 +124,6 @@ public class XmlNodeGenerator {
                     Object obj = objectIterator.next();
                     if (obj instanceof XmlSchemaElement) {
                         processElement((XmlSchemaElement)obj , parentNode , schema);
-                    }else if (obj instanceof XmlSchemaComplexType || obj instanceof  XmlSchemaSimpleType)
{     // never come to this
-                        XmlSchemaType schemaType = (XmlSchemaType)obj;
-                        processSchemaType(schemaType , parentNode , schema);
                     }
                 }
             }



Mime
View raw message