[MNG-127] move other repoman code to use new indexer

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@426403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-07-28 06:41:56 +00:00
parent 7c31a1f9be
commit 8a2f6fc754
8 changed files with 189 additions and 182 deletions

View File

@ -16,6 +16,7 @@
* limitations under the License.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
@ -23,15 +24,15 @@
import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.discovery.DiscovererException;
import org.apache.maven.repository.discovery.MetadataDiscoverer;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.MetadataRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.record.RepositoryIndexRecordFactory;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -55,7 +56,7 @@ public class IndexerTask
/**
* @plexus.requirement
*/
private RepositoryIndexingFactory indexFactory;
private RepositoryArtifactIndexFactory indexFactory;
/**
* @plexus.requirement
@ -68,9 +69,9 @@ public class IndexerTask
private Map artifactDiscoverers;
/**
* @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer"
* @plexus.requirement role-hint="standard"
*/
private Map metadataDiscoverers;
private RepositoryIndexRecordFactory recordFactory;
public void execute()
throws TaskExecutionException
@ -112,15 +113,6 @@ private void execute( Configuration configuration, File indexPath )
getLogger().info( "Indexing " + artifacts.size() + " new artifacts" );
indexArtifact( artifacts, indexPath, defaultRepository );
}
MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
List metadataList =
metadataDiscoverer.discoverMetadata( defaultRepository, "indexer", blacklistedPatterns );
if ( !metadataList.isEmpty() )
{
getLogger().info( "Indexing " + metadataList.size() + " new metadata files" );
indexMetadata( metadataList, indexPath, defaultRepository );
}
}
catch ( RepositoryIndexException e )
{
@ -153,8 +145,8 @@ public void executeNowIfNeeded()
try
{
ArtifactRepository repository = repoFactory.createRepository( configuration );
RepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
if ( !artifactIndex.indexExists() )
RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath, repository );
if ( !artifactIndex.exists() )
{
execute( configuration, indexPath );
}
@ -165,32 +157,16 @@ public void executeNowIfNeeded()
}
}
/**
* Index the artifacts in the list
*
* @param artifacts the artifacts to be indexed
* @param indexPath the path to the index file
* @param repository the repository where the artifacts are located
*/
protected void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
private void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
artifactIndex.indexArtifacts( artifacts );
artifactIndex.optimize();
}
/**
* Index the metadata in the list
*
* @param metadataList the metadata to be indexed
* @param indexPath the path to the index file
*/
protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
metadataIndex.indexMetadata( metadataList );
metadataIndex.optimize();
RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath, repository );
List records = new ArrayList();
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
records.add( recordFactory.createRecord( a ) );
}
artifactIndex.indexRecords( records );
}
}

View File

@ -133,21 +133,36 @@ record = new StandardArtifactIndexRecord();
artifact.getRepository().pathOf( pomArtifact ) );
if ( pomFile.exists() )
{
populatePomEntries( readPom( pomArtifact, artifact.getRepository() ), record );
try
{
populatePomEntries( readPom( pomArtifact, artifact.getRepository() ), record );
}
catch ( ProjectBuildingException e )
{
getLogger().error( "Error reading POM file, not populating in index: " + e.getMessage() );
}
}
}
else
{
Model model = readPom( artifact, artifact.getRepository() );
Model model;
try
{
model = readPom( artifact, artifact.getRepository() );
if ( !"pom".equals( model.getPackaging() ) )
{
// Don't return a record for a POM that is does not belong on its own
record = null;
if ( !"pom".equals( model.getPackaging() ) )
{
// Don't return a record for a POM that is does not belong on its own
record = null;
}
else
{
populatePomEntries( model, record );
}
}
else
catch ( ProjectBuildingException e )
{
populatePomEntries( model, record );
getLogger().error( "Error reading POM file, not populating in index: " + e.getMessage() );
}
}
}
@ -172,20 +187,11 @@ private void populatePomEntries( Model pom, StandardArtifactIndexRecord record )
}
private Model readPom( Artifact artifact, ArtifactRepository repository )
throws RepositoryIndexException
throws RepositoryIndexException, ProjectBuildingException
{
// TODO: will this pollute with local repo metadata?
Model model;
try
{
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
model = project.getModel();
}
catch ( ProjectBuildingException e )
{
throw new RepositoryIndexException( "Unable to read project: " + e.getMessage(), e );
}
return model;
MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository );
return project.getModel();
}
private void populateArchiveEntries( List files, StandardArtifactIndexRecord record, File artifactFile )

View File

@ -16,25 +16,26 @@
* limitations under the License.
*/
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Model;
import org.apache.maven.repository.digest.Digester;
import org.apache.maven.repository.digest.DigesterException;
import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryArtifactIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.SearchResult;
import org.apache.maven.repository.indexing.query.SingleTermQuery;
import org.apache.maven.repository.indexing.lucene.LuceneQuery;
import org.apache.maven.repository.indexing.record.StandardArtifactIndexRecord;
import org.apache.maven.repository.indexing.record.StandardIndexRecordFields;
import java.io.File;
import java.util.Iterator;
import java.util.List;
/**
* Validates an artifact file for duplicates within the same groupId based from what's available in a RepositoryIndex
* Validates an artifact file for duplicates within the same groupId based from what's available in a repository index.
*
* @author Edwin Punzalan
* @plexus.component role="org.apache.maven.repository.reporting.ArtifactReportProcessor" role-hint="duplicate"
@ -50,41 +51,25 @@ public class DuplicateArtifactFileReportProcessor
/**
* @plexus.requirement
*/
private RepositoryIndexingFactory indexFactory;
/**
* @plexus.requirement
*/
private RepositoryIndexSearchLayer searchLayer;
private RepositoryArtifactIndexFactory indexFactory;
/**
* @plexus.configuration
*/
private String indexDirectory;
//@todo configurable?
private String algorithm = RepositoryIndex.FLD_MD5;
public void processArtifact( Model model, Artifact artifact, ArtifactReporter reporter,
ArtifactRepository repository )
throws ReportProcessorException
{
if ( artifact.getFile() != null )
{
RepositoryIndex index;
try
{
index = indexFactory.createArtifactRepositoryIndex( new File( indexDirectory ), repository );
}
catch ( RepositoryIndexException e )
{
throw new ReportProcessorException( "Unable to create RepositoryIndex instance", e );
}
RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ), repository );
String checksum;
try
{
checksum = digester.createChecksum( artifact.getFile(), algorithm );
checksum = digester.createChecksum( artifact.getFile(), Digester.MD5 );
}
catch ( DigesterException e )
{
@ -93,7 +78,8 @@ public void processArtifact( Model model, Artifact artifact, ArtifactReporter re
try
{
List results = searchLayer.searchAdvanced( new SingleTermQuery( algorithm, checksum.trim() ), index );
List results = index.search( new LuceneQuery(
new TermQuery( new Term( StandardIndexRecordFields.MD5, checksum.toLowerCase() ) ) ) );
if ( results.isEmpty() )
{
@ -101,23 +87,20 @@ public void processArtifact( Model model, Artifact artifact, ArtifactReporter re
}
else
{
String id = artifact.getId();
boolean hasDuplicates = false;
for ( Iterator hits = results.iterator(); hits.hasNext(); )
for ( Iterator i = results.iterator(); i.hasNext(); )
{
SearchResult result = (SearchResult) hits.next();
Artifact artifactMatch = result.getArtifact();
StandardArtifactIndexRecord result = (StandardArtifactIndexRecord) i.next();
//make sure it is not the same artifact
if ( !id.equals( artifactMatch.getId() ) )
if ( !result.getFilename().equals( repository.pathOf( artifact ) ) )
{
//report only duplicates from the same groupId
String groupId = artifact.getGroupId();
if ( groupId.equals( artifactMatch.getGroupId() ) )
if ( groupId.equals( result.getGroupId() ) )
{
hasDuplicates = true;
reporter.addFailure( artifact, "Found duplicate for " + artifactMatch.getId() );
reporter.addFailure( artifact, "Found duplicate for " + artifact.getId() );
}
}
}

View File

@ -19,10 +19,13 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.Model;
import org.apache.maven.repository.digest.Digester;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory;
import org.apache.maven.repository.indexing.record.RepositoryIndexRecordFactory;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.util.Collections;
/**
* @author Edwin Punzalan
@ -47,39 +50,27 @@ protected void setUp()
{
super.setUp();
Digester digester = (Digester) lookup( Digester.ROLE );
indexDirectory = getTestFile( "target/indexDirectory" );
if ( !indexDirectory.exists() )
{
indexDirectory.mkdirs();
}
FileUtils.deleteDirectory( indexDirectory );
artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
artifact = createArtifact( "groupId", "artifactId", "1.0-alpha-1", "1.0-alpha-1", "jar" );
reporter = new MockArtifactReporter();
model = new Model();
ArtifactRepositoryIndex index = new ArtifactRepositoryIndex( indexDirectory, repository, digester );
index.indexArtifact( artifact );
index.optimize();
RepositoryArtifactIndexFactory factory =
(RepositoryArtifactIndexFactory) lookup( RepositoryArtifactIndexFactory.ROLE, "lucene" );
RepositoryArtifactIndex index = factory.createStandardIndex( indexDirectory, repository );
RepositoryIndexRecordFactory recordFactory =
(RepositoryIndexRecordFactory) lookup( RepositoryIndexRecordFactory.ROLE, "standard" );
index.indexRecords( Collections.singletonList( recordFactory.createRecord( artifact ) ) );
processor = (ArtifactReportProcessor) lookup( ArtifactReportProcessor.ROLE, "duplicate" );
}
protected void tearDown()
throws Exception
{
//FileUtils.deleteDirectory( indexDirectory );
processor = null;
model = null;
artifact = null;
reporter = null;
super.tearDown();
}
public void testNullArtifactFile()
throws Exception
{
@ -139,10 +130,7 @@ public void testFailure()
assertEquals( "Check no failures", 1, reporter.getFailures() );
}
private Artifact createArtifact( String groupId,
String artifactId,
String baseVersion,
String version,
private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version,
String type )
{
Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type );

View File

@ -9,10 +9,7 @@
<role>org.apache.maven.repository.digest.Digester</role>
</requirement>
<requirement>
<role>org.apache.maven.repository.indexing.RepositoryIndexingFactory</role>
</requirement>
<requirement>
<role>org.apache.maven.repository.indexing.RepositoryIndexSearchLayer</role>
<role>org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory</role>
</requirement>
</requirements>
<configuration>

View File

@ -17,30 +17,42 @@
*/
import com.opensymphony.xwork.ActionSupport;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.lucene.LuceneQuery;
import org.apache.maven.repository.indexing.record.StandardArtifactIndexRecord;
import org.apache.maven.repository.indexing.record.StandardIndexRecordFields;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
/**
* Browse the repository.
*
* @todo the tree part probably belongs in a browsing component, along with the methods currently in the indexer
* @todo the tree part probably belongs in a browsing component, and the indexer could optimize how it retrieves the terms rather than querying everything
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="browseAction"
*/
public class BrowseAction
@ -49,12 +61,7 @@ public class BrowseAction
/**
* @plexus.requirement
*/
private RepositoryIndexingFactory factory;
/**
* @plexus.requirement
*/
private RepositoryIndexSearchLayer searchLayer;
private RepositoryArtifactIndexFactory factory;
/**
* @plexus.requirement
@ -79,11 +86,11 @@ public class BrowseAction
private List versions;
public String browse()
throws ConfigurationStoreException, RepositoryIndexException, IOException
throws ConfigurationStoreException, RepositoryIndexException, IOException, RepositoryIndexSearchException
{
ArtifactRepositoryIndex index = getIndex();
RepositoryArtifactIndex index = getIndex();
if ( !index.indexExists() )
if ( !index.exists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
@ -97,11 +104,11 @@ public String browse()
}
public String browseGroup()
throws ConfigurationStoreException, RepositoryIndexException, IOException
throws ConfigurationStoreException, RepositoryIndexException, IOException, RepositoryIndexSearchException
{
ArtifactRepositoryIndex index = getIndex();
RepositoryArtifactIndex index = getIndex();
if ( !index.indexExists() )
if ( !index.exists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
@ -135,15 +142,26 @@ public String browseGroup()
this.groups = collateGroups( rootNode );
this.artifactIds = index.getArtifacts( groupId.replaceAll( GROUP_SEPARATOR, "." ) );
String groupId = this.groupId.replaceAll( GROUP_SEPARATOR, "." );
List records = index.search(
new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ) ) );
Set artifactIds = new HashSet();
for ( Iterator i = records.iterator(); i.hasNext(); )
{
StandardArtifactIndexRecord record = (StandardArtifactIndexRecord) i.next();
artifactIds.add( record.getArtifactId() );
}
this.artifactIds = new ArrayList( artifactIds );
Collections.sort( this.artifactIds );
return SUCCESS;
}
public String browseArtifact()
throws ConfigurationStoreException, RepositoryIndexException, IOException
throws ConfigurationStoreException, RepositoryIndexException, IOException, RepositoryIndexSearchException
{
ArtifactRepositoryIndex index = getIndex();
RepositoryArtifactIndex index = getIndex();
if ( StringUtils.isEmpty( groupId ) )
{
@ -159,26 +177,51 @@ public String browseArtifact()
return ERROR;
}
versions = index.getVersions( groupId.replaceAll( GROUP_SEPARATOR, "." ), artifactId );
String groupId = this.groupId.replaceAll( GROUP_SEPARATOR, "." );
if ( versions.isEmpty() )
BooleanQuery query = new BooleanQuery();
query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ),
BooleanClause.Occur.MUST );
query.add( new TermQuery( new Term( StandardIndexRecordFields.ARTIFACTID_EXACT, artifactId ) ),
BooleanClause.Occur.MUST );
List records = index.search( new LuceneQuery( query ) );
if ( records.isEmpty() )
{
// TODO: i18n
addActionError( "Could not find any artifacts with the given group and artifact ID" );
return ERROR;
}
Set versions = new HashSet();
for ( Iterator i = records.iterator(); i.hasNext(); )
{
StandardArtifactIndexRecord record = (StandardArtifactIndexRecord) i.next();
versions.add( record.getVersion() );
}
this.versions = new ArrayList( versions );
Collections.sort( this.versions );
return SUCCESS;
}
private GroupTreeNode buildGroupTree( ArtifactRepositoryIndex index )
throws IOException
private GroupTreeNode buildGroupTree( RepositoryArtifactIndex index )
throws IOException, RepositoryIndexSearchException
{
// TODO: give action message if indexing is in progress
// TODO: this will be inefficient over a very large number of artifacts, should be cached
List groups = index.enumerateGroupIds();
List records = index.search( new LuceneQuery( new MatchAllDocsQuery() ) );
Set groups = new TreeSet();
for ( Iterator i = records.iterator(); i.hasNext(); )
{
StandardArtifactIndexRecord record = (StandardArtifactIndexRecord) i.next();
groups.add( record.getGroupId() );
}
GroupTreeNode rootNode = new GroupTreeNode();
@ -227,7 +270,7 @@ private List collateGroups( GroupTreeNode rootNode )
return groups;
}
private ArtifactRepositoryIndex getIndex()
private RepositoryArtifactIndex getIndex()
throws ConfigurationStoreException, RepositoryIndexException
{
Configuration configuration = configurationStore.getConfigurationFromStore();
@ -235,7 +278,7 @@ private ArtifactRepositoryIndex getIndex()
ArtifactRepository repository = repositoryFactory.createRepository( configuration );
return factory.createArtifactRepositoryIndex( indexPath, repository );
return factory.createStandardIndex( indexPath, repository );
}
public List getGroups()

View File

@ -17,17 +17,22 @@
*/
import com.opensymphony.xwork.ActionSupport;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.TermQuery;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.apache.maven.repository.configuration.ConfigurationStoreException;
import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndex;
import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.query.SingleTermQuery;
import org.apache.maven.repository.indexing.lucene.LuceneQuery;
import org.apache.maven.repository.indexing.record.StandardIndexRecordFields;
import java.io.File;
import java.net.MalformedURLException;
@ -59,12 +64,7 @@ public class SearchAction
/**
* @plexus.requirement
*/
private RepositoryIndexingFactory factory;
/**
* @plexus.requirement
*/
private RepositoryIndexSearchLayer searchLayer;
private RepositoryArtifactIndexFactory factory;
/**
* @plexus.requirement
@ -78,21 +78,27 @@ public class SearchAction
public String quickSearch()
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException,
ConfigurationStoreException
ConfigurationStoreException, ParseException
{
// TODO: give action message if indexing is in progress
assert q != null && q.length() != 0;
ArtifactRepositoryIndex index = getIndex();
RepositoryArtifactIndex index = getIndex();
if ( !index.indexExists() )
if ( !index.exists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
}
searchResults = searchLayer.searchGeneral( q, index );
// TODO! this is correct, but ugly
MultiFieldQueryParser parser = new MultiFieldQueryParser( new String[]{StandardIndexRecordFields.GROUPID,
StandardIndexRecordFields.ARTIFACTID, StandardIndexRecordFields.BASE_VERSION,
StandardIndexRecordFields.CLASSIFIER, StandardIndexRecordFields.CLASSES, StandardIndexRecordFields.FILES,
StandardIndexRecordFields.TYPE, StandardIndexRecordFields.PROJECT_NAME,
StandardIndexRecordFields.PROJECT_DESCRIPTION}, new StandardAnalyzer() );
searchResults = index.search( new LuceneQuery( parser.parse( q ) ) );
return SUCCESS;
}
@ -104,20 +110,21 @@ public String findArtifact()
assert md5 != null && md5.length() != 0;
ArtifactRepositoryIndex index = getIndex();
RepositoryArtifactIndex index = getIndex();
if ( !index.indexExists() )
if ( !index.exists() )
{
addActionError( "The repository is not yet indexed. Please wait, and then try again." );
return ERROR;
}
searchResults = searchLayer.searchAdvanced( new SingleTermQuery( "md5", md5 ), index );
searchResults = index.search(
new LuceneQuery( new TermQuery( new Term( StandardIndexRecordFields.MD5, md5.toLowerCase() ) ) ) );
return SUCCESS;
}
private ArtifactRepositoryIndex getIndex()
private RepositoryArtifactIndex getIndex()
throws ConfigurationStoreException, RepositoryIndexException
{
Configuration configuration = configurationStore.getConfigurationFromStore();
@ -125,7 +132,7 @@ private ArtifactRepositoryIndex getIndex()
ArtifactRepository repository = repositoryFactory.createRepository( configuration );
return factory.createArtifactRepositoryIndex( indexPath, repository );
return factory.createStandardIndex( indexPath, repository );
}
public String doInput()

View File

@ -1,5 +1,3 @@
<%@ taglib uri="/webwork" prefix="ww" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%--
~ Copyright 2005-2006 The Apache Software Foundation.
~
@ -16,6 +14,9 @@
~ limitations under the License.
--%>
<%@ taglib uri="/webwork" prefix="ww" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Search Results</title>
@ -42,11 +43,17 @@
--%>
</tr>
<ww:set name="searchResults" value="searchResults" />
<c:forEach items="${searchResults}" var="result" varStatus="i">
<c:forEach items="${searchResults}" var="record" varStatus="i">
<tr class="${i.index % 2 == 0 ? "b" : "a"}">
<td><c:out value="${result.artifact.groupId}" /></td>
<td><c:out value="${result.artifact.artifactId}" /></td>
<td><c:out value="${result.artifact.version}" /></td>
<td>
<c:out value="${record.groupId}" />
</td>
<td>
<c:out value="${record.artifactId}" />
</td>
<td>
<c:out value="${record.version}" />
</td>
<%-- TODO: hits
<td>
<table border="1px" width="100%" cellspacing="0">