protected ArtifactRepository repository;
+ /**
+ * Class constructor
+ *
+ * @param indexPath
+ * @param repository
+ * @param indexFields
+ * @throws RepositoryIndexException
+ */
protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository, String[] indexFields )
throws RepositoryIndexException
{
}
/**
- * method to encapsulate the optimize() method for lucene
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#optimize()
*/
public void optimize()
throws RepositoryIndexException
}
/**
- * method used to query the index status
- *
- * @return true if the index is open.
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#isOpen()
*/
public boolean isOpen()
{
}
/**
- * method used to close all open streams to the index directory
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#close()
*/
public void close()
throws RepositoryIndexException
}
}
+ /**
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#getIndexPath()
+ */
public String getIndexPath()
{
return indexPath;
}
+ /**
+ * Method to retrieve the lucene IndexWriter used in creating/updating the index
+ *
+ * @return the lucene IndexWriter object used to update the index
+ * @throws IOException
+ */
protected IndexWriter getIndexWriter()
throws IOException
{
indexOpen = true;
}
+ /**
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#getRepository()
+ */
public ArtifactRepository getRepository()
{
return repository;
import java.util.List;
/**
- *
+ * Abstract Class to hold common codes for the different RepositoryIndexSearcher
*/
public abstract class AbstractRepositoryIndexSearcher
extends AbstractLogEnabled
}
/**
- * Search the artifact based on the search criteria specified in the query
- * object. Returns a list of artifact objects
- *
- * @param query the query object that contains the search criteria
- * @return List
- * @throws RepositoryIndexSearchException
+ * @see RepositoryIndexSearcher#search(org.apache.maven.repository.indexing.query.Query)
*/
public List search( Query query )
throws RepositoryIndexSearchException
return docs;
}
+ /**
+ * Method to create a lucene Query object from a single query phrase
+ *
+ * @param field the index field name to search into
+ * @param value the index field value to match the field with
+ * @return a lucene Query object representing the query phrase field = value
+ * @throws ParseException
+ */
private org.apache.lucene.search.Query createLuceneQuery( String field, String value )
throws ParseException
{
return qry;
}
+ /**
+ * Method to create a lucene Query object by converting a prepared Query object
+ *
+ * @param query the prepared Query object to be converted into a lucene Query object
+ * @return a lucene Query object to represent the passed Query object
+ * @throws ParseException
+ */
private org.apache.lucene.search.Query createLuceneQuery( Query query )
throws ParseException
{
/**
- * Class used to index Artifact objects in a specified repository
+ * Class used to index Artifact objects in a specific repository
*
* @author Edwin Punzalan
*/
private Digester digester;
+ /**
+ * Class constructor
+ *
+ * @param indexPath the path where the lucene index will be created/updated.
+ * @param repository the repository where the indexed artifacts are located
+ * @param digester the digester object to generate the checksum strings
+ * @throws RepositoryIndexException
+ */
public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
throws RepositoryIndexException
{
}
/**
- * method to get the Analyzer used to create indices
- *
- * @return the Analyzer object used to create the artifact indices
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#getAnalyzer()
*/
public Analyzer getAnalyzer()
{
}
/**
- * method to index a given artifact
+ * Method to index a given artifact
*
* @param artifact the Artifact object to be indexed
+ * @throws RepositoryIndexException
*/
public void indexArtifact( Artifact artifact )
throws RepositoryIndexException
}
}
+ /**
+ * @see RepositoryIndex#isKeywordField(String)
+ */
public boolean isKeywordField( String field )
{
return false;
}
+ /**
+ * Method to test a zip entry if it is a java class, and adds it to the classes buffer
+ *
+ * @param entry the zip entry to test for java class
+ * @param classes the String buffer to add the java class if the test result as true
+ * @return true if the zip entry is a java class and was successfully added to the buffer
+ */
private boolean addIfClassEntry( ZipEntry entry, StringBuffer classes )
{
boolean isAdded = false;
return isAdded;
}
+ /**
+ * Method to add a class package to the buffer of packages
+ *
+ * @param name the complete path name of the class
+ * @param packages the packages buffer
+ * @return true if the package is successfully added
+ */
private boolean addClassPackage( String name, StringBuffer packages )
{
boolean isAdded = false;
return isAdded;
}
+ /**
+ * Method to add the zip entry as a file list
+ *
+ * @param entry the zip entry to be added
+ * @param files the buffer of files to update
+ * @return true if the file was successfully added
+ */
private boolean addFile( ZipEntry entry, StringBuffer files )
{
String name = entry.getName();
* This class searches the index for existing artifacts that contains the
* specified query string.
*
- * @author Maria Odea Ching
*/
public class ArtifactRepositoryIndexSearcher
extends AbstractRepositoryIndexSearcher
this.factory = factory;
}
+ /**
+ * @see AbstractRepositoryIndexSearcher#createSearchedObjectFromIndexDocument(org.apache.lucene.document.Document)
+ */
protected Object createSearchedObjectFromIndexDocument( Document doc )
{
String groupId = doc.get( ArtifactRepositoryIndex.FLD_GROUPID );
*/
private ArtifactFactory artifactFactory;
+ /**
+ * @see RepositoryIndexingFactory#createArtifactRepositoryIndexSearcher(ArtifactRepositoryIndex)
+ */
public ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index )
{
return new ArtifactRepositoryIndexSearcher( index, artifactFactory );
}
+ /**
+ * @see RepositoryIndexingFactory#createArtifactRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
+ */
public ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new ArtifactRepositoryIndex( indexPath, repository, digester );
}
+ /**
+ * @see RepositoryIndexingFactory#createPomRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
+ */
public PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new PomRepositoryIndex( indexPath, repository, digester, artifactFactory );
}
+ /**
+ * @see RepositoryIndexingFactory#createPomRepositoryIndexSearcher(PomRepositoryIndex)
+ */
public PomRepositoryIndexSearcher createPomRepositoryIndexSearcher( PomRepositoryIndex index )
{
return new PomRepositoryIndexSearcher( index, artifactFactory );
import java.util.List;
/**
+ * Class to create index entries for a given pom in a repository
+ *
* @author Edwin Punzalan
*/
public class PomRepositoryIndex
private static final List KEYWORD_FIELDS = Arrays.asList(
new String[]{FLD_LICENSE_URLS, FLD_DEPENDENCIES, FLD_PLUGINS_BUILD, FLD_PLUGINS_REPORT, FLD_PLUGINS_ALL} );
+ /**
+ * Class Constructor
+ *
+ * @param indexPath the path where the index is available or will be made available
+ * @param repository the repository where objects indexed by this class resides
+ * @param digester the digester to be used for generating checksums
+ * @param artifactFactory the factory for building artifact objects
+ * @throws RepositoryIndexException
+ */
public PomRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester,
ArtifactFactory artifactFactory )
throws RepositoryIndexException
this.artifactFactory = artifactFactory;
}
+ /**
+ * @see org.apache.maven.repository.indexing.RepositoryIndex#getAnalyzer()
+ */
public Analyzer getAnalyzer()
{
if ( analyzer == null )
return analyzer;
}
+ /**
+ * Method to create the index fields for a Model object into the index
+ *
+ * @param pom the Model object to be indexed
+ * @throws RepositoryIndexException
+ */
public void indexPom( Model pom )
throws RepositoryIndexException
{
}
}
+ /**
+ * @see RepositoryIndex#isKeywordField(String)
+ */
public boolean isKeywordField( String field )
{
return KEYWORD_FIELDS.contains( field );
}
+ /**
+ * Method to index license urls found inside the passed pom
+ *
+ * @param doc the index object to create the fields for the license urls
+ * @param pom the Model object to be indexed
+ */
private void indexLicenseUrls( Document doc, Model pom )
{
List licenseList = pom.getLicenses();
}
}
+ /**
+ * Method to index declared dependencies found inside the passed pom
+ *
+ * @param doc the index object to create the fields for the dependencies
+ * @param pom the Model object to be indexed
+ */
private void indexDependencies( Document doc, Model pom )
{
List dependencyList = pom.getDependencies();
}
}
+ /**
+ * Method to index plugins to a specified index field
+ *
+ * @param doc the index object to create the fields for the plugins
+ * @param field the index field to store the passed plugin
+ * @param plugins the iterator to the list of plugins to be indexed
+ */
private void indexPlugins( Document doc, String field, Iterator plugins )
{
while ( plugins.hasNext() )
}
}
+ /**
+ * Method to index report plugins to a specified index field
+ *
+ * @param doc the index object to create the fields for the report plugins
+ * @param field the index field to store the passed report plugin
+ * @param plugins the iterator to the list of report plugins to be indexed
+ */
private void indexReportPlugins( Document doc, String field, Iterator plugins )
{
while ( plugins.hasNext() )
}
}
+ /**
+ * Method to generate the computed checksum of an existing file using the specified algorithm.
+ *
+ * @param algorithm the algorithm to be used to generate the checksum
+ * @param file the file to match the generated checksum
+ * @return a string representing the checksum
+ * @throws RepositoryIndexException
+ */
private String getChecksum( String algorithm, String file )
throws RepositoryIndexException
{
}
}
+ /**
+ * Method to create the unique artifact id to represent the artifact in the repository
+ *
+ * @param groupId the artifact groupId
+ * @param artifactId the artifact artifactId
+ * @param version the artifact version
+ * @return the String id to uniquely represent the artifact
+ */
private String getId( String groupId, String artifactId, String version )
{
return groupId + ":" + artifactId + ":" + version;
import org.apache.maven.artifact.factory.ArtifactFactory;
/**
+ * The PomRepositoryIndexSearcher is used to search for artifacts in the index created by a PomRepositoryIndex class.
+ *
* @author Edwin Punzalan
*/
public class PomRepositoryIndexSearcher
{
private ArtifactFactory factory;
+ /**
+ *
+ * @param index the PomRepositoryIndex
+ * @param artifactFactory
+ */
public PomRepositoryIndexSearcher( RepositoryIndex index, ArtifactFactory artifactFactory )
{
super( index );
this.factory = artifactFactory;
}
+ /**
+ * @see AbstractRepositoryIndexSearcher#createSearchedObjectFromIndexDocument(org.apache.lucene.document.Document)
+ */
protected Object createSearchedObjectFromIndexDocument( Document doc )
{
String groupId = doc.get( PomRepositoryIndex.FLD_GROUPID );
*/
public interface RepositoryIndex
{
+ /**
+ * Method used to query the index status
+ *
+ * @return true if the index is open.
+ */
boolean isOpen();
+ /**
+ * Method to close open streams to the index directory
+ */
void close()
throws RepositoryIndexException;
ArtifactRepository getRepository();
+ /**
+ * Method to encapsulate the optimize() method for lucene
+ */
void optimize()
throws RepositoryIndexException;
+ /**
+ * Method to retrieve the lucene analyzer object used in creating the document fields for this index
+ *
+ * @return lucene Analyzer object used in creating the index fields
+ */
Analyzer getAnalyzer();
+ /**
+ * Method to retrieve the path where the index is made available
+ *
+ * @return the path where the index resides
+ */
String getIndexPath();
+ /**
+ * Tests an index field if it is a keyword field
+ *
+ * @param field the name of the index field to test
+ * @return true if the index field passed is a keyword, otherwise its false
+ */
boolean isKeywordField( String field );
}
import java.util.List;
/**
- * @author Maria Odea Ching
+ *
*/
public interface RepositoryIndexSearcher
{
{
String ROLE = RepositoryIndexingFactory.class.getName();
+ /**
+ * Method to create an instance of the ArtifactRepositoryIndexSearcher
+ *
+ * @param index the ArtifactRepositoryIndex instance that the returned searcher will be searching into
+ * @return the ArtifactRepositoryIndexSearcher instance
+ */
ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index );
+ /**
+ * Method to create an instance of the ArtifactRepositoryIndex
+ *
+ * @param indexPath the path where the index will be created/updated
+ * @param repository the repository where the indexed artifacts are located
+ * @return the ArtifactRepositoryIndex instance
+ * @throws RepositoryIndexException
+ */
ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
+ /**
+ * Method to create an instance of the PomRepositoryIndex
+ *
+ * @param indexPath the path where the index will be created/updated
+ * @param repository the repository where the indexed poms are located
+ * @return the PomRepositoryIndex instance
+ * @throws RepositoryIndexException
+ */
PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
throws RepositoryIndexException;
+ /**
+ * Method to create an instance of the PomRepositoryIndexSearcher
+ *
+ * @param index the PomRepositoryIndex instance that the returned searcher will be searching into
+ * @return the PomRepositoryIndexSearcher instance
+ */
PomRepositoryIndexSearcher createPomRepositoryIndexSearcher( PomRepositoryIndex index );
}
*/
private Query query;
+ /**
+ * Class constructor
+ *
+ * @param query the query represented by this object
+ */
protected AbstractCompoundQueryTerm( Query query )
{
this.query = query;
}
+ /**
+ * @see CompoundQueryTerm#isRequired()
+ */
public boolean isRequired()
{
return false;
}
+ /**
+ * @see CompoundQueryTerm#isProhibited()
+ */
public boolean isProhibited()
{
return false;
}
+ /**
+ * @see CompoundQueryTerm#getQuery()
+ */
public Query getQuery()
{
return query;
public class AndQueryTerm
extends AbstractCompoundQueryTerm
{
+ /**
+ * Class constructor
+ *
+ * @param query the Query object represented by this object
+ */
public AndQueryTerm( Query query )
{
super( query );
}
+ /**
+ * @see AbstractCompoundQueryTerm#isRequired()
+ */
public boolean isRequired()
{
return true;
import java.util.List;
/**
+ * Class to hold multiple SinglePhraseQueries and/or other CompoundQueries.
+ *
* @author Edwin Punzalan
*/
public class CompoundQuery
{
protected List queries;
+ /**
+ * Class constructor
+ */
public CompoundQuery()
{
queries = new ArrayList();
}
+ /**
+ * Appends a required Query object to this Query object. The Query object will be encapsulated inside an
+ * AndQueryTerm object.
+ *
+ * @param query the Query object to be appended to this Query object
+ */
public void and( Query query )
{
queries.add( new AndQueryTerm( query ) );
}
+ /**
+ * Appends an optional Query object to this Query object. The Query object will be encapsulated inside an
+ * OrQueryTerm object.
+ *
+ * @param query the Query object to be appended to this Query object
+ */
public void or( Query query )
{
queries.add( new OrQueryTerm( query ) );
}
+ /**
+ * Appends a prohibited Query object to this Query object. The Query object will be encapsulated inside an
+ * NotQueryTerm object.
+ *
+ * @param query the Query object to be appended to this Query object
+ */
public void not( Query query )
{
queries.add( new NotQueryTerm( query ) );
}
+ /**
+ * Method to get the List of Queries appended into this
+ *
+ * @return List of all Queries added to this Query
+ */
public List getQueries()
{
return queries;
*/
public interface CompoundQueryTerm
{
+ /**
+ * Method to test if the Query is a search requirement
+ *
+ * @return true if this Query is a search requirement, otherwise returns false
+ */
boolean isRequired();
+ /**
+ * Method to test if the Query is prohibited in the search result
+ *
+ * @return true if this Query is prohibited in the search result
+ */
boolean isProhibited();
+ /**
+ * Method to get the Query object represented by this object
+ *
+ * @return the Query object represented by this object
+ */
Query getQuery();
}
public class NotQueryTerm
extends AbstractCompoundQueryTerm
{
+ /**
+ * Class constructor
+ *
+ * @param query the Query object represented by this Query object
+ */
public NotQueryTerm( Query query )
{
super( query );
}
+ /**
+ * @see CompoundQueryTerm#isProhibited()
+ */
public boolean isProhibited()
{
return true;
public class OrQueryTerm
extends AbstractCompoundQueryTerm
{
+ /**
+ * Class constructor
+ *
+ * @param query the Query object represented by this Query object
+ */
public OrQueryTerm( Query query )
{
super( query );
*/
/**
+ * Interface to label the query classes
+ *
* @author Edwin Punzalan
*/
public interface Query
*/
/**
+ * Class to hold a single field search condition
+ *
* @author Edwin Punzalan
*/
public class SinglePhraseQuery
private String value;
+ /**
+ * Class constructor
+ *
+ * @param field the index field to search
+ * @param value the index value requirement
+ */
public SinglePhraseQuery( String field, String value )
{
this.field = field;
this.value = value;
}
+ /**
+ * Method to retrieve the name of the index field searched
+ *
+ * @return the name of the index field
+ */
public String getField()
{
return field;
}
+ /**
+ * Method to retrieve the value used in searching the index field
+ *
+ * @return the value to corresspond the index field
+ */
public String getValue()
{
return value;
import java.util.List;
/**
- * @author Edwin Punzalan/Maria Odea Ching
+ * @author Edwin Punzalan
*/
public class ArtifactRepositoryIndexingTest
extends PlexusTestCase