cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1492135 - in /cxf/branches/2.5.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
Date Wed, 12 Jun 2013 10:30:08 GMT
Author: sergeyb
Date: Wed Jun 12 10:30:07 2013
New Revision: 1492135

URL: http://svn.apache.org/r1492135
Log:
Merged revisions 1491749 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1491749 | sergeyb | 2013-06-11 12:32:31 +0100 (Tue, 11 Jun 2013) | 16 lines
  
  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.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
    cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java

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

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

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java?rev=1492135&r1=1492134&r2=1492135&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
Wed Jun 12 10:30:07 2013
@@ -33,13 +33,16 @@ 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;
 
 public abstract class AbstractAtomProvider<T extends Element> 
     implements MessageBodyWriter<T>, MessageBodyReader<T> {
 
     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) {
@@ -63,12 +66,23 @@ 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();
     }
 
     public void setFormattedOutput(boolean formattedOutput) {
         this.formattedOutput = formattedOutput;
     }
+    
+    public void setAutodetectCharset(boolean autodetectCharset) {
+        this.autodetectCharset = autodetectCharset;
+    }
 
 }

Modified: cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java?rev=1492135&r1=1492134&r2=1492135&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
Wed Jun 12 10:30:07 2013
@@ -83,6 +83,7 @@ public class AtomPojoProvider extends Ab
     
     private MessageContext mc;   
     private boolean formattedOutput;
+    private boolean autodetectCharset;
     
     @Context
     public void setMessageContext(MessageContext context) {
@@ -467,8 +468,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);
         }
     }
@@ -479,6 +482,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 = atomReaders.get(cls.getName());
@@ -522,5 +526,7 @@ public class AtomPojoProvider extends Ab
         return null;
     }
 
-    
+    public void setAutodetectCharset(boolean autodetectCharset) {
+        this.autodetectCharset = autodetectCharset;
+    }
 }



Mime
View raw message