From: Brett Porter Date: Mon, 3 Mar 2008 00:38:40 +0000 (+0000) Subject: [MRM-715] switch to IndexWriter since IndexModifier is deprecated in 2.3.1 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8cf5f9555ce997a3e796a2f607a7bd9d6009095a;p=archiva.git [MRM-715] switch to IndexWriter since IndexModifier is deprecated in 2.3.1 git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@632892 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-1.0.x/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java b/archiva-1.0.x/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java index 469418cdf..8e79138e8 100644 --- a/archiva-1.0.x/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java +++ b/archiva-1.0.x/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java @@ -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