cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1491749 - in /cxf/branches/2.6.x-fixes: ./ rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
Date Tue, 11 Jun 2013 11:32:31 GMT
Author: sergeyb
Date: Tue Jun 11 11:32:31 2013
New Revision: 1491749

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

................
  r1491286 | sergeyb | 2013-06-09 21:41:06 +0100 (Sun, 09 Jun 2013) | 9 lines
  
  Merged revisions 1491283 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1491283 | sergeyb | 2013-06-09 21:31:18 +0100 (Sun, 09 Jun 2013) | 1 line
    
    Disabling the autodetection of the charset for Atom providers
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java
    cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1491286
  Merged /cxf/trunk:r1491283

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

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.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/atom/AbstractAtomProvider.java?rev=1491749&r1=1491748&r2=1491749&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java
Tue Jun 11 11:32:31 2013
@@ -35,6 +35,8 @@ import javax.ws.rs.ext.MessageBodyWriter
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Element;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.ParserOptions;
 import org.apache.abdera.writer.Writer;
 import org.apache.cxf.common.logging.LogUtils;
 
@@ -43,7 +45,7 @@ public abstract class AbstractAtomProvid
 
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractAtomProvider.class);
     private static final Abdera ATOM_ENGINE = new Abdera();
-        
+    private boolean autodetectCharset;
     private boolean formattedOutput;
     
     public long getSize(T element, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
@@ -82,7 +84,14 @@ public abstract class AbstractAtomProvid
     public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt, 
                          MultivaluedMap<String, String> headers, InputStream is) 
         throws IOException {
-        Document<T> doc = ATOM_ENGINE.getParser().parse(is);
+        Parser parser = ATOM_ENGINE.getParser();
+        synchronized (parser) {
+            ParserOptions options = parser.getDefaultParserOptions();
+            if (options != null) {
+                options.setAutodetectCharset(autodetectCharset);
+            }
+        }
+        Document<T> doc = parser.parse(is);
         return doc.getRoot();
     }
 
@@ -90,4 +99,7 @@ public abstract class AbstractAtomProvid
         this.formattedOutput = formattedOutput;
     }
 
+    public void setAutodetectCharset(boolean autodetectCharset) {
+        this.autodetectCharset = autodetectCharset;
+    }
 }

Modified: cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.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/atom/AtomPojoProvider.java?rev=1491749&r1=1491748&r2=1491749&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
Tue Jun 11 11:32:31 2013
@@ -88,6 +88,7 @@ public class AtomPojoProvider extends Ab
     private MessageContext mc;   
     private boolean formattedOutput;
     private boolean useJaxbForContent = true;
+    private boolean autodetectCharset;
     private String entryContentMethodName = DEFAULT_ENTRY_CONTENT_METHOD;
     
     public void setUseJaxbForContent(boolean use) {
@@ -601,8 +602,10 @@ public class AtomPojoProvider extends Ab
         if (isFeed) {
             return readFromFeed(cls, mt, headers, is);
         } else {
-            Entry entry = new AtomEntryProvider().readFrom(Entry.class, Entry.class, 
-                                                           new Annotation[]{}, mt, headers,
is);
+            AtomEntryProvider p = new AtomEntryProvider();
+            p.setAutodetectCharset(autodetectCharset);
+            Entry entry = p.readFrom(Entry.class, Entry.class, 
+                                     new Annotation[]{}, mt, headers, is);
             return readFromEntry(entry, cls, mt, headers, is);
         }
     }
@@ -613,6 +616,7 @@ public class AtomPojoProvider extends Ab
         throws IOException {
         
         AtomFeedProvider p = new AtomFeedProvider();
+        p.setAutodetectCharset(autodetectCharset);
         Feed feed = p.readFrom(Feed.class, Feed.class, new Annotation[]{}, mt, headers, is);
         
         AtomElementReader<?, ?> reader = getAtomReader(cls);
@@ -657,5 +661,9 @@ public class AtomPojoProvider extends Ab
         return null;
     }
 
+    public void setAutodetectCharset(boolean autodetectCharset) {
+        this.autodetectCharset = autodetectCharset;
+    }
+
     
 }



Mime
View raw message