You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2012/09/11 20:53:56 UTC

svn commit: r1383538 - in /cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/provider/ test/java/org/apache/cxf/jaxrs/provider/

Author: dkulp
Date: Tue Sep 11 18:53:56 2012
New Revision: 1383538

URL: http://svn.apache.org/viewvc?rev=1383538&view=rev
Log:
Merged revisions 1383118 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1383118 | sergeyb | 2012-09-10 17:39:42 -0400 (Mon, 10 Sep 2012) | 13 lines

  Merged revisions 1382763,1382965 via svnmerge from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1382763 | sergeyb | 2012-09-10 12:36:25 +0100 (Mon, 10 Sep 2012) | 1 line

    Updating DataSourceProvider to ignore DataSource content type property by default
  ........
    r1382965 | sergeyb | 2012-09-10 17:18:15 +0100 (Mon, 10 Sep 2012) | 1 line

    Restricting XSLTJaxbProvider to support single beans only
  ........

........

Modified:
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java?rev=1383538&r1=1383537&r2=1383538&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java Tue Sep 11 18:53:56 2012
@@ -40,6 +40,8 @@ import org.apache.cxf.jaxrs.ext.multipar
 @Provider
 public class DataSourceProvider implements MessageBodyReader, MessageBodyWriter {
     
+    private boolean useDataSourceContentType;
+    
     public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mt) {
         return isSupported(type, mt);
     }
@@ -70,7 +72,9 @@ public class DataSourceProvider implemen
         throws IOException {
         DataSource ds = DataSource.class.isAssignableFrom(cls) 
             ? (DataSource)src : ((DataHandler)src).getDataSource();
-        setContentTypeIfNeeded(type, headers, ds.getContentType());
+        if (useDataSourceContentType) {    
+            setContentTypeIfNeeded(type, headers, ds.getContentType());
+        }
         IOUtils.copy(ds.getInputStream(), os);
     }
     
@@ -80,6 +84,10 @@ public class DataSourceProvider implemen
             headers.putSingle("Content-Type", ct);
         }
     }
+
+    public void setUseDataSourceContentType(boolean useDataSourceContentType) {
+        this.useDataSourceContentType = useDataSourceContentType;
+    }
     
 
 }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java?rev=1383538&r1=1383537&r2=1383538&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java Tue Sep 11 18:53:56 2012
@@ -63,6 +63,7 @@ import org.xml.sax.XMLFilter;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.staxutils.StaxSource;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -101,6 +102,9 @@ public class XSLTJaxbProvider extends JA
     
     @Override
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) {
+        if (InjectionUtils.isSupportedCollectionOrArray(type)) {
+            return false;
+        }
         // JAXB support is required
         if (!super.isReadable(type, genericType, anns, mt)) {
             return false;
@@ -116,6 +120,9 @@ public class XSLTJaxbProvider extends JA
     
     @Override
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) {
+        if (InjectionUtils.isSupportedCollectionOrArray(type)) {
+            return false;
+        }
         // JAXB support is required
         if (!super.isReadable(type, genericType, anns, mt)) {
             return false;

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java?rev=1383538&r1=1383537&r2=1383538&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java (original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java Tue Sep 11 18:53:56 2012
@@ -88,12 +88,13 @@ public class DataSourceProviderTest exte
     @Test
     public void testWriteDataSourceWithDiffCT() throws Exception {
         DataSourceProvider p = new DataSourceProvider();
+        p.setUseDataSourceContentType(true);
         DataSource ds = new InputStreamDataSource(new ByteArrayInputStream("image".getBytes()), 
                                                   "image/png"); 
         ByteArrayOutputStream os = new ByteArrayOutputStream();
         MultivaluedMap<String, Object> outHeaders = new MetadataMap<String, Object>();
         p.writeTo(ds, DataSource.class, DataSource.class, new Annotation[]{}, 
-                   MediaType.valueOf("image/bar"), outHeaders, os);
+                   MediaType.valueOf("image/jpeg"), outHeaders, os);
         assertEquals("image", os.toString());
         assertEquals("image/png", outHeaders.getFirst("Content-Type"));
     }