maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csta...@apache.org
Subject svn commit: r1410262 - in /maven/indexer/trunk/indexer-core/src: main/java/org/apache/maven/index/ main/java/org/apache/maven/index/archetype/ main/java/org/apache/maven/index/context/ main/java/org/apache/maven/index/treeview/ test/java/org/apache/mav...
Date Fri, 16 Nov 2012 09:11:14 GMT
Author: cstamas
Date: Fri Nov 16 09:11:10 2012
New Revision: 1410262

URL: http://svn.apache.org/viewvc?rev=1410262&view=rev
Log:
MINDEXER-67: Introducing Indexer component

And deprecating NexusIndexer, making it delegate to new
Indexer component and remain backward compatible.

Users of deprecated NexusIndexer component will see
exactly same behaviour, while new users of Indexer
will gain full control for context manipulation.

Added:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Indexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/IndexerScanRequest.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/AbstractArchetypeDataSource.java
      - copied, changed from r1410255, maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/ExistingLuceneIndexMismatchException.java
      - copied, changed from r1410255, maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java
Modified:
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Grouping.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java
    maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/treeview/DefaultIndexTreeView.java
    maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/FullBootProofOfConcept.java

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java Fri Nov 16 09:11:10 2012
@@ -48,7 +48,7 @@ import org.codehaus.plexus.util.xml.pull
  * {@link IndexCreator}, which can populate {@link ArtifactInfo} for the given artifact.
  * 
  * @see IndexCreator#populateArtifactInfo(ArtifactContext)
- * @see NexusIndexer#scan(IndexingContext)
+ * @see Indexer#scan(IndexingContext)
  * @author Jason van Zyl
  * @author Tamas Cservenak
  */

Added: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java?rev=1410262&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java (added)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java Fri Nov 16 09:11:10 2012
@@ -0,0 +1,341 @@
+package org.apache.maven.index;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0    
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.maven.index.context.ContextMemberProvider;
+import org.apache.maven.index.context.DefaultIndexingContext;
+import org.apache.maven.index.context.ExistingLuceneIndexMismatchException;
+import org.apache.maven.index.context.IndexCreator;
+import org.apache.maven.index.context.IndexUtils;
+import org.apache.maven.index.context.IndexingContext;
+import org.apache.maven.index.context.MergedIndexingContext;
+import org.apache.maven.index.expr.SearchExpression;
+import org.apache.maven.index.expr.SourcedSearchExpression;
+import org.apache.maven.index.util.IndexCreatorSorter;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * A default {@link Indexer} implementation.
+ * 
+ * @author Tamas Cservenak
+ */
+@Component( role = Indexer.class )
+public class DefaultIndexer
+    extends AbstractLogEnabled
+    implements Indexer
+{
+    @Requirement
+    private Scanner scanner;
+
+    @Requirement
+    private SearchEngine searcher;
+
+    @Requirement
+    private IndexerEngine indexerEngine;
+
+    @Requirement
+    private QueryCreator queryCreator;
+
+    // ----------------------------------------------------------------------------
+    // Contexts
+    // ----------------------------------------------------------------------------
+
+    public IndexingContext createIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
+                                                  String repositoryUrl, String indexUpdateUrl, boolean searchable,
+                                                  boolean reclaim, List<? extends IndexCreator> indexers )
+        throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException
+    {
+        final IndexingContext context =
+            new DefaultIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
+                IndexCreatorSorter.sort( indexers ), reclaim );
+        context.setSearchable( searchable );
+        return context;
+    }
+
+    public IndexingContext createMergedIndexingContext( String id, String repositoryId, File repository,
+                                                        File indexDirectory, boolean searchable,
+                                                        ContextMemberProvider membersProvider )
+        throws IOException
+    {
+        IndexingContext context =
+            new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
+        return context;
+    }
+
+    public void closeIndexingContext( IndexingContext context, boolean deleteFiles )
+        throws IOException
+    {
+        context.close( deleteFiles );
+    }
+
+    // ----------------------------------------------------------------------------
+    // Scanning
+    // ----------------------------------------------------------------------------
+
+    public void scan( final IndexerScanRequest indexerScanRequest )
+        throws IOException
+    {
+        final IndexingContext context = indexerScanRequest.getIndexingContext();
+        final File repositoryDirectory = context.getRepository();
+        if ( repositoryDirectory == null )
+        {
+            // nothing to scan
+            return;
+        }
+
+        if ( !repositoryDirectory.exists() )
+        {
+            throw new IOException( "Repository directory " + repositoryDirectory + " does not exist" );
+        }
+
+        // always use temporary context when reindexing
+        final File tmpFile = File.createTempFile( context.getId() + "-tmp", "" );
+        final File tmpDir = new File( tmpFile.getParentFile(), tmpFile.getName() + ".dir" );
+        if ( !tmpDir.mkdirs() )
+        {
+            throw new IOException( "Cannot create temporary directory: " + tmpDir );
+        }
+
+        IndexingContext tmpContext = null;
+        try
+        {
+            final FSDirectory directory = FSDirectory.open( tmpDir );
+            if ( indexerScanRequest.isUpdate() )
+            {
+                IndexUtils.copyDirectory( context.getIndexDirectory(), directory );
+            }
+            tmpContext = new DefaultIndexingContext( context.getId() + "-tmp", //
+                context.getRepositoryId(), //
+                context.getRepository(), //
+                directory, //
+                context.getRepositoryUrl(), //
+                context.getIndexUpdateUrl(), //
+                context.getIndexCreators(), //
+                true );
+
+            scanner.scan( new ScanningRequest( tmpContext, //
+                new DefaultScannerListener( tmpContext, indexerEngine, indexerScanRequest.isUpdate(),
+                    indexerScanRequest.getArtifactScanningListener() ), indexerScanRequest.getStartingPath() ) );
+
+            tmpContext.updateTimestamp( true );
+            context.replace( tmpContext.getIndexDirectory() );
+        }
+        catch ( Exception ex )
+        {
+            throw (IOException) new IOException( "Error scanning context " + context.getId() + ": " + ex ).initCause( ex );
+        }
+        finally
+        {
+            if ( tmpContext != null )
+            {
+                tmpContext.close( true );
+            }
+
+            if ( tmpFile.exists() )
+            {
+                tmpFile.delete();
+            }
+
+            FileUtils.deleteDirectory( tmpDir );
+        }
+    }
+
+    // ----------------------------------------------------------------------------
+    // Modifying
+    // ----------------------------------------------------------------------------
+
+    public void addArtifactsToIndex( Collection<ArtifactContext> ac, IndexingContext context )
+        throws IOException
+    {
+        if ( ac != null && !ac.isEmpty() )
+        {
+            for ( ArtifactContext actx : ac )
+            {
+                indexerEngine.update( context, actx );
+            }
+
+            context.commit();
+        }
+    }
+
+    public void deleteArtifactsFromIndex( Collection<ArtifactContext> ac, IndexingContext context )
+        throws IOException
+    {
+        if ( ac != null && !ac.isEmpty() )
+        {
+            for ( ArtifactContext actx : ac )
+            {
+                indexerEngine.remove( context, actx );
+
+                context.commit();
+            }
+        }
+    }
+
+    // ----------------------------------------------------------------------------
+    // Searching
+    // ----------------------------------------------------------------------------
+
+    public FlatSearchResponse searchFlat( FlatSearchRequest request )
+        throws IOException
+    {
+        if ( request.getContexts().isEmpty() )
+        {
+            return new FlatSearchResponse( request.getQuery(), 0, Collections.<ArtifactInfo> emptySet() );
+        }
+        else
+        {
+            return searcher.forceSearchFlatPaged( request, request.getContexts() );
+        }
+    }
+
+    public IteratorSearchResponse searchIterator( IteratorSearchRequest request )
+        throws IOException
+    {
+        if ( request.getContexts().isEmpty() )
+        {
+            return IteratorSearchResponse.empty( request.getQuery() );
+        }
+        else
+        {
+            return searcher.forceSearchIteratorPaged( request, request.getContexts() );
+        }
+    }
+
+    public GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
+        throws IOException
+    {
+        if ( request.getContexts().isEmpty() )
+        {
+            return new GroupedSearchResponse( request.getQuery(), 0, Collections.<String, ArtifactInfoGroup> emptyMap() );
+        }
+        else
+        {
+            // search targeted
+            return searcher.forceSearchGrouped( request, request.getContexts() );
+        }
+    }
+
+    // ----------------------------------------------------------------------------
+    // Identification
+    // ----------------------------------------------------------------------------
+
+    public Collection<ArtifactInfo> identify( final File artifact, final Collection<IndexingContext> contexts )
+        throws IOException
+    {
+        FileInputStream is = null;
+        try
+        {
+            final MessageDigest sha1 = MessageDigest.getInstance( "SHA-1" );
+            is = new FileInputStream( artifact );
+            final byte[] buff = new byte[4096];
+            int n;
+            while ( ( n = is.read( buff ) ) > -1 )
+            {
+                sha1.update( buff, 0, n );
+            }
+            byte[] digest = sha1.digest();
+            return identify( constructQuery( MAVEN.SHA1, new SourcedSearchExpression( encode( digest ) ) ), contexts );
+        }
+        catch ( NoSuchAlgorithmException ex )
+        {
+            IOException ioe = new IOException( "Unable to calculate digest" );
+            ioe.initCause( ex );
+            throw ioe;
+        }
+        finally
+        {
+            IOUtil.close( is );
+        }
+    }
+
+    public Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
+        throws IOException
+    {
+        final IteratorSearchResponse result =
+            searcher.searchIteratorPaged( new IteratorSearchRequest( query ), contexts );
+        try
+        {
+            final ArrayList<ArtifactInfo> ais = new ArrayList<ArtifactInfo>( result.getTotalHitsCount() );
+            for ( ArtifactInfo ai : result )
+            {
+                ais.add( ai );
+            }
+            return ais;
+        }
+        finally
+        {
+            result.close();
+        }
+    }
+
+    // ----------------------------------------------------------------------------
+    // Query construction
+    // ----------------------------------------------------------------------------
+
+    public Query constructQuery( Field field, SearchExpression expression )
+        throws IllegalArgumentException
+    {
+        try
+        {
+            return queryCreator.constructQuery( field, expression );
+        }
+        catch ( ParseException e )
+        {
+            throw new IllegalArgumentException( e );
+        }
+    }
+
+    // ==
+
+    private static final char[] DIGITS = "0123456789abcdef".toCharArray();
+
+    private static String encode( byte[] digest )
+    {
+        char[] buff = new char[digest.length * 2];
+
+        int n = 0;
+
+        for ( byte b : digest )
+        {
+            buff[n++] = DIGITS[( 0xF0 & b ) >> 4];
+            buff[n++] = DIGITS[0x0F & b];
+        }
+
+        return new String( buff );
+    }
+}

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java Fri Nov 16 09:11:10 2012
@@ -20,11 +20,7 @@ package org.apache.maven.index;
  */
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -34,11 +30,10 @@ import java.util.concurrent.ConcurrentHa
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.FSDirectory;
 import org.apache.maven.index.context.ContextMemberProvider;
 import org.apache.maven.index.context.DefaultIndexingContext;
+import org.apache.maven.index.context.ExistingLuceneIndexMismatchException;
 import org.apache.maven.index.context.IndexCreator;
-import org.apache.maven.index.context.IndexUtils;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.context.MergedIndexingContext;
 import org.apache.maven.index.context.StaticContextMemberProvider;
@@ -48,25 +43,25 @@ import org.apache.maven.index.util.Index
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
 
 /**
  * A default {@link NexusIndexer} implementation.
  * 
  * @author Tamas Cservenak
  * @author Eugene Kuleshov
+ * @deprecated Use {@link Indexer} instead. Discouraged from further use, as it suffers from multiple synchronization
+ *             and other problems. As it tries to serve as "context registry" too, but it does not synchronize the
+ *             access to it, but also, introduces some extras (like "targeted" vs "non targeted" search), that makes
+ *             it's behavior less intuitive.
  */
+@Deprecated
 @Component( role = NexusIndexer.class )
 public class DefaultNexusIndexer
     extends AbstractLogEnabled
     implements NexusIndexer
 {
     @Requirement
-    private Scanner scanner;
-
-    @Requirement
-    private SearchEngine searcher;
+    private Indexer indexer;
 
     @Requirement
     private IndexerEngine indexerEngine;
@@ -74,12 +69,7 @@ public class DefaultNexusIndexer
     @Requirement
     private QueryCreator queryCreator;
 
-    private final Map<String, IndexingContext> indexingContexts;
-
-    public DefaultNexusIndexer()
-    {
-        this.indexingContexts = new ConcurrentHashMap<String, IndexingContext>();
-    }
+    private final Map<String, IndexingContext> indexingContexts = new ConcurrentHashMap<String, IndexingContext>();
 
     // ----------------------------------------------------------------------------
     // Contexts
@@ -95,72 +85,60 @@ public class DefaultNexusIndexer
                                                List<? extends IndexCreator> indexers )
         throws IOException, UnsupportedExistingLuceneIndexException
     {
-        IndexingContext context =
-            new DefaultIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
-                IndexCreatorSorter.sort( indexers ), false );
-
-        indexingContexts.put( context.getId(), context );
-
-        return context;
-    }
-
-    public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
-                                                     File indexDirectory, String repositoryUrl, String indexUpdateUrl,
-                                                     List<? extends IndexCreator> indexers )
-        throws IOException
-    {
-        IndexingContext context = null;
-
         try
         {
-            context =
-                new DefaultIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl,
-                    indexUpdateUrl, IndexCreatorSorter.sort( indexers ), true );
-
+            IndexingContext context =
+                indexer.createIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl,
+                    indexUpdateUrl, true, false, indexers );
             indexingContexts.put( context.getId(), context );
+            return context;
         }
-        catch ( UnsupportedExistingLuceneIndexException e )
+        catch ( ExistingLuceneIndexMismatchException e )
         {
-            // will not be thrown
+            throw new UnsupportedExistingLuceneIndexException( e.getMessage(), e );
         }
-
-        return context;
     }
 
-    public IndexingContext addIndexingContext( String id, String repositoryId, File repository, Directory directory,
-                                               String repositoryUrl, String indexUpdateUrl,
-                                               List<? extends IndexCreator> indexers )
-        throws IOException, UnsupportedExistingLuceneIndexException
+    public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
+                                                     File indexDirectory, String repositoryUrl, String indexUpdateUrl,
+                                                     List<? extends IndexCreator> indexers )
+        throws IOException
     {
         IndexingContext context =
-            new DefaultIndexingContext( id, repositoryId, repository, directory, repositoryUrl, indexUpdateUrl,
-                IndexCreatorSorter.sort( indexers ), false );
-
+            indexer.createIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
+                true, true, indexers );
         indexingContexts.put( context.getId(), context );
-
         return context;
     }
 
-    public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
-                                                     Directory directory, String repositoryUrl, String indexUpdateUrl,
-                                                     List<? extends IndexCreator> indexers )
-        throws IOException
+    public IndexingContext addIndexingContext( String id, String repositoryId, File repository, Directory directory,
+                                               String repositoryUrl, String indexUpdateUrl,
+                                               List<? extends IndexCreator> indexers )
+        throws IOException, UnsupportedExistingLuceneIndexException
     {
-        IndexingContext context = null;
-
         try
         {
-            context =
+            IndexingContext context =
                 new DefaultIndexingContext( id, repositoryId, repository, directory, repositoryUrl, indexUpdateUrl,
-                    IndexCreatorSorter.sort( indexers ), true );
-
+                    IndexCreatorSorter.sort( indexers ), false );
             indexingContexts.put( context.getId(), context );
+            return context;
         }
-        catch ( UnsupportedExistingLuceneIndexException e )
+        catch ( ExistingLuceneIndexMismatchException e )
         {
-            // will not be thrown
+            throw new UnsupportedExistingLuceneIndexException( e.getMessage(), e );
         }
+    }
 
+    public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
+                                                     Directory directory, String repositoryUrl, String indexUpdateUrl,
+                                                     List<? extends IndexCreator> indexers )
+        throws IOException
+    {
+        IndexingContext context =
+            new DefaultIndexingContext( id, repositoryId, repository, directory, repositoryUrl, indexUpdateUrl,
+                IndexCreatorSorter.sort( indexers ), true );
+        indexingContexts.put( context.getId(), context );
         return context;
     }
 
@@ -169,13 +147,8 @@ public class DefaultNexusIndexer
                                                      Collection<IndexingContext> contexts )
         throws IOException
     {
-        IndexingContext context =
-            new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
-                new StaticContextMemberProvider( contexts ) );
-
-        indexingContexts.put( context.getId(), context );
-
-        return context;
+        return addMergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
+            new StaticContextMemberProvider( contexts ) );
     }
 
     public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
@@ -184,10 +157,9 @@ public class DefaultNexusIndexer
         throws IOException
     {
         IndexingContext context =
-            new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
-
+            indexer.createMergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
+                membersProvider );
         indexingContexts.put( context.getId(), context );
-
         return context;
     }
 
@@ -199,9 +171,7 @@ public class DefaultNexusIndexer
         IndexingContext context =
             new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
                 new StaticContextMemberProvider( contexts ) );
-
         indexingContexts.put( context.getId(), context );
-
         return context;
     }
 
@@ -212,9 +182,7 @@ public class DefaultNexusIndexer
     {
         IndexingContext context =
             new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
-
         indexingContexts.put( context.getId(), context );
-
         return context;
     }
 
@@ -224,7 +192,7 @@ public class DefaultNexusIndexer
         if ( indexingContexts.containsKey( context.getId() ) )
         {
             indexingContexts.remove( context.getId() );
-            context.close( deleteFiles );
+            indexer.closeIndexingContext( context, deleteFiles );
         }
     }
 
@@ -273,73 +241,8 @@ public class DefaultNexusIndexer
                       final boolean update )
         throws IOException
     {
-        File repositoryDirectory = context.getRepository();
-
-        if ( repositoryDirectory == null )
-        {
-            // nothing to scan
-            return;
-        }
-
-        if ( !repositoryDirectory.exists() )
-        {
-            throw new IOException( "Repository directory " + repositoryDirectory + " does not exist" );
-        }
-
-        // always use temporary context when reindexing
-        File tmpFile = File.createTempFile( context.getId() + "-tmp", "" );
-        File tmpDir = new File( tmpFile.getParentFile(), tmpFile.getName() + ".dir" );
-        if ( !tmpDir.mkdirs() )
-        {
-            throw new IOException( "Cannot create temporary directory: " + tmpDir );
-        }
-
-        IndexingContext tmpContext = null;
-        try
-        {
-            FSDirectory directory = FSDirectory.open( tmpDir );
-
-            if ( update )
-            {
-                IndexUtils.copyDirectory( context.getIndexDirectory(), directory );
-            }
-
-            tmpContext = new DefaultIndexingContext( context.getId() + "-tmp", //
-                context.getRepositoryId(), //
-                context.getRepository(), //
-                directory, //
-                context.getRepositoryUrl(), //
-                context.getIndexUpdateUrl(), //
-                context.getIndexCreators(), //
-                true );
-
-            scanner.scan( new ScanningRequest( tmpContext, //
-                new DefaultScannerListener( tmpContext, indexerEngine, update, listener ), fromPath ) );
-
-            tmpContext.updateTimestamp( true );
-            context.replace( tmpContext.getIndexDirectory() );
-
-            removeIndexingContext( tmpContext, true );
-        }
-        catch ( Exception ex )
-        {
-            throw (IOException) new IOException( "Error scanning context " + context.getId() + ": " + ex ).initCause( ex );
-        }
-        finally
-        {
-            if ( tmpContext != null )
-            {
-                tmpContext.close( true );
-            }
-
-            if ( tmpFile.exists() )
-            {
-                tmpFile.delete();
-            }
-
-            FileUtils.deleteDirectory( tmpDir );
-        }
-
+        final IndexerScanRequest indexerScanRequest = new IndexerScanRequest( context, listener, fromPath, update );
+        indexer.scan( indexerScanRequest );
     }
 
     /**
@@ -364,26 +267,13 @@ public class DefaultNexusIndexer
     public void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
         throws IOException
     {
-        if ( ac != null )
-        {
-            indexerEngine.update( context, ac );
-
-            context.commit();
-        }
+        indexer.addArtifactsToIndex( Collections.singleton( ac ), context );
     }
 
-    public void addArtifactsToIndex( Collection<ArtifactContext> ac, IndexingContext context )
+    public void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
         throws IOException
     {
-        if ( ac != null && !ac.isEmpty() )
-        {
-            for ( ArtifactContext actx : ac )
-            {
-                indexerEngine.update( context, actx );
-            }
-
-            context.commit();
-        }
+        indexer.addArtifactsToIndex( acs, context );
     }
 
     /**
@@ -392,26 +282,13 @@ public class DefaultNexusIndexer
     public void deleteArtifactFromIndex( ArtifactContext ac, IndexingContext context )
         throws IOException
     {
-        if ( ac != null )
-        {
-            indexerEngine.remove( context, ac );
-
-            context.commit();
-        }
+        indexer.deleteArtifactsFromIndex( Collections.singleton( ac ), context );
     }
 
-    public void deleteArtifactsFromIndex( Collection<ArtifactContext> ac, IndexingContext context )
+    public void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
         throws IOException
     {
-        if ( ac != null && !ac.isEmpty() )
-        {
-            for ( ArtifactContext actx : ac )
-            {
-                indexerEngine.remove( context, actx );
-
-                context.commit();
-            }
-        }
+        indexer.deleteArtifactsFromIndex( acs, context );
     }
 
     // ----------------------------------------------------------------------------
@@ -423,12 +300,9 @@ public class DefaultNexusIndexer
     {
         if ( request.getContexts().isEmpty() )
         {
-            return searcher.searchFlatPaged( request, indexingContexts.values() );
-        }
-        else
-        {
-            return searcher.forceSearchFlatPaged( request, request.getContexts() );
+            request.getContexts().addAll( getIndexingContexts().values() );
         }
+        return indexer.searchFlat( request );
     }
 
     public IteratorSearchResponse searchIterator( IteratorSearchRequest request )
@@ -436,12 +310,9 @@ public class DefaultNexusIndexer
     {
         if ( request.getContexts().isEmpty() )
         {
-            return searcher.searchIteratorPaged( request, indexingContexts.values() );
-        }
-        else
-        {
-            return searcher.forceSearchIteratorPaged( request, request.getContexts() );
+            request.getContexts().addAll( getIndexingContexts().values() );
         }
+        return indexer.searchIterator( request );
     }
 
     public GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
@@ -449,14 +320,9 @@ public class DefaultNexusIndexer
     {
         if ( request.getContexts().isEmpty() )
         {
-            // search all
-            return searcher.searchGrouped( request, indexingContexts.values() );
-        }
-        else
-        {
-            // search targeted
-            return searcher.forceSearchGrouped( request, request.getContexts() );
+            request.getContexts().addAll( getIndexingContexts().values() );
         }
+        return indexer.searchGrouped( request );
     }
 
     // ----------------------------------------------------------------------------
@@ -480,14 +346,7 @@ public class DefaultNexusIndexer
     public Query constructQuery( Field field, SearchExpression expression )
         throws IllegalArgumentException
     {
-        try
-        {
-            return queryCreator.constructQuery( field, expression );
-        }
-        catch ( ParseException e )
-        {
-            throw new IllegalArgumentException( e );
-        }
+        return indexer.constructQuery( field, expression );
     }
 
     // ----------------------------------------------------------------------------
@@ -509,39 +368,7 @@ public class DefaultNexusIndexer
     public Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
         throws IOException
     {
-        FileInputStream is = null;
-
-        try
-        {
-            MessageDigest sha1 = MessageDigest.getInstance( "SHA-1" );
-
-            is = new FileInputStream( artifact );
-
-            byte[] buff = new byte[4096];
-
-            int n;
-
-            while ( ( n = is.read( buff ) ) > -1 )
-            {
-                sha1.update( buff, 0, n );
-            }
-
-            byte[] digest = sha1.digest();
-
-            Query q = constructQuery( MAVEN.SHA1, encode( digest ), SearchType.EXACT );
-
-            return identify( q, contexts );
-        }
-        catch ( NoSuchAlgorithmException ex )
-        {
-            IOException ioe = new IOException( "Unable to calculate digest" );
-            ioe.initCause( ex );
-            throw ioe;
-        }
-        finally
-        {
-            IOUtil.close( is );
-        }
+        return indexer.identify( artifact, contexts );
     }
 
     public Collection<ArtifactInfo> identify( Query query )
@@ -553,41 +380,6 @@ public class DefaultNexusIndexer
     public Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
         throws IOException
     {
-        IteratorSearchResponse result = searcher.searchIteratorPaged( new IteratorSearchRequest( query ), contexts );
-
-        try
-        {
-            ArrayList<ArtifactInfo> ais = new ArrayList<ArtifactInfo>( result.getTotalHitsCount() );
-
-            for ( ArtifactInfo ai : result )
-            {
-                ais.add( ai );
-            }
-
-            return ais;
-        }
-        finally
-        {
-            result.close();
-        }
-    }
-
-    // ==
-
-    private static final char[] DIGITS = "0123456789abcdef".toCharArray();
-
-    private static String encode( byte[] digest )
-    {
-        char[] buff = new char[digest.length * 2];
-
-        int n = 0;
-
-        for ( byte b : digest )
-        {
-            buff[n++] = DIGITS[( 0xF0 & b ) >> 4];
-            buff[n++] = DIGITS[0x0F & b];
-        }
-
-        return new String( buff );
+        return indexer.identify( query, contexts );
     }
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java Fri Nov 16 09:11:10 2012
@@ -28,7 +28,7 @@ import org.apache.maven.index.context.In
 /**
  * A flat search request.
  * 
- * @see NexusIndexer#searchFlat(FlatSearchRequest)
+ * @see Indexer#searchFlat(FlatSearchRequest)
  */
 public class FlatSearchRequest
     extends AbstractSearchRequest

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java Fri Nov 16 09:11:10 2012
@@ -26,7 +26,7 @@ import org.apache.lucene.search.Query;
 /**
  * A flat search response.
  * 
- * @see NexusIndexer#searchFlat(FlatSearchRequest)
+ * @see Indexer#searchFlat(FlatSearchRequest)
  */
 public class FlatSearchResponse
     extends AbstractSearchResponse

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java Fri Nov 16 09:11:10 2012
@@ -29,7 +29,7 @@ import org.apache.maven.index.context.In
  * A grouped search request. This kinds of request is not pageable, since order of incoming hits are not defined, hence
  * paging between Document hits makes no sense, would produce unpredictable (and probably not meaningful) results.
  * 
- * @see NexusIndexer#searchGrouped(GroupedSearchRequest)
+ * @see Indexer#searchGrouped(GroupedSearchRequest)
  */
 public class GroupedSearchRequest
     extends AbstractSearchRequest

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java Fri Nov 16 09:11:10 2012
@@ -26,7 +26,7 @@ import org.apache.lucene.search.Query;
 /**
  * A grouped search response. For hitsCount, it reports the number of groups found.
  * 
- * @see NexusIndexer#searchGrouped(GroupedSearchRequest)
+ * @see Indexer#searchGrouped(GroupedSearchRequest)
  */
 public class GroupedSearchResponse
     extends AbstractSearchResponse

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Grouping.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Grouping.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Grouping.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Grouping.java Fri Nov 16 09:11:10 2012
@@ -24,7 +24,7 @@ import java.util.Map;
 /**
  * A grouping criteria for grouped searches.
  * 
- * @see NexusIndexer#searchGrouped(GroupedSearchRequest)
+ * @see Indexer#searchGrouped(GroupedSearchRequest)
  * @author Tamas Cservenak
  */
 public interface Grouping

Added: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Indexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Indexer.java?rev=1410262&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Indexer.java (added)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/Indexer.java Fri Nov 16 09:11:10 2012
@@ -0,0 +1,224 @@
+package org.apache.maven.index;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.lucene.search.Query;
+import org.apache.maven.index.context.ContextMemberProvider;
+import org.apache.maven.index.context.ExistingLuceneIndexMismatchException;
+import org.apache.maven.index.context.IndexCreator;
+import org.apache.maven.index.context.IndexingContext;
+import org.apache.maven.index.expr.SearchExpression;
+import org.apache.maven.index.expr.SourcedSearchExpression;
+import org.apache.maven.index.expr.UserInputSearchExpression;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0    
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Indexer component. It is the main component of Maven Indexer, offering {@link IndexingContext} creation and close
+ * methods, context maintenance (scan, add, remove) and search methods. Supersedes the {@link NexusIndexer} component,
+ * making it less cludged, and focusing on main use cases.
+ * 
+ * @author cstamas
+ * @since 5.1.0
+ */
+public interface Indexer
+{
+    /**
+     * Creates an indexing context.
+     * 
+     * @param id the ID of the context.
+     * @param repositoryId the ID of the repository that this context represents. You might have several contexts
+     *            indexing same repository ID, but on separate locations.
+     * @param repository the location of the repository on FS.
+     * @param indexDirectory the location of the Lucene indexes on FS.
+     * @param repositoryUrl the location of the remote repository or {@code null} if this indexing context does not need
+     *            remote updates (is not a proxy).
+     * @param indexUpdateUrl the alternate location of the remote repository indexes (if they are not in default place)
+     *            or {@code null} if defaults are applicable.
+     * @param searchable if context should be searched in non-targeted mode.
+     * @param reclaim if indexDirectory is known to contain (or should contain) valid Maven Indexer lucene index, and no
+     *            checks needed to be performed, or, if we want to "stomp" over existing index (unsafe to do!).
+     * @param indexers the set of indexers to apply to this context.
+     * @return the context created.
+     * @throws IOException in case of some serious IO problem.
+     * @throws ExistingLuceneIndexMismatchException if a Lucene index already exists where location is specified, but
+     *             it has no Nexus descriptor record or it has, but the embedded repoId differs from the repoId
+     *             specified from the supplied one. Never thrown if {@code reclaim} is {@code true}, as in that case, if
+     *             Lucene index exists but any of those criteria above are not met, the existing index is overwritten,
+     *             and equipped with proper descriptor silently.
+     * @throws IllegalArgumentException in case the supplied list of IndexCreators are having non-satisfiable
+     *             dependencies.
+     */
+    IndexingContext createIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
+                                           String repositoryUrl, String indexUpdateUrl, boolean searchable,
+                                           boolean reclaim, List<? extends IndexCreator> indexers )
+        throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException;
+
+    /**
+     * Creates a merged indexing context.
+     * 
+     * @param id the ID of the context.
+     * @param repositoryId the ID of the repository that this context represents. You might have several contexts
+     *            indexing same repository ID, but on separate locations.
+     * @param repository the location of the repository on FS.
+     * @param indexDirectory the location of the Lucene indexes on FS.
+     * @param searchable if context should be searched in non-targeted mode.
+     * @param membersProvider the {@link ContextMemberProvider}, never null.
+     * @return the context created.
+     * @throws IOException in case of some serious IO problem.
+     */
+    IndexingContext createMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
+                                                 boolean searchable, ContextMemberProvider membersProvider )
+        throws IOException;
+
+    /**
+     * Closes the indexing context: closes it and deletes (if specified) the index files.
+     * 
+     * @param context the one needed to be closed, never {@code null}.
+     * @param deleteFiles {@code true} if all indexer related files (including Lucene index!) needs to be deleted,
+     *            {@code false} otherwise.
+     * @throws IOException
+     */
+    void closeIndexingContext( IndexingContext context, boolean deleteFiles )
+        throws IOException;
+
+    // ----------------------------------------------------------------------------
+    // Scanning
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Performs a scan (re-index).
+     * 
+     * @param indexerScanRequest
+     * @throws IOException
+     */
+    void scan( IndexerScanRequest indexerScanRequest )
+        throws IOException;
+
+    // ----------------------------------------------------------------------------
+    // Modifying
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Adds the passed in artifact contexts to passed in indexing context.
+     * 
+     * @param acs
+     * @param context
+     * @throws IOException
+     */
+    void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
+        throws IOException;
+
+    /**
+     * Removes the passed in artifacts contexts from passed in indexing context.
+     * 
+     * @param acs
+     * @param context
+     * @throws IOException
+     */
+    void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
+        throws IOException;
+
+    // ----------------------------------------------------------------------------
+    // Searching
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Searches according the request parameters.
+     * 
+     * @param request
+     * @return search response
+     * @throws IOException
+     */
+    FlatSearchResponse searchFlat( FlatSearchRequest request )
+        throws IOException;
+
+    /**
+     * Searches according to request parameters.
+     * 
+     * @param request
+     * @return search response
+     * @throws IOException
+     */
+    IteratorSearchResponse searchIterator( IteratorSearchRequest request )
+        throws IOException;
+
+    /**
+     * Searches according the request parameters.
+     * 
+     * @param request
+     * @return search response
+     * @throws IOException
+     */
+    GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
+        throws IOException;
+
+    // ----------------------------------------------------------------------------
+    // Identify
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Performs an "identity" search. Passed in {@link File} will have SHA1 hash calculated, and an
+     * {@link #identify(Query, Collection)} method will be invoked searching with calculated hash the {@link MAVEN#SHA1}
+     * field. This is just a shorthand method, as these calls are simply calculating hex encoded SHA1 of the file, and
+     * invoking the {@link #constructQuery(Field, SearchExpression)} and {@link #identify(Query, Collection)} methods.
+     * 
+     * @param artifact the file
+     * @param contexts in which to perform the action
+     * @return collection of identified matches.
+     * @throws IOException
+     */
+    Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
+        throws IOException;
+
+    /**
+     * Performs an "identity" search. Those are usually simple key-value queries, involving "unique" fields like
+     * {@link MAVEN#SHA1} or such.
+     * 
+     * @param query
+     * @param contexts
+     * @return collection of identified matches.
+     * @throws IOException
+     */
+    Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
+        throws IOException;
+
+    // ----------------------------------------------------------------------------
+    // Query construction
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a
+     * field indexed, and WHAT query is needed to achieve that search.
+     * 
+     * @param field
+     * @param expression
+     * @return the query to be used for search.
+     * @see SearchExpression
+     * @see UserInputSearchExpression
+     * @see SourcedSearchExpression
+     * @throws IllegalArgumentException
+     */
+    Query constructQuery( Field field, SearchExpression expression )
+        throws IllegalArgumentException;
+}

Added: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/IndexerScanRequest.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/IndexerScanRequest.java?rev=1410262&view=auto
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/IndexerScanRequest.java (added)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/IndexerScanRequest.java Fri Nov 16 09:11:10 2012
@@ -0,0 +1,91 @@
+package org.apache.maven.index;
+
+import java.io.File;
+
+import org.apache.maven.index.context.IndexingContext;
+import org.codehaus.plexus.util.StringUtils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0    
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Scanning request for initiating a {@link Indexer#scan(IndexerScanRequest)} operation of an {@link IndexingContext}.
+ * 
+ * @author cstamas
+ * @since 5.1.0
+ */
+public class IndexerScanRequest
+{
+    private final IndexingContext context;
+
+    private final ArtifactScanningListener artifactScanningListener;
+
+    private final String startingPath;
+
+    private final boolean update;
+
+    /**
+     * Constructor.
+     * 
+     * @param context
+     * @param artifactScanningListener
+     * @param startingPath
+     * @param update
+     */
+    public IndexerScanRequest( final IndexingContext context, final ArtifactScanningListener artifactScanningListener,
+                               final String startingPath, final boolean update )
+    {
+        this.context = context;
+        this.artifactScanningListener = artifactScanningListener;
+        this.startingPath = startingPath;
+        this.update = update;
+    }
+
+    public IndexingContext getIndexingContext()
+    {
+        return context;
+    }
+
+    public ArtifactScanningListener getArtifactScanningListener()
+    {
+        return artifactScanningListener;
+    }
+
+    public String getStartingPath()
+    {
+        return startingPath;
+    }
+
+    public boolean isUpdate()
+    {
+        return update;
+    }
+
+    public File getStartingDirectory()
+    {
+        if ( StringUtils.isBlank( startingPath ) )
+        {
+            return getIndexingContext().getRepository();
+        }
+        else
+        {
+            return new File( getIndexingContext().getRepository(), startingPath );
+        }
+    }
+}

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java Fri Nov 16 09:11:10 2012
@@ -74,8 +74,9 @@ import org.apache.maven.index.updater.In
  *   ...
  * </pre>
  * 
- * Query could be also constructed using a convenience {@link NexusIndexer#constructQuery(Field, SearchExpression)} method that
- * handles creation of the wildcard queries. Also see {@link DefaultQueryCreator} for more details on supported queries.
+ * Query could be also constructed using a convenience {@link NexusIndexer#constructQuery(Field, SearchExpression)}
+ * method that handles creation of the wildcard queries. Also see {@link DefaultQueryCreator} for more details on
+ * supported queries.
  * 
  * @see IndexingContext
  * @see IndexUpdater
@@ -83,7 +84,9 @@ import org.apache.maven.index.updater.In
  * @author Jason van Zyl
  * @author Tamas Cservenak
  * @author Eugene Kuleshov
+ * @deprecated Use {@link Indexer} instead.
  */
+@Deprecated
 public interface NexusIndexer
 {
     String ROLE = NexusIndexer.class.getName();
@@ -111,7 +114,9 @@ public interface NexusIndexer
      *             it has no Nexus descriptor record or it has, but the embedded repoId differs from the repoId
      *             specified from the supplied one.
      * @throws IllegalArgumentException in case the supplied list of IndexCreators are not satisfiable
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     IndexingContext addIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
                                         String repositoryUrl, String indexUpdateUrl,
                                         List<? extends IndexCreator> indexers )
@@ -132,7 +137,9 @@ public interface NexusIndexer
      * @return
      * @throws IOException in case of some serious IO problem.
      * @throws IllegalArgumentException in case the supplied list of IndexCreators are not satisfiable
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     IndexingContext addIndexingContextForced( String id, String repositoryId, File repository, File indexDirectory,
                                               String repositoryUrl, String indexUpdateUrl,
                                               List<? extends IndexCreator> indexers )
@@ -154,7 +161,9 @@ public interface NexusIndexer
      *             it has no Nexus descriptor record or it has, but the embedded repoId differs from the repoId
      *             specified from the supplied one.
      * @throws IllegalArgumentException in case the supplied list of IndexCreators are not satisfiable
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     IndexingContext addIndexingContext( String id, String repositoryId, File repository, Directory directory,
                                         String repositoryUrl, String indexUpdateUrl,
                                         List<? extends IndexCreator> indexers )
@@ -175,25 +184,31 @@ public interface NexusIndexer
      * @return
      * @throws IOException in case of some serious IO problem.
      * @throws IllegalArgumentException in case the supplied list of IndexCreators are not satisfiable
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     IndexingContext addIndexingContextForced( String id, String repositoryId, File repository, Directory directory,
                                               String repositoryUrl, String indexUpdateUrl,
                                               List<? extends IndexCreator> indexers )
         throws IOException;
 
+    @Deprecated
     IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
                                               boolean searchable, Collection<IndexingContext> contexts )
         throws IOException;
 
+    @Deprecated
     IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
                                               boolean searchable, ContextMemberProvider membersProvider )
         throws IOException;
 
+    @Deprecated
     IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
                                               Directory indexDirectory, boolean searchable,
                                               Collection<IndexingContext> contexts )
         throws IOException;
 
+    @Deprecated
     IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
                                               Directory indexDirectory, boolean searchable,
                                               ContextMemberProvider membersProvider )
@@ -205,13 +220,18 @@ public interface NexusIndexer
      * @param context
      * @param deleteFiles
      * @throws IOException
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void removeIndexingContext( IndexingContext context, boolean deleteFiles )
         throws IOException;
 
     /**
      * Returns the map of indexing contexts keyed by their ID.
+     * 
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     Map<String, IndexingContext> getIndexingContexts();
 
     // ----------------------------------------------------------------------------
@@ -221,7 +241,9 @@ public interface NexusIndexer
      * Performs full scan (reindex) for the local repository belonging to supplied context.
      * 
      * @param context
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void scan( IndexingContext context )
         throws IOException;
 
@@ -231,7 +253,9 @@ public interface NexusIndexer
      * 
      * @param context
      * @param listener
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void scan( IndexingContext context, ArtifactScanningListener listener )
         throws IOException;
 
@@ -240,8 +264,10 @@ public interface NexusIndexer
      * context.
      * 
      * @param context
-     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happenF
+     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happen
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void scan( IndexingContext context, boolean update )
         throws IOException;
 
@@ -250,8 +276,10 @@ public interface NexusIndexer
      * 
      * @param context
      * @param listener
-     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happenF
+     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happen
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void scan( IndexingContext context, ArtifactScanningListener listener, boolean update )
         throws IOException;
 
@@ -262,11 +290,14 @@ public interface NexusIndexer
      * @param fromPath a path segment if you want "sub-path" reindexing (ie. reindex just a given subfolder of a
      *            repository, ot whole repository from root.
      * @param listener
-     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happenF
+     * @param update if incremental reindex wanted, set true, otherwise false and full reindex will happen
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     void scan( IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update )
         throws IOException;
 
+    @Deprecated
     void artifactDiscovered( ArtifactContext ac, IndexingContext context )
         throws IOException;
 
@@ -274,15 +305,19 @@ public interface NexusIndexer
     // Modifying
     // ----------------------------------------------------------------------------
 
+    @Deprecated
     void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
         throws IOException;
 
+    @Deprecated
     void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
         throws IOException;
 
+    @Deprecated
     void deleteArtifactFromIndex( ArtifactContext ac, IndexingContext context )
         throws IOException;
 
+    @Deprecated
     void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
         throws IOException;
 
@@ -296,7 +331,9 @@ public interface NexusIndexer
      * @param request
      * @return
      * @throws IOException
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     FlatSearchResponse searchFlat( FlatSearchRequest request )
         throws IOException;
 
@@ -306,7 +343,9 @@ public interface NexusIndexer
      * @param request
      * @return
      * @throws IOException
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     IteratorSearchResponse searchIterator( IteratorSearchRequest request )
         throws IOException;
 
@@ -316,7 +355,9 @@ public interface NexusIndexer
      * @param request
      * @return
      * @throws IOException
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
         throws IOException;
 
@@ -332,8 +373,9 @@ public interface NexusIndexer
      * @param query
      * @param type
      * @return
-     * @deprecated Use {@link #constructQuery(Field, SearchExpression)} instead.
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     Query constructQuery( Field field, String query, SearchType type )
         throws IllegalArgumentException;
 
@@ -344,7 +386,9 @@ public interface NexusIndexer
      * @param field
      * @param expression
      * @return
+     * @deprecated Use {@link Indexer} instead.
      */
+    @Deprecated
     Query constructQuery( Field field, SearchExpression expression )
         throws IllegalArgumentException;
 
@@ -353,18 +397,23 @@ public interface NexusIndexer
     // Since 4.0: Indexer does not make any assumptions, it is caller call to decide what to do with multiple results
     // ----------------------------------------------------------------------------
 
+    @Deprecated
     Collection<ArtifactInfo> identify( Field field, String query )
         throws IllegalArgumentException, IOException;
 
+    @Deprecated
     Collection<ArtifactInfo> identify( File artifact )
         throws IOException;
 
+    @Deprecated
     Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
         throws IOException;
 
+    @Deprecated
     Collection<ArtifactInfo> identify( Query query )
         throws IOException;
 
+    @Deprecated
     Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
         throws IOException;
 

Copied: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/AbstractArchetypeDataSource.java (from r1410255, maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java)
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/AbstractArchetypeDataSource.java?p2=maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/AbstractArchetypeDataSource.java&p1=maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java&r1=1410255&r2=1410262&rev=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/AbstractArchetypeDataSource.java Fri Nov 16 09:11:10 2012
@@ -20,6 +20,7 @@ package org.apache.maven.index.archetype
  */
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -31,40 +32,31 @@ import org.apache.maven.archetype.source
 import org.apache.maven.index.ArtifactInfo;
 import org.apache.maven.index.FlatSearchRequest;
 import org.apache.maven.index.FlatSearchResponse;
+import org.apache.maven.index.Indexer;
 import org.apache.maven.index.MAVEN;
-import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
 import org.apache.maven.index.expr.SourcedSearchExpression;
-import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 
-/**
- * @author Eugene Kuleshov
- */
-@Component( role = ArchetypeDataSource.class, hint = "nexus" )
-public class NexusArchetypeDataSource
+public abstract class AbstractArchetypeDataSource
     extends AbstractLogEnabled
     implements ArchetypeDataSource
 {
     @Requirement
-    private NexusIndexer indexer;
+    private Indexer indexer;
 
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
+    public ArchetypeCatalog getArchetypeCatalog( final Properties properties )
         throws ArchetypeDataSourceException
     {
-        ArchetypeCatalog catalog = new ArchetypeCatalog();
-
+        final ArchetypeCatalog catalog = new ArchetypeCatalog();
         try
         {
-            Map<String, String> repositories = getRepositoryMap();
-
-            Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) );
-
-            FlatSearchRequest searchRequest = new FlatSearchRequest( pq );
-
-            FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest );
-
+            final Map<String, String> repositories = getRepositoryMap();
+            final Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) );
+            final FlatSearchRequest searchRequest = new FlatSearchRequest( pq );
+            searchRequest.setContexts( getIndexingContexts() );
+            final FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest );
             for ( ArtifactInfo info : searchResponse.getResults() )
             {
                 Archetype archetype = new Archetype();
@@ -73,7 +65,6 @@ public class NexusArchetypeDataSource
                 archetype.setVersion( info.version );
                 archetype.setDescription( info.description );
                 archetype.setRepository( repositories.get( info.repository ) );
-
                 catalog.addArchetype( archetype );
             }
         }
@@ -90,7 +81,7 @@ public class NexusArchetypeDataSource
         // can't cache this because indexes can be changed
         Map<String, String> repositories = new HashMap<String, String>();
 
-        for ( IndexingContext context : indexer.getIndexingContexts().values() )
+        for ( IndexingContext context : getIndexingContexts() )
         {
             String repositoryUrl = context.getRepositoryUrl();
             if ( repositoryUrl != null )
@@ -106,4 +97,8 @@ public class NexusArchetypeDataSource
     {
         // TODO maybe update index
     }
+
+    // ==
+
+    protected abstract List<IndexingContext> getIndexingContexts();
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/archetype/NexusArchetypeDataSource.java Fri Nov 16 09:11:10 2012
@@ -19,91 +19,32 @@ package org.apache.maven.index.archetype
  * under the License.
  */
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.ArrayList;
+import java.util.List;
 
-import org.apache.lucene.search.Query;
-import org.apache.maven.archetype.catalog.Archetype;
-import org.apache.maven.archetype.catalog.ArchetypeCatalog;
 import org.apache.maven.archetype.source.ArchetypeDataSource;
-import org.apache.maven.archetype.source.ArchetypeDataSourceException;
-import org.apache.maven.index.ArtifactInfo;
-import org.apache.maven.index.FlatSearchRequest;
-import org.apache.maven.index.FlatSearchResponse;
-import org.apache.maven.index.MAVEN;
 import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.context.IndexingContext;
-import org.apache.maven.index.expr.SourcedSearchExpression;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
 
 /**
+ * Nexus Archetype Data Source.
+ * 
  * @author Eugene Kuleshov
+ * @deprecated Extend {@link AbstractArchetypeDataSource} instead, and make it suit your case.
  */
+@Deprecated
 @Component( role = ArchetypeDataSource.class, hint = "nexus" )
 public class NexusArchetypeDataSource
-    extends AbstractLogEnabled
-    implements ArchetypeDataSource
+    extends AbstractArchetypeDataSource
 {
     @Requirement
-    private NexusIndexer indexer;
+    private NexusIndexer nexusIndexer;
 
-    public ArchetypeCatalog getArchetypeCatalog( Properties properties )
-        throws ArchetypeDataSourceException
+    @Override
+    protected List<IndexingContext> getIndexingContexts()
     {
-        ArchetypeCatalog catalog = new ArchetypeCatalog();
-
-        try
-        {
-            Map<String, String> repositories = getRepositoryMap();
-
-            Query pq = indexer.constructQuery( MAVEN.PACKAGING, new SourcedSearchExpression( "maven-archetype" ) );
-
-            FlatSearchRequest searchRequest = new FlatSearchRequest( pq );
-
-            FlatSearchResponse searchResponse = indexer.searchFlat( searchRequest );
-
-            for ( ArtifactInfo info : searchResponse.getResults() )
-            {
-                Archetype archetype = new Archetype();
-                archetype.setGroupId( info.groupId );
-                archetype.setArtifactId( info.artifactId );
-                archetype.setVersion( info.version );
-                archetype.setDescription( info.description );
-                archetype.setRepository( repositories.get( info.repository ) );
-
-                catalog.addArchetype( archetype );
-            }
-        }
-        catch ( Exception ex )
-        {
-            getLogger().error( "Unable to retrieve archetypes", ex );
-        }
-
-        return catalog;
-    }
-
-    private Map<String, String> getRepositoryMap()
-    {
-        // can't cache this because indexes can be changed
-        Map<String, String> repositories = new HashMap<String, String>();
-
-        for ( IndexingContext context : indexer.getIndexingContexts().values() )
-        {
-            String repositoryUrl = context.getRepositoryUrl();
-            if ( repositoryUrl != null )
-            {
-                repositories.put( context.getId(), repositoryUrl );
-            }
-        }
-
-        return repositories;
-    }
-
-    public void updateCatalog( Properties properties, Archetype archetype )
-    {
-        // TODO maybe update index
+        return new ArrayList<IndexingContext>( nexusIndexer.getIndexingContexts().values() );
     }
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/DefaultIndexingContext.java Fri Nov 16 09:11:10 2012
@@ -111,7 +111,7 @@ public class DefaultIndexingContext
                                     String repositoryUrl, String indexUpdateUrl,
                                     List<? extends IndexCreator> indexCreators, Directory indexDirectory,
                                     boolean reclaimIndex )
-        throws UnsupportedExistingLuceneIndexException, IOException
+        throws ExistingLuceneIndexMismatchException, IOException
     {
         this.id = id;
 
@@ -150,7 +150,7 @@ public class DefaultIndexingContext
     public DefaultIndexingContext( String id, String repositoryId, File repository, File indexDirectoryFile,
                                    String repositoryUrl, String indexUpdateUrl,
                                    List<? extends IndexCreator> indexCreators, boolean reclaimIndex )
-        throws IOException, UnsupportedExistingLuceneIndexException
+        throws IOException, ExistingLuceneIndexMismatchException
     {
         this( id, repositoryId, repository, repositoryUrl, indexUpdateUrl, indexCreators,
             FSDirectory.open( indexDirectoryFile ), reclaimIndex );
@@ -158,10 +158,11 @@ public class DefaultIndexingContext
         this.indexDirectoryFile = indexDirectoryFile;
     }
 
+    @Deprecated
     public DefaultIndexingContext( String id, String repositoryId, File repository, Directory indexDirectory,
                                    String repositoryUrl, String indexUpdateUrl,
                                    List<? extends IndexCreator> indexCreators, boolean reclaimIndex )
-        throws IOException, UnsupportedExistingLuceneIndexException
+        throws IOException, ExistingLuceneIndexMismatchException
     {
         this( id, repositoryId, repository, repositoryUrl, indexUpdateUrl, indexCreators, indexDirectory, reclaimIndex );
 
@@ -182,7 +183,7 @@ public class DefaultIndexingContext
     }
 
     private void prepareIndex( boolean reclaimIndex )
-        throws IOException, UnsupportedExistingLuceneIndexException
+        throws IOException, ExistingLuceneIndexMismatchException
     {
         if ( IndexReader.indexExists( indexDirectory ) )
         {
@@ -245,7 +246,7 @@ public class DefaultIndexingContext
     }
 
     private void checkAndUpdateIndexDescriptor( boolean reclaimIndex )
-        throws IOException, UnsupportedExistingLuceneIndexException
+        throws IOException, ExistingLuceneIndexMismatchException
     {
         if ( reclaimIndex )
         {
@@ -265,7 +266,7 @@ public class DefaultIndexingContext
 
                 if ( collector.getTotalHits() == 0 )
                 {
-                    throw new UnsupportedExistingLuceneIndexException(
+                    throw new ExistingLuceneIndexMismatchException(
                         "The existing index has no NexusIndexer descriptor" );
                 }
 
@@ -296,7 +297,7 @@ public class DefaultIndexingContext
                     }
                     else if ( !getRepositoryId().equals( repoId ) )
                     {
-                        throw new UnsupportedExistingLuceneIndexException( "The existing index is for repository " //
+                        throw new ExistingLuceneIndexMismatchException( "The existing index is for repository " //
                             + "[" + repoId + "] and not for repository [" + getRepositoryId() + "]" );
                     }
                 }
@@ -360,7 +361,7 @@ public class DefaultIndexingContext
             IndexUtils.deleteTimestamp( indexDirectory );
         }
     }
-    
+
     // ==
 
     public boolean isSearchable()
@@ -592,7 +593,7 @@ public class DefaultIndexingContext
         {
             prepareIndex( true );
         }
-        catch ( UnsupportedExistingLuceneIndexException e )
+        catch ( ExistingLuceneIndexMismatchException e )
         {
             // just deleted it
         }

Copied: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/ExistingLuceneIndexMismatchException.java (from r1410255, maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java)
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/ExistingLuceneIndexMismatchException.java?p2=maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/ExistingLuceneIndexMismatchException.java&p1=maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java&r1=1410255&r2=1410262&rev=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/ExistingLuceneIndexMismatchException.java Fri Nov 16 09:11:10 2012
@@ -1,5 +1,7 @@
 package org.apache.maven.index.context;
 
+import java.io.IOException;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -20,20 +22,23 @@ package org.apache.maven.index.context;
  */
 
 /**
- * Thrown when a user tries to create a NexusInder IndexingContext over and existing Lucene index. The reason for
- * throwing this exception may be multiple: non-NexusIndexer Lucene index, index version is wrong, repositoryId does not
- * matches the context repositoryId, etc.
+ * Thrown when a user tries to create a NexusInder IndexingContext over and existing Lucene index, and there is a
+ * mismatch. The reason for mismatch may be multiple: non-NexusIndexer Lucene index (basically missing the descriptor
+ * document), index version is wrong or unknown, repositoryId from context and descriptor document does not matches,
+ * etc. This exception is not thrown in cases when "reclaim" is done, as in those cases, even if an unknown index is
+ * found, descriptor will be forcefully added with current context information, potentially replacing the existing
+ * descriptor, if any.
  * 
  * @author Tamas Cservenak
+ * @since 5.1.0
  */
-public class UnsupportedExistingLuceneIndexException
-    extends Exception
+public class ExistingLuceneIndexMismatchException
+    extends IOException
 {
-    private static final long serialVersionUID = -3206758653346308322L;
+    private static final long serialVersionUID = -6587046761831878804L;
 
-    public UnsupportedExistingLuceneIndexException( String message )
+    public ExistingLuceneIndexMismatchException( String message )
     {
         super( message );
     }
-
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/MergedIndexingContext.java Fri Nov 16 09:11:10 2012
@@ -83,6 +83,7 @@ public class MergedIndexingContext
         this.directoryFile = indexDirectoryFile;
     }
 
+    @Deprecated
     public MergedIndexingContext( String id, String repositoryId, File repository, Directory indexDirectory,
                                   boolean searchable, ContextMemberProvider membersProvider )
         throws IOException

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/context/UnsupportedExistingLuceneIndexException.java Fri Nov 16 09:11:10 2012
@@ -1,5 +1,8 @@
 package org.apache.maven.index.context;
 
+import org.apache.maven.index.Indexer;
+import org.apache.maven.index.NexusIndexer;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -25,6 +28,7 @@ package org.apache.maven.index.context;
  * matches the context repositoryId, etc.
  * 
  * @author Tamas Cservenak
+ * @deprecated The deprecated {@link NexusIndexer} uses this exception. Use {@link Indexer} instead.
  */
 public class UnsupportedExistingLuceneIndexException
     extends Exception
@@ -36,4 +40,8 @@ public class UnsupportedExistingLuceneIn
         super( message );
     }
 
+    public UnsupportedExistingLuceneIndexException( String message, ExistingLuceneIndexMismatchException e )
+    {
+        super( message, e );
+    }
 }

Modified: maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/treeview/DefaultIndexTreeView.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/treeview/DefaultIndexTreeView.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/treeview/DefaultIndexTreeView.java (original)
+++ maven/indexer/trunk/indexer-core/src/main/java/org/apache/maven/index/treeview/DefaultIndexTreeView.java Fri Nov 16 09:11:10 2012
@@ -30,10 +30,10 @@ import org.apache.lucene.search.BooleanQ
 import org.apache.lucene.search.Query;
 import org.apache.maven.index.ArtifactInfo;
 import org.apache.maven.index.Field;
+import org.apache.maven.index.Indexer;
 import org.apache.maven.index.IteratorSearchRequest;
 import org.apache.maven.index.IteratorSearchResponse;
 import org.apache.maven.index.MAVEN;
-import org.apache.maven.index.NexusIndexer;
 import org.apache.maven.index.expr.SourcedSearchExpression;
 import org.apache.maven.index.treeview.TreeNode.Type;
 import org.codehaus.plexus.component.annotations.Component;
@@ -47,11 +47,11 @@ public class DefaultIndexTreeView
     implements IndexTreeView
 {
     @Requirement
-    private NexusIndexer nexusIndexer;
+    private Indexer indexer;
 
-    protected NexusIndexer getNexusIndexer()
+    protected Indexer getIndexer()
     {
-        return nexusIndexer;
+        return indexer;
     }
 
     public TreeNode listNodes( TreeViewRequest request )
@@ -498,16 +498,16 @@ public class DefaultIndexTreeView
         Query versionQ = null;
 
         // minimum must have
-        groupIdQ = getNexusIndexer().constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( g ) );
+        groupIdQ = getIndexer().constructQuery( MAVEN.GROUP_ID, new SourcedSearchExpression( g ) );
 
         if ( StringUtils.isNotBlank( a ) )
         {
-            artifactIdQ = getNexusIndexer().constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( a ) );
+            artifactIdQ = getIndexer().constructQuery( MAVEN.ARTIFACT_ID, new SourcedSearchExpression( a ) );
         }
 
         if ( StringUtils.isNotBlank( v ) )
         {
-            versionQ = getNexusIndexer().constructQuery( MAVEN.VERSION, new SourcedSearchExpression( v ) );
+            versionQ = getIndexer().constructQuery( MAVEN.VERSION, new SourcedSearchExpression( v ) );
         }
 
         BooleanQuery q = new BooleanQuery();
@@ -528,7 +528,7 @@ public class DefaultIndexTreeView
 
         searchRequest.getContexts().add( request.getIndexingContext() );
 
-        IteratorSearchResponse result = getNexusIndexer().searchIterator( searchRequest );
+        IteratorSearchResponse result = getIndexer().searchIterator( searchRequest );
 
         return result;
     }

Modified: maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/FullBootProofOfConcept.java
URL: http://svn.apache.org/viewvc/maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/FullBootProofOfConcept.java?rev=1410262&r1=1410261&r2=1410262&view=diff
==============================================================================
--- maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/FullBootProofOfConcept.java (original)
+++ maven/indexer/trunk/indexer-core/src/test/java/org/apache/maven/index/updater/FullBootProofOfConcept.java Fri Nov 16 09:11:10 2012
@@ -54,6 +54,10 @@ public class FullBootProofOfConcept
             {
                 run( basedir );
             }
+            catch ( UnsupportedExistingLuceneIndexException e )
+            {
+                e.printStackTrace();
+            }
             catch ( IOException e )
             {
                 e.printStackTrace();
@@ -70,10 +74,6 @@ public class FullBootProofOfConcept
             {
                 e.printStackTrace();
             }
-            catch ( UnsupportedExistingLuceneIndexException e )
-            {
-                e.printStackTrace();
-            }
             finally
             {
                 try



Mime
View raw message