org.apache.maven.index
Class DefaultNexusIndexer

java.lang.Object
  extended by org.codehaus.plexus.logging.AbstractLogEnabled
      extended by org.apache.maven.index.DefaultNexusIndexer
All Implemented Interfaces:
NexusIndexer, org.codehaus.plexus.logging.LogEnabled

@Component(role=NexusIndexer.class)
public class DefaultNexusIndexer
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements NexusIndexer

A default NexusIndexer implementation.

Author:
Tamas Cservenak, Eugene Kuleshov

Field Summary
 
Fields inherited from interface org.apache.maven.index.NexusIndexer
ROLE
 
Constructor Summary
DefaultNexusIndexer()
           
 
Method Summary
 void addArtifactsToIndex(Collection<ArtifactContext> ac, IndexingContext context)
           
 void addArtifactToIndex(ArtifactContext ac, IndexingContext context)
          Delegates to the IndexerEngine to update artifact to the index
 IndexingContext addIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers)
          Adds an indexing context to Nexus indexer.
 IndexingContext addIndexingContext(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers)
          Adds an indexing context to Nexus indexer.
 IndexingContext addIndexingContextForced(String id, String repositoryId, File repository, org.apache.lucene.store.Directory directory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers)
          Adds an indexing context to Nexus indexer.
 IndexingContext addIndexingContextForced(String id, String repositoryId, File repository, File indexDirectory, String repositoryUrl, String indexUpdateUrl, List<? extends IndexCreator> indexers)
          Adds an indexing context to Nexus indexer.
 IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, Collection<IndexingContext> contexts)
           
 IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, org.apache.lucene.store.Directory indexDirectory, boolean searchable, ContextMemberProvider membersProvider)
           
 IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, Collection<IndexingContext> contexts)
           
 IndexingContext addMergedIndexingContext(String id, String repositoryId, File repository, File indexDirectory, boolean searchable, ContextMemberProvider membersProvider)
           
 void artifactDiscovered(ArtifactContext ac, IndexingContext context)
          Delegates to the IndexerEngine to add a new artifact to the index
 org.apache.lucene.search.Query constructQuery(Field field, SearchExpression expression)
          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.
 org.apache.lucene.search.Query constructQuery(Field field, String query, SearchType type)
          Deprecated. 
 void deleteArtifactFromIndex(ArtifactContext ac, IndexingContext context)
          Delegates to the IndexerEngine to remove artifact from the index
 void deleteArtifactsFromIndex(Collection<ArtifactContext> ac, IndexingContext context)
           
 Map<String,IndexingContext> getIndexingContexts()
          Returns the map of indexing contexts keyed by their ID.
 Collection<ArtifactInfo> identify(Field field, String query)
           
 Collection<ArtifactInfo> identify(File artifact)
           
 Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts)
           
 Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query)
           
 Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query, Collection<IndexingContext> contexts)
           
 void removeIndexingContext(IndexingContext context, boolean deleteFiles)
          Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.
 void scan(IndexingContext context)
          Performs full scan (reindex) for the local repository belonging to supplied context.
 void scan(IndexingContext context, ArtifactScanningListener listener)
          Performs full scan (reindex) for the local repository belonging to supplied context.
 void scan(IndexingContext context, ArtifactScanningListener listener, boolean update)
          Performs optionally incremental scan (reindex) for the local repository, with listener.
 void scan(IndexingContext context, boolean update)
          Performs optionally incremental scan (reindex/full reindex) for the local repository belonging to the supplied context.
 void scan(IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update)
          Uses Scanner to scan repository content.
 FlatSearchResponse searchFlat(FlatSearchRequest request)
          Searches according the request parameters.
 GroupedSearchResponse searchGrouped(GroupedSearchRequest request)
          Searches according the request parameters.
 IteratorSearchResponse searchIterator(IteratorSearchRequest request)
          Searches according to request parameters.
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNexusIndexer

public DefaultNexusIndexer()
Method Detail

addIndexingContext

public IndexingContext addIndexingContext(String id,
                                          String repositoryId,
                                          File repository,
                                          File indexDirectory,
                                          String repositoryUrl,
                                          String indexUpdateUrl,
                                          List<? extends IndexCreator> indexers)
                                   throws IOException,
                                          UnsupportedExistingLuceneIndexException
Description copied from interface: NexusIndexer
Adds an indexing context to Nexus indexer.

Specified by:
addIndexingContext in interface NexusIndexer
Parameters:
id - the ID of the context.
repositoryId - the ID of the repository that this context represents.
repository - the location of the repository.
indexDirectory - the location of the Lucene indexes.
repositoryUrl - the location of the remote repository.
indexUpdateUrl - the alternate location of the remote repository indexes (if they are not in default place).
indexers - the set of indexers to apply to this context.
Returns:
Throws:
IOException - in case of some serious IO problem.
UnsupportedExistingLuceneIndexException - 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.

addIndexingContextForced

public IndexingContext addIndexingContextForced(String id,
                                                String repositoryId,
                                                File repository,
                                                File indexDirectory,
                                                String repositoryUrl,
                                                String indexUpdateUrl,
                                                List<? extends IndexCreator> indexers)
                                         throws IOException
Description copied from interface: NexusIndexer
Adds an indexing context to Nexus indexer. It "forces" this operation, thus no UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply stomp-over and rewrite (or add) the Nexus index descriptor.

Specified by:
addIndexingContextForced in interface NexusIndexer
Parameters:
id - the ID of the context.
repositoryId - the ID of the repository that this context represents.
repository - the location of the repository.
indexDirectory - the location of the Lucene indexes.
repositoryUrl - the location of the remote repository.
indexUpdateUrl - the alternate location of the remote repository indexes (if they are not in default place).
indexers - the set of indexers to apply to this context.
Returns:
Throws:
IOException - in case of some serious IO problem.

addIndexingContext

public IndexingContext addIndexingContext(String id,
                                          String repositoryId,
                                          File repository,
                                          org.apache.lucene.store.Directory directory,
                                          String repositoryUrl,
                                          String indexUpdateUrl,
                                          List<? extends IndexCreator> indexers)
                                   throws IOException,
                                          UnsupportedExistingLuceneIndexException
Description copied from interface: NexusIndexer
Adds an indexing context to Nexus indexer.

Specified by:
addIndexingContext in interface NexusIndexer
Parameters:
id - the ID of the context.
repositoryId - the ID of the repository that this context represents.
repository - the location of the repository.
directory - the location of the Lucene indexes.
repositoryUrl - the location of the remote repository.
indexUpdateUrl - the alternate location of the remote repository indexes (if they are not in default place).
indexers - the set of indexers to apply to this context.
Returns:
Throws:
IOException - in case of some serious IO problem.
UnsupportedExistingLuceneIndexException - 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.

addIndexingContextForced

public IndexingContext addIndexingContextForced(String id,
                                                String repositoryId,
                                                File repository,
                                                org.apache.lucene.store.Directory directory,
                                                String repositoryUrl,
                                                String indexUpdateUrl,
                                                List<? extends IndexCreator> indexers)
                                         throws IOException
Description copied from interface: NexusIndexer
Adds an indexing context to Nexus indexer. It "forces" this operation, thus no UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply stomp-over and rewrite (or add) the Nexus index descriptor.

Specified by:
addIndexingContextForced in interface NexusIndexer
Parameters:
id - the ID of the context.
repositoryId - the ID of the repository that this context represents.
repository - the location of the repository.
directory - the location of the Lucene indexes.
repositoryUrl - the location of the remote repository.
indexUpdateUrl - the alternate location of the remote repository indexes (if they are not in default place).
indexers - the set of indexers to apply to this context.
Returns:
Throws:
IOException - in case of some serious IO problem.

addMergedIndexingContext

public IndexingContext addMergedIndexingContext(String id,
                                                String repositoryId,
                                                File repository,
                                                File indexDirectory,
                                                boolean searchable,
                                                Collection<IndexingContext> contexts)
                                         throws IOException
Specified by:
addMergedIndexingContext in interface NexusIndexer
Throws:
IOException

addMergedIndexingContext

public IndexingContext addMergedIndexingContext(String id,
                                                String repositoryId,
                                                File repository,
                                                File indexDirectory,
                                                boolean searchable,
                                                ContextMemberProvider membersProvider)
                                         throws IOException
Specified by:
addMergedIndexingContext in interface NexusIndexer
Throws:
IOException

addMergedIndexingContext

public IndexingContext addMergedIndexingContext(String id,
                                                String repositoryId,
                                                File repository,
                                                org.apache.lucene.store.Directory indexDirectory,
                                                boolean searchable,
                                                Collection<IndexingContext> contexts)
                                         throws IOException
Specified by:
addMergedIndexingContext in interface NexusIndexer
Throws:
IOException

addMergedIndexingContext

public IndexingContext addMergedIndexingContext(String id,
                                                String repositoryId,
                                                File repository,
                                                org.apache.lucene.store.Directory indexDirectory,
                                                boolean searchable,
                                                ContextMemberProvider membersProvider)
                                         throws IOException
Specified by:
addMergedIndexingContext in interface NexusIndexer
Throws:
IOException

removeIndexingContext

public void removeIndexingContext(IndexingContext context,
                                  boolean deleteFiles)
                           throws IOException
Description copied from interface: NexusIndexer
Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.

Specified by:
removeIndexingContext in interface NexusIndexer
Throws:
IOException

getIndexingContexts

public Map<String,IndexingContext> getIndexingContexts()
Description copied from interface: NexusIndexer
Returns the map of indexing contexts keyed by their ID.

Specified by:
getIndexingContexts in interface NexusIndexer

scan

public void scan(IndexingContext context)
          throws IOException
Description copied from interface: NexusIndexer
Performs full scan (reindex) for the local repository belonging to supplied context.

Specified by:
scan in interface NexusIndexer
Throws:
IOException

scan

public void scan(IndexingContext context,
                 boolean update)
          throws IOException
Description copied from interface: NexusIndexer
Performs optionally incremental scan (reindex/full reindex) for the local repository belonging to the supplied context.

Specified by:
scan in interface NexusIndexer
update - if incremental reindex wanted, set true, otherwise false and full reindex will happenF
Throws:
IOException

scan

public void scan(IndexingContext context,
                 ArtifactScanningListener listener)
          throws IOException
Description copied from interface: NexusIndexer
Performs full scan (reindex) for the local repository belonging to supplied context. ArtifactListener is used during that process.

Specified by:
scan in interface NexusIndexer
Throws:
IOException

scan

public void scan(IndexingContext context,
                 ArtifactScanningListener listener,
                 boolean update)
          throws IOException
Description copied from interface: NexusIndexer
Performs optionally incremental scan (reindex) for the local repository, with listener.

Specified by:
scan in interface NexusIndexer
update - if incremental reindex wanted, set true, otherwise false and full reindex will happenF
Throws:
IOException

scan

public void scan(IndexingContext context,
                 String fromPath,
                 ArtifactScanningListener listener,
                 boolean update)
          throws IOException
Uses Scanner to scan repository content. A ArtifactScanningListener is used to process found artifacts and to add them to the index using NexusIndexer.artifactDiscovered(ArtifactContext, IndexingContext).

Specified by:
scan in interface NexusIndexer
fromPath - a path segment if you want "sub-path" reindexing (ie. reindex just a given subfolder of a repository, ot whole repository from root.
update - if incremental reindex wanted, set true, otherwise false and full reindex will happenF
Throws:
IOException
See Also:
DefaultScannerListener, artifactDiscovered(ArtifactContext, IndexingContext)

artifactDiscovered

public void artifactDiscovered(ArtifactContext ac,
                               IndexingContext context)
                        throws IOException
Delegates to the IndexerEngine to add a new artifact to the index

Specified by:
artifactDiscovered in interface NexusIndexer
Throws:
IOException

addArtifactToIndex

public void addArtifactToIndex(ArtifactContext ac,
                               IndexingContext context)
                        throws IOException
Delegates to the IndexerEngine to update artifact to the index

Specified by:
addArtifactToIndex in interface NexusIndexer
Throws:
IOException

addArtifactsToIndex

public void addArtifactsToIndex(Collection<ArtifactContext> ac,
                                IndexingContext context)
                         throws IOException
Specified by:
addArtifactsToIndex in interface NexusIndexer
Throws:
IOException

deleteArtifactFromIndex

public void deleteArtifactFromIndex(ArtifactContext ac,
                                    IndexingContext context)
                             throws IOException
Delegates to the IndexerEngine to remove artifact from the index

Specified by:
deleteArtifactFromIndex in interface NexusIndexer
Throws:
IOException

deleteArtifactsFromIndex

public void deleteArtifactsFromIndex(Collection<ArtifactContext> ac,
                                     IndexingContext context)
                              throws IOException
Specified by:
deleteArtifactsFromIndex in interface NexusIndexer
Throws:
IOException

searchFlat

public FlatSearchResponse searchFlat(FlatSearchRequest request)
                              throws IOException
Description copied from interface: NexusIndexer
Searches according the request parameters.

Specified by:
searchFlat in interface NexusIndexer
Returns:
Throws:
IOException

searchIterator

public IteratorSearchResponse searchIterator(IteratorSearchRequest request)
                                      throws IOException
Description copied from interface: NexusIndexer
Searches according to request parameters.

Specified by:
searchIterator in interface NexusIndexer
Returns:
Throws:
IOException

searchGrouped

public GroupedSearchResponse searchGrouped(GroupedSearchRequest request)
                                    throws IOException
Description copied from interface: NexusIndexer
Searches according the request parameters.

Specified by:
searchGrouped in interface NexusIndexer
Returns:
Throws:
IOException

constructQuery

@Deprecated
public org.apache.lucene.search.Query constructQuery(Field field,
                                                                String query,
                                                                SearchType type)
                                              throws IllegalArgumentException
Deprecated. 

Description copied from interface: NexusIndexer
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.

Specified by:
constructQuery in interface NexusIndexer
Returns:
Throws:
IllegalArgumentException

constructQuery

public org.apache.lucene.search.Query constructQuery(Field field,
                                                     SearchExpression expression)
                                              throws IllegalArgumentException
Description copied from interface: NexusIndexer
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.

Specified by:
constructQuery in interface NexusIndexer
Returns:
Throws:
IllegalArgumentException

identify

public Collection<ArtifactInfo> identify(Field field,
                                         String query)
                                  throws IllegalArgumentException,
                                         IOException
Specified by:
identify in interface NexusIndexer
Throws:
IllegalArgumentException
IOException

identify

public Collection<ArtifactInfo> identify(File artifact)
                                  throws IOException
Specified by:
identify in interface NexusIndexer
Throws:
IOException

identify

public Collection<ArtifactInfo> identify(File artifact,
                                         Collection<IndexingContext> contexts)
                                  throws IOException
Specified by:
identify in interface NexusIndexer
Throws:
IOException

identify

public Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query)
                                  throws IOException
Specified by:
identify in interface NexusIndexer
Throws:
IOException

identify

public Collection<ArtifactInfo> identify(org.apache.lucene.search.Query query,
                                         Collection<IndexingContext> contexts)
                                  throws IOException
Specified by:
identify in interface NexusIndexer
Throws:
IOException


Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.