cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1383118 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/
Date Mon, 10 Sep 2012 21:39:42 GMT
Author: sergeyb
Date: Mon Sep 10 21:39:42 2012
New Revision: 1383118

URL: http://svn.apache.org/viewvc?rev=1383118&view=rev
Log:
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.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1382763,1382965

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

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java?rev=1383118&r1=1383117&r2=1383118&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataSourceProvider.java
Mon Sep 10 21:39:42 2012
@@ -40,6 +40,8 @@ import org.apache.cxf.jaxrs.ext.multipar
 @Provider
 public class DataSourceProvider<T> implements MessageBodyReader<T>, MessageBodyWriter<T>
{
     
+    private boolean useDataSourceContentType;
+    
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return isSupported(type, mt);
     }
@@ -71,7 +73,9 @@ public class DataSourceProvider<T> imple
         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);
     }
     
@@ -82,6 +86,10 @@ public class DataSourceProvider<T> imple
             headers.putSingle("Content-Type", ct);
         }
     }
+
+    public void setUseDataSourceContentType(boolean useDataSourceContentType) {
+        this.useDataSourceContentType = useDataSourceContentType;
+    }
     
 
 }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java?rev=1383118&r1=1383117&r2=1383118&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
Mon Sep 10 21:39:42 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<T> extends
     
     @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<T> extends
     
     @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.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java?rev=1383118&r1=1383117&r2=1383118&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataSourceProviderTest.java
Mon Sep 10 21:39:42 2012
@@ -88,12 +88,13 @@ public class DataSourceProviderTest exte
     @Test
     public void testWriteDataSourceWithDiffCT() throws Exception {
         DataSourceProvider<DataSource> p = new DataSourceProvider<DataSource>();
+        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"));
     }



Mime
View raw message