cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Upgraded Apache Lucene to version 4.9
Date Mon, 25 Aug 2014 13:39:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 4d6fd513a -> 4aaafd7a4


CXF-5923: Create sample to demonstrate usage of search extension with Lucene and Tika. Upgraded
Apache Lucene to version 4.9


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

Branch: refs/heads/master
Commit: ffd429be404953874e141c52a9c8ba46812d73ca
Parents: 816e1a5
Author: reta <drreta@gmail.com>
Authored: Mon Aug 25 09:37:10 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Mon Aug 25 09:37:10 2014 -0400

----------------------------------------------------------------------
 .../src/main/release/samples/jax_rs/search/pom.xml   | 14 +++++++-------
 .../main/java/demo/jaxrs/search/server/Catalog.java  | 15 +++++++++------
 parent/pom.xml                                       |  2 +-
 .../lucene/AbstractLuceneQueryVisitorTest.java       |  4 ++--
 .../search/tika/TikaLuceneContentExtractorTest.java  |  4 ++--
 .../cxf/systest/jaxrs/extraction/BookCatalog.java    | 11 +++++++----
 6 files changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/distribution/src/main/release/samples/jax_rs/search/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/pom.xml b/distribution/src/main/release/samples/jax_rs/search/pom.xml
index 4f9f9c9..e69b720 100644
--- a/distribution/src/main/release/samples/jax_rs/search/pom.xml
+++ b/distribution/src/main/release/samples/jax_rs/search/pom.xml
@@ -84,38 +84,38 @@
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-transports-http</artifactId>
-            <version>3.1.0-SNAPSHOT</version>
+            <version>${cxf.version}</version>
         </dependency>
         <!-- This dependency is needed if you're using the Jetty container -->
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-transports-http-jetty</artifactId>
-            <version>3.1.0-SNAPSHOT</version>
+            <version>${cxf.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-frontend-jaxrs</artifactId>
-            <version>3.1.0-SNAPSHOT</version>
+            <version>${cxf.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-rs-extension-search</artifactId>
-            <version>3.1.0-SNAPSHOT</version>
+            <version>${cxf.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-rt-rs-extension-providers</artifactId>
-            <version>3.1.0-SNAPSHOT</version>
+            <version>${cxf.version}</version>
         </dependency>          
         <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-core</artifactId>
-            <version>4.0.0</version>
+            <version>${cxf.lucene.version}</version>
         </dependency>
          <dependency>
             <groupId>org.apache.lucene</groupId>
             <artifactId>lucene-analyzers-common</artifactId>
-            <version>4.0.0</version>
+            <version>${cxf.lucene.version}</version>
         </dependency>
         <dependency>
             <groupId>javax.json</groupId>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
index b2bb376..f66ecee 100644
--- a/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
+++ b/distribution/src/main/release/samples/jax_rs/search/src/main/java/demo/jaxrs/search/server/Catalog.java
@@ -86,8 +86,7 @@ import org.apache.tika.parser.pdf.PDFParser;
 public class Catalog {
     private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(new
PDFParser());    
     private final Directory directory = new RAMDirectory();
-    private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
-    private final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
+    private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9);    
     private final Storage storage; 
     private final ExecutorService executor = Executors.newFixedThreadPool(
         Runtime.getRuntime().availableProcessors());
@@ -122,7 +121,7 @@ public class Catalog {
 
                             final byte[] content = IOUtils.readBytesFromStream(handler.getInputStream());
                             storeAndIndex(metadata, content);
-                        } catch (final IOException ex) {
+                        } catch (final Exception ex) {
                             response.resume(Response.serverError().build());  
                         } 
                         
@@ -228,7 +227,7 @@ public class Catalog {
     
     @DELETE
     public Response delete() throws IOException {
-        final IndexWriter writer = new IndexWriter(directory, config);
+        final IndexWriter writer = getIndexWriter();
         
         try {
             storage.deleteAll();
@@ -242,7 +241,7 @@ public class Catalog {
     }
     
     private void initIndex() throws IOException {
-        final IndexWriter writer = new IndexWriter(directory, config);
+        final IndexWriter writer = getIndexWriter();
         
         try {
             writer.commit();
@@ -250,6 +249,10 @@ public class Catalog {
             writer.close();
         }
     }
+
+    private IndexWriter getIndexWriter() throws IOException {
+        return new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_4_9, analyzer));
+    }
     
     private static LuceneQueryVisitor< SearchBean > createVisitor() {
         final Map< String, Class< ? > > fieldTypes = new HashMap< String,
Class< ? > >();
@@ -281,7 +284,7 @@ public class Catalog {
             
             final Document document = extractor.extract(in, metadata);
             if (document != null) {                    
-                final IndexWriter writer = new IndexWriter(directory, config);
+                final IndexWriter writer = getIndexWriter();
                 
                 try {                                              
                     storage.addDocument(metadata.getSource(), content);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index c66b9fb..6612479 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -90,7 +90,7 @@
         <cxf.james.mim4j.version>0.7.2</cxf.james.mim4j.version>
         <cxf.logback.classic.version>1.0.13</cxf.logback.classic.version>
         <cxf.log4j.version>1.2.17</cxf.log4j.version>
-        <cxf.lucene.version>4.0.0-BETA</cxf.lucene.version>
+        <cxf.lucene.version>4.9.0</cxf.lucene.version>
         <cxf.mina.version>2.0.7</cxf.mina.version>
         <cxf.javax.annotation-api.version>1.2</cxf.javax.annotation-api.version>
         <cxf.geronimo.jms.version>1.1.1</cxf.geronimo.jms.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java
index 9d6568d..b6868b6 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/lucene/AbstractLuceneQueryVisitorTest.java
@@ -53,9 +53,9 @@ public abstract class AbstractLuceneQueryVisitorTest extends Assert {
     
     @Before
     public void setUp() throws Exception {
-        analyzer = new StandardAnalyzer(Version.LUCENE_40);
+        analyzer = new StandardAnalyzer(Version.LUCENE_4_9);
         directory = new RAMDirectory();
-        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
+        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
         IndexWriter iwriter = new IndexWriter(directory, config);
         
         Document doc = new Document();

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
index 553fcf8..b37b1b8 100644
--- a/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
+++ b/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/tika/TikaLuceneContentExtractorTest.java
@@ -54,10 +54,10 @@ public class TikaLuceneContentExtractorTest extends Assert {
     
     @Before
     public void setUp() throws Exception {
-        final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
+        final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9);
         directory = new RAMDirectory();
         
-        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
+        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_9, analyzer);
         writer = new IndexWriter(directory, config);    
         writer.commit();
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/ffd429be/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
index 343efce..c1c0abd 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
@@ -63,8 +63,7 @@ import org.apache.tika.parser.pdf.PDFParser;
 public class BookCatalog {
     private final TikaLuceneContentExtractor extractor = new TikaLuceneContentExtractor(new
PDFParser());    
     private final Directory directory = new RAMDirectory();
-    private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
-    private final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
+    private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_4_9);    
     private final LuceneQueryVisitor<SearchBean> visitor = createVisitor();
     
     @POST
@@ -81,7 +80,7 @@ public class BookCatalog {
                 
                 final Document document = extractor.extract(handler.getInputStream(), metadata);
                 if (document != null) {                    
-                    final IndexWriter writer = new IndexWriter(directory, config);
+                    final IndexWriter writer = getIndexWriter();
                     
                     try {
                         writer.addDocument(document);
@@ -112,7 +111,7 @@ public class BookCatalog {
     
     @DELETE
     public Response delete() throws IOException {
-        final IndexWriter writer = new IndexWriter(directory, config);
+        final IndexWriter writer = getIndexWriter();
         
         try {
             writer.deleteAll();
@@ -124,6 +123,10 @@ public class BookCatalog {
         return Response.ok().build();
     }
     
+    private IndexWriter getIndexWriter() throws IOException {
+        return new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_4_9, analyzer));
+    }
+    
     private static LuceneQueryVisitor< SearchBean > createVisitor() {
         final Map< String, Class< ? > > fieldTypes = new HashMap< String,
Class< ? > >();
         fieldTypes.put("modified", Date.class);


Mime
View raw message