cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/3] cxf git commit: Update SourceProvider to be able to write out any Nodes and not just Documents
Date Fri, 05 Feb 2016 20:39:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/master af11d1bff -> f8834cf0d


Update SourceProvider to be able to write out any Nodes and not just Documents


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/f8834cf0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/f8834cf0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/f8834cf0

Branch: refs/heads/master
Commit: f8834cf0d4397e0f6acab078b96fe1a228c42d02
Parents: 72821c7
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Fri Feb 5 17:53:39 2016 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Fri Feb 5 17:54:04 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/provider/SourceProvider.java    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f8834cf0/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
index 52bf495..20e29d0 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
@@ -44,7 +44,7 @@ import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
-
+import org.w3c.dom.Node;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.ext.MessageContext;
@@ -72,7 +72,7 @@ public class SourceProvider<T> extends AbstractConfigurableProvider
implements
     
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return Source.class.isAssignableFrom(type)
-            || Document.class.isAssignableFrom(type);
+            || Node.class.isAssignableFrom(type);
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
@@ -189,9 +189,14 @@ public class SourceProvider<T> extends AbstractConfigurableProvider
implements
         
         String encoding = HttpUtils.getSetEncoding(mt, headers, StandardCharsets.UTF_8.name());
         
-        XMLStreamReader reader = 
-            source instanceof Source ? StaxUtils.createXMLStreamReader((Source)source) 
-                    : StaxUtils.createXMLStreamReader((Document)source);
+        XMLStreamReader reader = null;
+        if (source instanceof Source) {
+            reader = StaxUtils.createXMLStreamReader((Source)source);
+        } else if (source instanceof Document) {
+            reader = StaxUtils.createXMLStreamReader((Document)source);
+        } else {
+            reader = StaxUtils.createXMLStreamReader(new DOMSource((Node)source));
+        }
         XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(os, encoding);
         try {
             StaxUtils.copy(reader, writer);


Mime
View raw message