mirror of https://github.com/apache/archiva.git
Added javadoc annotations
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@359161 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4ee2ce3e6
commit
deba390c88
|
@ -27,6 +27,7 @@ import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Abstract class for RepositoryIndexers
|
||||||
*
|
*
|
||||||
* @author Edwin Punzalan
|
* @author Edwin Punzalan
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +39,9 @@ public abstract class AbstractRepositoryIndexer
|
||||||
protected IndexReader indexReader;
|
protected IndexReader indexReader;
|
||||||
protected IndexWriter indexWriter;
|
protected IndexWriter indexWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method to encapsulate the optimize() method for lucene
|
||||||
|
*/
|
||||||
public void optimize()
|
public void optimize()
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
@ -56,11 +60,19 @@ public abstract class AbstractRepositoryIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method used to query the index status
|
||||||
|
*
|
||||||
|
* @param true if the index is open.
|
||||||
|
*/
|
||||||
public boolean isOpen()
|
public boolean isOpen()
|
||||||
{
|
{
|
||||||
return indexOpen;
|
return indexOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method used to close all open streams to the index directory
|
||||||
|
*/
|
||||||
public void close()
|
public void close()
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
@ -86,6 +98,9 @@ public abstract class AbstractRepositoryIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method for opening the index directory for indexing operations
|
||||||
|
*/
|
||||||
public void open()
|
public void open()
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
@ -99,7 +114,6 @@ public abstract class AbstractRepositoryIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void getIndexWriter()
|
protected void getIndexWriter()
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
@ -123,6 +137,11 @@ public abstract class AbstractRepositoryIndexer
|
||||||
return new ArtifactRepositoryIndexAnalyzer( new SimpleAnalyzer() );
|
return new ArtifactRepositoryIndexAnalyzer( new SimpleAnalyzer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method for validating an index directory
|
||||||
|
*
|
||||||
|
* @throws RepositoryIndexerException if the given indexPath is not valid for this type of RepositoryIndexer
|
||||||
|
*/
|
||||||
protected void validateIndex()
|
protected void validateIndex()
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.lucene.analysis.CharTokenizer;
|
||||||
import org.apache.lucene.analysis.TokenStream;
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class created specifically to index artifacts
|
||||||
*
|
*
|
||||||
* @author Edwin Punzalan
|
* @author Edwin Punzalan
|
||||||
*/
|
*/
|
||||||
|
@ -33,12 +34,25 @@ public class ArtifactRepositoryIndexAnalyzer
|
||||||
{
|
{
|
||||||
private Analyzer defaultAnalyzer;
|
private Analyzer defaultAnalyzer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor to for this analyzer
|
||||||
|
*
|
||||||
|
* @character defaultAnalyzer the analyzer to use as default for the general fields of the artifact indeces
|
||||||
|
*/
|
||||||
public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
|
public ArtifactRepositoryIndexAnalyzer( Analyzer defaultAnalyzer )
|
||||||
{
|
{
|
||||||
this.defaultAnalyzer = defaultAnalyzer;
|
this.defaultAnalyzer = defaultAnalyzer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TokenStream tokenStream(String fieldName, Reader reader)
|
/**
|
||||||
|
* Method called by lucence during indexing operations
|
||||||
|
*
|
||||||
|
* @character fieldName the field name that the lucene object is currently processing
|
||||||
|
* @character reader a Reader object to the index stream
|
||||||
|
*
|
||||||
|
* @return an analyzer to specific to the field name or the default analyzer if none is present
|
||||||
|
*/
|
||||||
|
public TokenStream tokenStream( String fieldName, Reader reader )
|
||||||
{
|
{
|
||||||
TokenStream tokenStream;
|
TokenStream tokenStream;
|
||||||
|
|
||||||
|
@ -54,19 +68,34 @@ public class ArtifactRepositoryIndexAnalyzer
|
||||||
return tokenStream;
|
return tokenStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class used to tokenize an artifact's version.
|
||||||
|
*/
|
||||||
private class VersionTokenizer
|
private class VersionTokenizer
|
||||||
extends CharTokenizer
|
extends CharTokenizer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Constructor with the required reader to the index stream
|
||||||
|
*
|
||||||
|
* @reader the Reader object of the index stream
|
||||||
|
*/
|
||||||
public VersionTokenizer( Reader reader )
|
public VersionTokenizer( Reader reader )
|
||||||
{
|
{
|
||||||
super( reader );
|
super( reader );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isTokenChar( char param )
|
/**
|
||||||
|
* method that lucene calls to check tokenization of a stream character
|
||||||
|
*
|
||||||
|
* @param character char currently being processed
|
||||||
|
*
|
||||||
|
* @return true if the char is a token, false if the char is a stop char
|
||||||
|
*/
|
||||||
|
protected boolean isTokenChar( char character )
|
||||||
{
|
{
|
||||||
boolean token;
|
boolean token;
|
||||||
|
|
||||||
switch( param )
|
switch( character )
|
||||||
{
|
{
|
||||||
case '.':
|
case '.':
|
||||||
case '-':
|
case '-':
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Class used to index Artifact objects in a specified repository
|
||||||
*
|
*
|
||||||
* @author Edwin Punzalan
|
* @author Edwin Punzalan
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +63,14 @@ public class ArtifactRepositoryIndexer
|
||||||
private StringBuffer packages;
|
private StringBuffer packages;
|
||||||
private StringBuffer files;
|
private StringBuffer files;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @todo change repository to layout ???
|
||||||
|
*
|
||||||
|
* @param repository the repository where the indexed artifacts are located. This is necessary only to distinguish
|
||||||
|
* between default and legacy directory structure of the artifact location.
|
||||||
|
* @param path the directory where the index is located or will be created.
|
||||||
|
*/
|
||||||
public ArtifactRepositoryIndexer( ArtifactRepository repository, String path )
|
public ArtifactRepositoryIndexer( ArtifactRepository repository, String path )
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
@ -70,11 +79,21 @@ public class ArtifactRepositoryIndexer
|
||||||
validateIndex();
|
validateIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method for collecting the available index fields usable for searching
|
||||||
|
*
|
||||||
|
* @return index field names
|
||||||
|
*/
|
||||||
public String[] getIndexFields()
|
public String[] getIndexFields()
|
||||||
{
|
{
|
||||||
return FIELDS;
|
return FIELDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* generic method for indexing
|
||||||
|
*
|
||||||
|
* @param obj the object to be indexed by this indexer
|
||||||
|
*/
|
||||||
public void addObjectIndex(Object obj)
|
public void addObjectIndex(Object obj)
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
@ -89,6 +108,11 @@ public class ArtifactRepositoryIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method to index a given artifact
|
||||||
|
*
|
||||||
|
* @param artifact the Artifact object to be indexed
|
||||||
|
*/
|
||||||
public void addArtifactIndex( Artifact artifact )
|
public void addArtifactIndex( Artifact artifact )
|
||||||
throws RepositoryIndexerException
|
throws RepositoryIndexerException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue