Author: shameera
Date: Sun Mar 16 16:43:06 2014
New Revision: 1578111
URL: http://svn.apache.org/r1578111
Log:
Improved XML Stream based JSON to generate intermediate structure when schema
has ref elements and added a new test case too
Added:
axis/axis2/java/core/trunk/modules/json/test-resources/custom_schema/testSchema_3.xsd
Modified:
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java
axis/axis2/java/core/trunk/modules/json/test-resources/custom_schema/testSchema_2.xsd
axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/gson/factory/XmlNodeGeneratorTest.java
Modified:
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java?rev=1578111&r1=1578110&r2=1578111&view=diff
==
---
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
(original)
+++
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamReader.java
Sun Mar 16 16:43:06 2014
@@ -21,6 +21,7 @@ package org.apache.axis2.json.gson;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.json.gson.factory.JSONType;
import org.apache.axis2.json.gson.factory.JsonConstant;
@@ -87,7 +88,7 @@ public class GsonXMLStreamReader impleme
}
public GsonXMLStreamReader(JsonReader jsonReader, QName elementQname,
List xmlSchemaList,
- ConfigurationContext configContext) {
+ ConfigurationContext configContext) throws
AxisFault {
this.jsonReader = jsonReader;
initXmlStreamReader(elementQname, xmlSchemaList, configContext);
}
@@ -96,16 +97,20 @@ public class GsonXMLStreamReader impleme
return jsonReader;
}
-public void initXmlStreamReader(QName elementQname, List
xmlSchemaList, ConfigurationContext configContext) {
+public void initXmlStreamReader(QName elementQname, List
xmlSchemaList, ConfigurationContext configContext) throws AxisFault {
this.elementQname = elementQname;
this.xmlSchemaList = xmlSchemaList;
this.configContext = configContext;
-process();
+try {
+process();
+} catch (AxisFault axisFault) {
+throw new AxisFault("Error while initializing XMLStreamReader ",
axisFault);
+}
isProcessed = true;
}
-private void process() {
+private void process() throws AxisFault {
Object ob = configContext.getProperty(JsonConstant.XMLNODES);
if (ob != null) {
Map nodeMap = (Map) ob;
Modified:
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java?rev=1578111&r1=1578110&r2=1578111&view=diff
==
---
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
(original)
+++
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java
Sun Mar 16 16:43:06 2014
@@ -653,9 +653,11 @@ public class GsonXMLStreamWriter impleme
public void writeStartDocument(String encoding, String version) throws
XMLStreamException {
if (!isProcessed) {
-xmlNodeGenerator.getMainXmlNode();
-queue = xmlNodeGenerator.getQueue(mainXmlNode);
-isProcessed = true;
+try {
+process();
+} catch (IOException e) {
+throw new XMLStreamException("Error occur while trying to
write start document element", e);
+}
}
}
@@ -672,7 +674,7 @@ public class GsonXMLStreamWriter impleme
try {
process();
} catch (IOException e) {
-throw new XMLStreamException("Error occur while trying to
write first begin object ");
+throw new XMLStreamException("Error occur while trying to
write first begin object ", e);
}
}
try {
Modified:
axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/gson/factory/XmlNodeGenerator.java?rev=1