]> source.dussan.org Git - archiva.git/commitdiff
[MRM-715] switch to IndexWriter since IndexModifier is deprecated in 2.3.1
authorBrett Porter <brett@apache.org>
Mon, 3 Mar 2008 00:38:40 +0000 (00:38 +0000)
committerBrett Porter <brett@apache.org>
Mon, 3 Mar 2008 00:38:40 +0000 (00:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@632892 13f79535-47bb-0310-9956-ffa450edef68

archiva-1.0.x/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java

index 469418cdfb3d72b727debc00a3ce7ee4d414f818..8e79138e84e10481de50959766fa05321798b3bb 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.maven.archiva.indexer.lucene;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexModifier;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
@@ -86,11 +85,11 @@ public class LuceneRepositoryContentIndex
     {
         synchronized( repository )
         {
-            IndexModifier indexModifier = null;
+            IndexWriter indexWriter = null;
             try
             {
-                indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
-                indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
+                indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() );
+                indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH );
     
                 for ( Iterator i = records.iterator(); i.hasNext(); )
                 {
@@ -100,14 +99,14 @@ public class LuceneRepositoryContentIndex
                     {
                         Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
     
-                        indexModifier.deleteDocuments( term );
+                        indexWriter.deleteDocuments( term );
     
                         Document document = indexHandlers.getConverter().convert( record );
     
-                        indexModifier.addDocument( document );
+                        indexWriter.addDocument( document );
                     }
                 }
-                indexModifier.optimize();
+                indexWriter.optimize();
             }
             catch ( IOException e )
             {
@@ -115,7 +114,7 @@ public class LuceneRepositoryContentIndex
             }
             finally
             {
-                closeQuietly( indexModifier );
+                closeQuietly( indexWriter );
             }
         }
     }
@@ -125,23 +124,23 @@ public class LuceneRepositoryContentIndex
     {
         synchronized( repository )
         {
-            IndexModifier indexModifier = null;
+            IndexWriter indexWriter = null;
             try
             {
-                indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() );
-                indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH );
+                indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() );
+                indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH );
     
                 if ( record != null )
                 {
                     Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() );
     
-                    indexModifier.deleteDocuments( term );
+                    indexWriter.deleteDocuments( term );
     
                     Document document = indexHandlers.getConverter().convert( record );
     
-                    indexModifier.addDocument( document );
+                    indexWriter.addDocument( document );
                 }
-                indexModifier.optimize();
+                indexWriter.optimize();
             }
             catch ( IOException e )
             {
@@ -149,7 +148,7 @@ public class LuceneRepositoryContentIndex
             }
             finally
             {
-                closeQuietly( indexModifier );
+                closeQuietly( indexWriter );
             }
         }
     }
@@ -407,21 +406,6 @@ public class LuceneRepositoryContentIndex
         }
     }
 
-    private static void closeQuietly( IndexModifier indexModifier )
-    {
-        if ( indexModifier != null )
-        {
-            try
-            {
-                indexModifier.close();
-            }
-            catch ( IOException e )
-            {
-                // ignore
-            }
-        }
-    }
-
     private static void closeQuietly( IndexReader reader )
     {
         try