cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5549] Avoiding caching the parsed content if it is not needed
Date Fri, 20 Jun 2014 15:33:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/master df94a7fe5 -> b522a8107


[CXF-5549] Avoiding caching the parsed content if it is not needed


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

Branch: refs/heads/master
Commit: b522a8107bbee369069390b3002814dccab84c6b
Parents: df94a7f
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Jun 20 16:32:58 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Jun 20 16:32:58 2014 +0100

----------------------------------------------------------------------
 .../ext/search/tika/TikaContentExtractor.java   | 23 ++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b522a810/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaContentExtractor.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaContentExtractor.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaContentExtractor.java
index 904a672..e7cb623 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaContentExtractor.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/tika/TikaContentExtractor.java
@@ -119,11 +119,10 @@ public class TikaContentExtractor {
                 }
             }
             
-            final ToTextContentHandler handler = new ToTextContentHandler();
+            final ToTextContentHandler handler = extractContent 
+                ? new ToTextContentHandler() : new IgnoreContentHandler();
             parser.parse(in, handler, metadata, context);
-            // TODO: use a content handler which will ignore parser content events 
-            String content = extractContent ? handler.toString() : ""; 
-            return new TikaContent(content, metadata);
+            return new TikaContent(handler.toString(), metadata);
         } catch (final IOException ex) {
             LOG.log(Level.WARNING, "Unable to extract media type from input stream", ex);
         } catch (final SAXException ex) {
@@ -149,4 +148,20 @@ public class TikaContentExtractor {
         }
     }
     
+    private static class IgnoreContentHandler extends ToTextContentHandler {
+        @Override
+        public void characters(char[] ch, int start, int length) throws SAXException {
+            // Complete
+        }
+        @Override
+        public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
{
+            // Complete
+        }
+        @Override
+        public String toString() {
+            return "";
+        }
+
+
+    }
 }


Mime
View raw message