cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1551501 - in /cxf/branches/2.6.x-fixes: ./ parent/ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/ rt/rs/extensions/providers/s...
Date Tue, 17 Dec 2013 10:31:58 GMT
Author: sergeyb
Date: Tue Dec 17 10:31:58 2013
New Revision: 1551501

URL: http://svn.apache.org/r1551501
Log:
Merged revisions 1551500 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1551500 | sergeyb | 2013-12-17 10:28:25 +0000 (Tue, 17 Dec 2013) | 9 lines
  
  Merged revisions 1551499 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1551499 | sergeyb | 2013-12-17 10:23:07 +0000 (Tue, 17 Dec 2013) | 1 line
    
    [CXF-5463] Update Jettion version to 1.3.5
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/parent/pom.xml
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1551500
  Merged /cxf/trunk:r1551499

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/parent/pom.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/parent/pom.xml?rev=1551501&r1=1551500&r2=1551501&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/parent/pom.xml (original)
+++ cxf/branches/2.6.x-fixes/parent/pom.xml Tue Dec 17 10:31:58 2013
@@ -121,7 +121,7 @@
         <cxf.jaxb.xjc.version>${cxf.jaxb21.xjc.version}</cxf.jaxb.xjc.version>
 
         <cxf.jdom.version>1.0</cxf.jdom.version>
-        <cxf.jettison.version>1.3.4</cxf.jettison.version>
+        <cxf.jettison.version>1.3.5</cxf.jettison.version>
         <cxf.jetty.osgi.version>[7.2,8.2)</cxf.jetty.osgi.version>
         <cxf.jetty.version>7.5.4.v20111024</cxf.jetty.version>
         <cxf.jibx.version>1.2.4.5</cxf.jibx.version>

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java?rev=1551501&r1=1551500&r2=1551501&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/JSONProvider.java
Tue Dec 17 10:31:58 2013
@@ -101,7 +101,8 @@ public class JSONProvider<T> extends Abs
     private boolean dropRootElement;
     private boolean dropElementsInXmlStream = true;
     private boolean dropCollectionWrapperElement;
-    private boolean ignoreMixedContent; 
+    private boolean ignoreMixedContent;
+    private boolean ignoreEmptyArrayValues;
     private boolean writeXsiType = true;
     private boolean readXsiType = true;
     private boolean ignoreNamespaces;
@@ -109,7 +110,6 @@ public class JSONProvider<T> extends Abs
     private TypeConverter typeConverter;
     private boolean attributesToElements;
     private boolean writeNullAsString = true;
-    private boolean readNullAsEmptyString = true;
     
     @Override
     public void setAttributesToElements(boolean value) {
@@ -278,7 +278,6 @@ public class JSONProvider<T> extends Abs
                                                   readXsiType, 
                                                   namespaceMap, 
                                                   primitiveArrayKeys,
-                                                  readNullAsEmptyString,
                                                   getDepthProperties());
         }
         reader = createTransformReaderIfNeeded(reader, is);
@@ -520,6 +519,10 @@ public class JSONProvider<T> extends Abs
         if (!writeNullAsString) {
             config.setWriteNullAsString(writeNullAsString);
         }
+        if (ignoreEmptyArrayValues) {
+            config.setIgnoreEmptyArrayValues(ignoreEmptyArrayValues);
+        }
+        
         
         boolean dropRootInJsonStream = dropRootElement && !dropElementsInXmlStream;
         if (dropRootInJsonStream) {
@@ -596,8 +599,8 @@ public class JSONProvider<T> extends Abs
         this.writeNullAsString = writeNullAsString;
     }
 
-    public void setReadNullAsEmptyString(boolean readNullAsString) {
-        this.readNullAsEmptyString = readNullAsString;
+    public void setIgnoreEmptyArrayValues(boolean ignoreEmptyArrayElements) {
+        this.ignoreEmptyArrayValues = ignoreEmptyArrayElements;
     }
 
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java?rev=1551501&r1=1551500&r2=1551501&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/json/utils/JSONUtils.java
Tue Dec 17 10:31:58 2013
@@ -137,13 +137,12 @@ public final class JSONUtils {
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
         ConcurrentHashMap<String, String> namespaceMap) throws Exception {
-        return createStreamReader(is, readXsiType, namespaceMap, null, true, null);
+        return createStreamReader(is, readXsiType, namespaceMap, null, null);
     }
     
     public static XMLStreamReader createStreamReader(InputStream is, boolean readXsiType,
         ConcurrentHashMap<String, String> namespaceMap,
         List<String> primitiveArrayKeys,
-        boolean readNullAsString,
         DocumentDepthProperties depthProps) throws Exception {
         if (readXsiType) {
             namespaceMap.putIfAbsent(XSI_URI, XSI_PREFIX);
@@ -153,9 +152,7 @@ public final class JSONUtils {
             conf.setPrimitiveArrayKeys(
                 new HashSet<String>(primitiveArrayKeys));
         }
-        if (!readNullAsString) {
-            conf.setReadNullAsEmptyString(readNullAsString);
-        }
+        
         XMLInputFactory factory = depthProps != null 
             ? new JettisonMappedReaderFactory(conf, depthProps) 
             : new MappedXMLInputFactory(conf);

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java?rev=1551501&r1=1551500&r2=1551501&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/json/JSONProviderTest.java
Tue Dec 17 10:31:58 2013
@@ -1014,6 +1014,32 @@ public class JSONProviderTest extends As
             "{\"ManyTags\":{\"tags\":{\"list\":[{\"group\":\"b\",\"name\":\"a\"}]}}}",
             s);
     }
+    
+    @Test
+    public void testManyTagsEmptyArray() throws Exception {
+        JSONProvider<ManyTags> p = new JSONProvider<ManyTags>() {
+            protected XMLStreamWriter createWriter(Object actualObject, Class<?> actualClass,

+                Type genericType, String enc, OutputStream os, boolean isCollection) throws
Exception {
+                return new EmptyListWriter(
+                    super.createWriter(actualObject, actualClass, genericType, enc, os, isCollection));
+            }
+        };
+        p.setSerializeAsArray(true);
+        p.setArrayKeys(Collections.singletonList("list"));
+        p.setIgnoreEmptyArrayValues(true);
+        Tags tags = new Tags();
+        tags.addTag(createTag("a", "b"));
+        ManyTags many = new ManyTags();
+        many.setTags(tags);
+        
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        
+        p.writeTo(many, ManyTags.class, ManyTags.class, ManyTags.class.getAnnotations(),

+                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
os);
+        
+        String s = os.toString();
+        assertEquals("{\"ManyTags\":{\"tags\":{\"list\":[]}}}", s);
+    }
 
     @Test
     public void testInDropElement() throws Exception {
@@ -1634,6 +1660,32 @@ public class JSONProviderTest extends As
         }
     }
     
+    private static class EmptyListWriter extends DelegatingXMLStreamWriter {
+        private int count;
+        public EmptyListWriter(XMLStreamWriter writer) {
+            super(writer);
+        }
+
+        public void writeCharacters(String text) throws XMLStreamException {
+        }
+        
+        public void writeStartElement(String p, String local, String uri) throws XMLStreamException
{
+            if ("group".equals(local) || "name".equals(local)) {
+                count++; 
+            } else {
+                super.writeStartElement(p, local, uri);
+            }
+        }
+        
+        public void writeEndElement() throws XMLStreamException {
+            if (count == 0) {
+                super.writeEndElement(); 
+            } else {
+                count--;
+            }
+        }
+    }
+    
     private static class NullWriter extends DelegatingXMLStreamWriter {
         public NullWriter(XMLStreamWriter writer) {
             super(writer);



Mime
View raw message