git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@366107 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-0.9-alpha-1
@@ -32,7 +32,7 @@ public abstract class AbstractRepositoryIndex | |||
implements RepositoryIndex | |||
{ | |||
private String indexPath; | |||
private boolean indexOpen; | |||
private IndexReader indexReader; |
@@ -16,22 +16,22 @@ package org.apache.maven.repository.indexing; | |||
* limitations under the License. | |||
*/ | |||
import org.apache.lucene.document.Document; | |||
import org.apache.lucene.queryParser.ParseException; | |||
import org.apache.lucene.queryParser.QueryParser; | |||
import org.apache.lucene.search.BooleanQuery; | |||
import org.apache.lucene.search.IndexSearcher; | |||
import org.apache.lucene.search.Hits; | |||
import org.apache.lucene.document.Document; | |||
import org.apache.lucene.search.IndexSearcher; | |||
import org.apache.maven.repository.indexing.query.AbstractCompoundQuery; | |||
import org.apache.maven.repository.indexing.query.OptionalQuery; | |||
import org.apache.maven.repository.indexing.query.Query; | |||
import org.apache.maven.repository.indexing.query.RequiredQuery; | |||
import org.apache.maven.repository.indexing.query.SinglePhraseQuery; | |||
import org.apache.maven.repository.indexing.query.AbstractCompoundQuery; | |||
import java.io.IOException; | |||
import java.util.List; | |||
import java.util.Iterator; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
/** | |||
* | |||
@@ -50,7 +50,7 @@ public abstract class AbstractRepositoryIndexSearcher | |||
/** | |||
* Constructor | |||
* | |||
* @param index the index object | |||
* @param index the index object | |||
*/ | |||
public AbstractRepositoryIndexSearcher( ArtifactRepositoryIndex index ) | |||
{ |
@@ -21,6 +21,7 @@ import org.apache.lucene.analysis.SimpleAnalyzer; | |||
import org.apache.lucene.document.Document; | |||
import org.apache.lucene.document.Field; | |||
import org.apache.maven.artifact.Artifact; | |||
import org.apache.maven.artifact.repository.ArtifactRepository; | |||
import org.apache.maven.repository.digest.Digester; | |||
import java.io.FileNotFoundException; | |||
@@ -30,7 +31,6 @@ import java.util.Enumeration; | |||
import java.util.zip.ZipEntry; | |||
import java.util.zip.ZipException; | |||
import java.util.zip.ZipFile; | |||
import org.apache.maven.artifact.repository.ArtifactRepository; | |||
/** | |||
@@ -64,7 +64,7 @@ public class ArtifactRepositoryIndex | |||
private Analyzer analyzer; | |||
private Digester digester; | |||
private ArtifactRepository repository; | |||
public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester ) | |||
@@ -72,7 +72,7 @@ public class ArtifactRepositoryIndex | |||
{ | |||
this.repository = repository; | |||
this.digester = digester; | |||
open( indexPath ); | |||
} | |||
@@ -22,19 +22,22 @@ import org.apache.maven.artifact.repository.ArtifactRepository; | |||
import org.apache.maven.repository.digest.Digester; | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
* @plexus.component role="org.apache.maven.repository.indexing.RepositoryIndexingFactory" | |||
*/ | |||
public class DefaultRepositoryIndexingFactory | |||
implements RepositoryIndexingFactory | |||
{ | |||
/** @plexus.requirement */ | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private Digester digester; | |||
/** @plexus.requirement */ | |||
/** | |||
* @plexus.requirement | |||
*/ | |||
private ArtifactFactory artifactFactory; | |||
public ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index ) | |||
{ | |||
return new ArtifactRepositoryIndexSearcher( index, artifactFactory ); |
@@ -38,6 +38,7 @@ public interface RepositoryIndex | |||
/* void open( String indexPath ) | |||
throws RepositoryIndexException; | |||
*/ | |||
void optimize() | |||
throws RepositoryIndexException; | |||
@@ -16,11 +16,9 @@ package org.apache.maven.repository.indexing; | |||
* limitations under the License. | |||
*/ | |||
import java.util.List; | |||
import org.apache.maven.repository.indexing.query.Query; | |||
import org.apache.maven.artifact.Artifact; | |||
import org.apache.lucene.document.Document; | |||
import java.util.List; | |||
/** | |||
* @author Maria Odea Ching | |||
@@ -29,10 +27,12 @@ public interface RepositoryIndexSearcher | |||
{ | |||
/** | |||
* Search the artifact based on the search criteria specified in the query object. Returns a list of | |||
* artifact objects. | |||
* artifact objects. | |||
* | |||
* @param query The query object that contains the search criteria. | |||
* @return List | |||
* @exception RepositoryIndexSearchException | |||
* @throws RepositoryIndexSearchException | |||
*/ | |||
List search(Query query) throws RepositoryIndexSearchException; | |||
List search( Query query ) | |||
throws RepositoryIndexSearchException; | |||
} |
@@ -21,7 +21,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository; | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public interface RepositoryIndexingFactory | |||
@@ -29,6 +28,7 @@ public interface RepositoryIndexingFactory | |||
String ROLE = RepositoryIndexingFactory.class.getName(); | |||
ArtifactRepositoryIndexSearcher createArtifactRepositoryIndexSearcher( ArtifactRepositoryIndex index ); | |||
ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository ) | |||
throws RepositoryIndexException; | |||
} |
@@ -21,24 +21,23 @@ import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public abstract class AbstractCompoundQuery | |||
implements Query | |||
{ | |||
protected List queries; | |||
public AbstractCompoundQuery() | |||
{ | |||
queries = new ArrayList(); | |||
} | |||
public void add( Query query ) | |||
{ | |||
queries.add( query ); | |||
} | |||
public List getQueryList() | |||
{ | |||
return queries; |
@@ -17,11 +17,7 @@ package org.apache.maven.repository.indexing.query; | |||
* limitations under the License. | |||
*/ | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public class OptionalQuery |
@@ -18,7 +18,6 @@ package org.apache.maven.repository.indexing.query; | |||
*/ | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public interface Query |
@@ -18,7 +18,6 @@ package org.apache.maven.repository.indexing.query; | |||
*/ | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public class RequiredQuery |
@@ -18,13 +18,13 @@ package org.apache.maven.repository.indexing.query; | |||
*/ | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public class SinglePhraseQuery | |||
implements Query | |||
{ | |||
private String field; | |||
private String value; | |||
public SinglePhraseQuery( String field, String value ) | |||
@@ -37,7 +37,7 @@ public class SinglePhraseQuery | |||
{ | |||
return field; | |||
} | |||
public String getValue() | |||
{ | |||
return value; |
@@ -153,7 +153,7 @@ public class ArtifactRepositoryIndexingTest | |||
/** | |||
* Create an index that will be used for testing. | |||
* | |||
* | |||
* @throws Exception | |||
*/ | |||
public void createTestIndex() | |||
@@ -180,7 +180,7 @@ public class ArtifactRepositoryIndexingTest | |||
/** | |||
* Test the ArtifactRepositoryIndexSearcher using a single-phrase search. | |||
* | |||
* | |||
* @throws Exception | |||
*/ | |||
public void testSearchSingle() | |||
@@ -297,7 +297,7 @@ public class ArtifactRepositoryIndexingTest | |||
/** | |||
* Test the ArtifactRepositoryIndexSearcher using compound search (AND, OR). | |||
* | |||
* | |||
* @throws Exception | |||
*/ | |||
public void testSearchCompound() |
@@ -1,6 +1,6 @@ | |||
package org.apache.maven.repository.indexing.query; | |||
import junit.framework.*; | |||
import junit.framework.TestCase; | |||
/* | |||
* Copyright 2001-2005 The Apache Software Foundation. | |||
@@ -20,10 +20,10 @@ import junit.framework.*; | |||
*/ | |||
/** | |||
* | |||
* @author Edwin Punzalan | |||
*/ | |||
public class QueryTest extends TestCase | |||
public class QueryTest | |||
extends TestCase | |||
{ | |||
public void testSinglePhraseQueryObject() | |||
{ | |||
@@ -32,23 +32,23 @@ public class QueryTest extends TestCase | |||
assertEquals( "Field", query.getField() ); | |||
assertEquals( "Value", query.getValue() ); | |||
} | |||
public void testCompoundQueries() | |||
{ | |||
RequiredQuery rQuery = new RequiredQuery(); | |||
assertTrue( rQuery instanceof Query ); | |||
rQuery.add( new SinglePhraseQuery( "r1Field", "r1Value" ) ); | |||
rQuery.add( new SinglePhraseQuery( "r2Field", "r2Value" ) ); | |||
OptionalQuery oQuery = new OptionalQuery(); | |||
oQuery.add( new SinglePhraseQuery( "oField", "oValue" ) ); | |||
RequiredQuery all = new RequiredQuery(); | |||
all.add( rQuery ); | |||
all.add( oQuery ); | |||
assertEquals( 2, all.getQueryList().size() ); | |||
for( int ctr = 0; ctr < all.getQueryList().size(); ctr++ ) | |||
for ( int ctr = 0; ctr < all.getQueryList().size(); ctr++ ) | |||
{ | |||
Query query = (Query) all.getQueryList().get( ctr ); | |||
switch ( ctr ) |