You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by jo...@apache.org on 2007/05/25 17:05:54 UTC

svn commit: r541680 [2/2] - in /maven/archiva/trunk: archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consum...

Added: maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java?view=auto&rev=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java Fri May 25 08:05:51 2007
@@ -0,0 +1,70 @@
+package org.apache.maven.archiva.indexer.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * SearchResultLimits - used to provide the search some limits on how the results are returned.
+ * This can provide paging for the 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class SearchResultLimits
+{
+    /** 
+     * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES.
+     * USE WITH CAUTION!!
+     */
+    public static final int ALL_PAGES = ( -1 );
+
+    private int pageSize = 30;
+
+    private int selectedPage = 0;
+
+    public SearchResultLimits( int selectedPage )
+    {
+        this.selectedPage = selectedPage;
+    }
+
+    public int getPageSize()
+    {
+        return pageSize;
+    }
+
+    /**
+     * Set page size for maximum # of hits to return per page.
+     * 
+     * @param pageSize size of page by # of hits. (maximum value is 200)
+     */
+    public void setPageSize( int pageSize )
+    {
+        this.pageSize = Math.min( 200, pageSize );
+    }
+
+    public int getSelectedPage()
+    {
+        return selectedPage;
+    }
+
+    public void setSelectedPage( int selectedPage )
+    {
+        this.selectedPage = selectedPage;
+    }
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResultLimits.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java Fri May 25 08:05:51 2007
@@ -19,8 +19,17 @@
  * under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.archiva.indexer.bytecode.BytecodeRecord;
+import org.apache.maven.archiva.indexer.filecontent.FileContentRecord;
+import org.apache.maven.archiva.indexer.hashcodes.HashcodesRecord;
+import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
+import org.apache.maven.archiva.model.ArchivaArtifact;
+
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * SearchResults 
@@ -32,59 +41,140 @@
 {
     private List repositories = new ArrayList();
 
-    private List contentHits = new ArrayList();
+    private Map hits = new HashMap();
 
-    private List bytecodeHits = new ArrayList();
+    private int totalHits;
 
-    private List hashcodeHits = new ArrayList();
+    private SearchResultLimits limits;
 
     public SearchResults()
     {
         /* do nothing */
     }
 
-    public boolean isEmpty()
+    public void addHit( LuceneRepositoryContentRecord record )
     {
-        return ( bytecodeHits.isEmpty() && hashcodeHits.isEmpty() && contentHits.isEmpty() );
+        if ( record instanceof FileContentRecord )
+        {
+            FileContentRecord filecontent = (FileContentRecord) record;
+            addFileContentHit( filecontent );
+        }
+        else if ( record instanceof HashcodesRecord )
+        {
+            HashcodesRecord hashcodes = (HashcodesRecord) record;
+            addHashcodeHit( hashcodes );
+        }
+        else if ( record instanceof BytecodeRecord )
+        {
+            BytecodeRecord bytecode = (BytecodeRecord) record;
+            addBytecodeHit( bytecode );
+        }
     }
 
-    public List getBytecodeHits()
+    private void addBytecodeHit( BytecodeRecord bytecode )
     {
-        return bytecodeHits;
+        String key = toKey( bytecode.getArtifact() );
+
+        SearchResultHit hit = (SearchResultHit) this.hits.get( key );
+
+        if ( hit == null )
+        {
+            hit = new SearchResultHit();
+        }
+
+        hit.addArtifact( bytecode.getArtifact() );
+        hit.setContext( null ); // TODO: provide context on why this is a valuable hit.
+
+        this.hits.put( key, hit );
     }
 
-    public List getContentHits()
+    private String toKey( ArchivaArtifact artifact )
     {
-        return contentHits;
+        StringBuffer key = new StringBuffer();
+
+        key.append( StringUtils.defaultString( artifact.getGroupId() ) ).append( ":" );
+        key.append( StringUtils.defaultString( artifact.getArtifactId() ) );
+
+        return key.toString();
     }
 
-    public List getHashcodeHits()
+    private void addHashcodeHit( HashcodesRecord hashcodes )
     {
-        return hashcodeHits;
+        String key = toKey( hashcodes.getArtifact() );
+
+        SearchResultHit hit = (SearchResultHit) this.hits.get( key );
+
+        if ( hit == null )
+        {
+            hit = new SearchResultHit();
+        }
+
+        hit.addArtifact( hashcodes.getArtifact() );
+        hit.setContext( null ); // TODO: provide context on why this is a valuable hit.
+
+        this.hits.put( key, hit );
     }
 
-    public List getRepositories()
+    public void addFileContentHit( FileContentRecord filecontent )
     {
-        return repositories;
+        String key = filecontent.getPrimaryKey();
+
+        SearchResultHit hit = (SearchResultHit) this.hits.get( key );
+
+        if ( hit == null )
+        {
+            // Only need to worry about this hit if it is truely new.
+            hit = new SearchResultHit();
+
+            hit.setUrl( filecontent.getRepositoryId() + "/" + filecontent.getFilename() );
+            hit.setContext( null ); // TODO: handle context + highlight later.
+
+            this.hits.put( key, hit );
+        }
     }
 
-    public void setBytecodeHits( List bytecodeHits )
+    /**
+     * Get the list of {@link SearchResultHit} objects.
+     * 
+     * @return the list of {@link SearchResultHit} objects.
+     */
+    public List getHits()
     {
-        this.bytecodeHits = bytecodeHits;
+        return new ArrayList( hits.values() );
     }
 
-    public void setContentHits( List contentHits )
+    public List getRepositories()
     {
-        this.contentHits = contentHits;
+        return repositories;
     }
 
-    public void setHashcodeHits( List hashcodeHits )
+    public boolean isEmpty()
     {
-        this.hashcodeHits = hashcodeHits;
+        return hits.isEmpty();
     }
 
     public void setRepositories( List repositories )
     {
         this.repositories = repositories;
+    }
+
+    public SearchResultLimits getLimits()
+    {
+        return limits;
+    }
+
+    public void setLimits( SearchResultLimits limits )
+    {
+        this.limits = limits;
+    }
+
+    public int getTotalHits()
+    {
+        return totalHits;
+    }
+
+    public void setTotalHits( int totalHits )
+    {
+        this.totalHits = totalHits;
     }
 }

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AbstractSearchTestCase.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AbstractSearchTestCase.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AbstractSearchTestCase.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AbstractSearchTestCase.java Fri May 25 08:05:51 2007
@@ -19,14 +19,19 @@
  * under the License.
  */
 
+import org.apache.lucene.document.Document;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Hit;
+import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.TermQuery;
-import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
 import org.apache.maven.archiva.indexer.lucene.LuceneRepositoryContentRecord;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -39,13 +44,15 @@
  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
  * @version $Id$
  */
-public abstract class AbstractSearchTestCase extends AbstractIndexerTestCase
+public abstract class AbstractSearchTestCase
+    extends AbstractIndexerTestCase
 {
     protected Map records;
 
     protected abstract Map createSampleRecordsMap();
 
-    protected void setUp() throws Exception
+    protected void setUp()
+        throws Exception
     {
         super.setUp();
 
@@ -59,7 +66,8 @@
         return new TermQuery( new Term( field, value ) );
     }
 
-    protected Query createMatchQuery( String field, String value ) throws ParseException
+    protected Query createMatchQuery( String field, String value )
+        throws ParseException
     {
         QueryParser queryParser = new QueryParser( field, indexHandlers.getAnalyzer() );
         queryParser.setLowercaseExpandedTerms( true );
@@ -81,8 +89,8 @@
         if ( expectedKeys.length != actualResults.size() )
         {
             dumpResults( actualResults );
-            throw new ComparisonFailure( "Results count", String.valueOf( expectedKeys.length ),
-                                         String.valueOf( actualResults.size() ) );
+            throw new ComparisonFailure( "Results count", String.valueOf( expectedKeys.length ), String
+                .valueOf( actualResults.size() ) );
         }
 
         assertEquals( "Results count", expectedKeys.length, actualResults.size() );
@@ -96,8 +104,7 @@
             {
                 dumpResults( actualResults );
                 fail( "Expected record <" + key
-                                + "> not in records map (smack the unit test developer, tell them to fix method "
-                                + getName() + ")" );
+                    + "> not in records map (smack the unit test developer, tell them to fix method " + getName() + ")" );
             }
 
             if ( !actualResults.contains( record ) )
@@ -133,31 +140,56 @@
         }
     }
 
-    protected void assertQueryExactMatchNoResults( String key, String term ) throws RepositoryIndexSearchException
+    protected void assertQueryExactMatchNoResults( String key, String term )
+        throws Exception
     {
         Query query = createExactMatchQuery( key, term );
-        List results = index.search( new LuceneQuery( query ) );
+        List results = search( query );
         assertNoResults( results );
     }
 
-    protected void assertQueryExactMatch( String key, String names[], String term ) throws RepositoryIndexSearchException
+    protected void assertQueryExactMatch( String key, String names[], String term )
+        throws Exception
     {
         Query query = createExactMatchQuery( key, term );
-        List results = index.search( new LuceneQuery( query ) );
+        List results = search( query );
         assertResults( names, results );
     }
 
-    protected void assertQueryMatch( String key, String names[], String term ) throws Exception
+    protected void assertQueryMatch( String key, String names[], String term )
+        throws Exception
     {
         Query query = createMatchQuery( key, term );
-        List results = index.search( new LuceneQuery( query ) );
+        List results = search( query );
         assertResults( names, results );
     }
 
-    protected void assertQueryMatchNoResults( String key, String term ) throws Exception
+    protected void assertQueryMatchNoResults( String key, String term )
+        throws Exception
     {
         Query query = createMatchQuery( key, term );
-        List results = index.search( new LuceneQuery( query ) );
+
+        List results = search( query );
+
         assertNoResults( results );
+    }
+
+    protected List search( Query query )
+        throws RepositoryIndexSearchException, IOException, java.text.ParseException
+    {
+        Searcher searcher = (Searcher) index.getSearchable();; // this shouldn't cause a problem.
+
+        Hits hits = searcher.search( query );
+
+        List results = new ArrayList();
+        Iterator it = hits.iterator();
+        while ( it.hasNext() )
+        {
+            Hit hit = (Hit) it.next();
+            Document doc = hit.getDocument();
+            LuceneRepositoryContentRecord record = index.getEntryConverter().convert( doc );
+            results.add( record );
+        }
+        return results;
     }
 }

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AllTests.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AllTests.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AllTests.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/AllTests.java Fri May 25 08:05:51 2007
@@ -38,6 +38,7 @@
         suite.addTest( org.apache.maven.archiva.indexer.bytecode.AllTests.suite() );
         suite.addTest( org.apache.maven.archiva.indexer.hashcodes.AllTests.suite() );
         suite.addTest( org.apache.maven.archiva.indexer.query.AllTests.suite() );
+        suite.addTest( org.apache.maven.archiva.indexer.search.AllTests.suite() );
         //$JUnit-END$
         return suite;
     }

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeSearchTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeSearchTest.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeSearchTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/bytecode/BytecodeSearchTest.java Fri May 25 08:05:51 2007
@@ -26,9 +26,7 @@
 import org.apache.maven.archiva.indexer.ArtifactKeys;
 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
 import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
-import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
 import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
-import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArchivaRepository;
 
@@ -72,96 +70,97 @@
             ArchivaArtifact artifact = (ArchivaArtifact) entry.getValue();
             File dumpFile = getDumpFile( artifact );
             BytecodeRecord record = BytecodeRecordLoader.loadRecord( dumpFile, artifact );
+            record.setRepositoryId( "test-repo" );
             records.put( entry.getKey(), record );
         }
 
         return records;
     }
 
-    public void testExactMatchVersionSimple() throws RepositoryIndexSearchException
+    public void testExactMatchVersionSimple() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "archiva-common" }, "1.0" );
     }
 
-    public void testExactMatchVersionSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "continuum-webapp" }, "1.0.3-SNAPSHOT" );
     }
 
-    public void testExactMatchVersionAlphaSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionAlphaSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "redback-authorization-open" },
                                "1.0-alpha-1-SNAPSHOT" );
     }
 
-    public void testExactMatchVersionTimestampedSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionTimestampedSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "wagon-provider-api" },
                                "1.0-beta-3-20070209.213958-2" );
     }
 
-    public void testExactMatchVersionInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchVersionInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.VERSION_EXACT, "foo" );
     }
 
-    public void testExactMatchGroupIdOrgApacheMavenArchiva() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdOrgApacheMavenArchiva() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.GROUPID_EXACT, new String[] { "archiva-common" },
                                "org.apache.maven.archiva" );
     }
 
-    public void testExactMatchGroupIdOrgApacheMaven() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdOrgApacheMaven() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.GROUPID_EXACT, new String[] { "maven-archetype-simple" },
                                "org.apache.maven" );
     }
 
-    public void testExactMatchGroupIdInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.GROUPID_EXACT, "foo" );
     }
 
-    public void testExactMatchArtifactIdArchivaCommon() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdArchivaCommon() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.ARTIFACTID_EXACT, new String[] { "archiva-common" }, "archiva-common" );
     }
 
-    public void testExactMatchArtifactIdTestNg() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdTestNg() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.ARTIFACTID_EXACT, new String[] { "testng" }, "testng" );
     }
 
-    public void testExactMatchArtifactIdInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.ARTIFACTID_EXACT, "foo" );
     }
 
-    public void testExactMatchTypeJar() throws RepositoryIndexSearchException
+    public void testExactMatchTypeJar() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "archiva-common", "redback-authorization-open",
             "testng", "wagon-provider-api" } ), "jar" );
     }
 
-    public void testExactMatchTypeWar() throws RepositoryIndexSearchException
+    public void testExactMatchTypeWar() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "continuum-webapp" } ), "war" );
     }
 
     /* TODO: Fix 'maven-plugin' type
-     public void testExactMatchTypePlugin() throws RepositoryIndexSearchException
+     public void testExactMatchTypePlugin() throws Exception
      {
      assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "maven-help-plugin" } ), "maven-plugin" );
      } */
 
     /* TODO: Fix 'maven-archetype' type
-     public void testExactMatchTypeArchetype() throws RepositoryIndexSearchException
+     public void testExactMatchTypeArchetype() throws Exception
      {
      assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "maven-archetype-simple" } ), "maven-archetype" );
      }
      */
 
-    public void testExactMatchTypeInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchTypeInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.TYPE, "foo" );
     }
@@ -250,7 +249,7 @@
         BooleanQuery bQuery = new BooleanQuery();
         bQuery.add( new MatchAllDocsQuery(), BooleanClause.Occur.MUST );
         bQuery.add( createMatchQuery( ArtifactKeys.CLASSIFIER, "jdk15" ), BooleanClause.Occur.MUST_NOT );
-        List results = index.search( new LuceneQuery( bQuery ) );
+        List results = search( bQuery );
 
         assertResults( new String[] { "archiva-common", "continuum-webapp", "redback-authorization-open",
             "daytrader-ear", "maven-archetype-simple", "maven-help-plugin", "wagon-provider-api" }, results );

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesIndexTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesIndexTest.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesIndexTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesIndexTest.java Fri May 25 08:05:51 2007
@@ -55,6 +55,7 @@
         ArchivaArtifact artifact = new ArchivaArtifact( "com.foo", "projfoo", "1.0", "", "jar" );
         
         HashcodesRecord record = new HashcodesRecord();
+        record.setRepositoryId( "test-repo" );
         record.setArtifact( artifact );
         
         artifact.getModel().setChecksumSHA1( "c66f18bf192cb613fc2febb4da541a34133eedc2" );

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesSearchTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesSearchTest.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesSearchTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/hashcodes/HashcodesSearchTest.java Fri May 25 08:05:51 2007
@@ -26,9 +26,7 @@
 import org.apache.maven.archiva.indexer.ArtifactKeys;
 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
 import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
-import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
 import org.apache.maven.archiva.indexer.lucene.LuceneIndexHandlers;
-import org.apache.maven.archiva.indexer.lucene.LuceneQuery;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArchivaRepository;
 
@@ -72,118 +70,119 @@
             ArchivaArtifact artifact = (ArchivaArtifact) entry.getValue();
             File dumpFile = getDumpFile( artifact );
             HashcodesRecord record = HashcodesRecordLoader.loadRecord( dumpFile, artifact );
+            record.setRepositoryId( "test-repo" );
             records.put( entry.getKey(), record );
         }
 
         return records;
     }
 
-    public void testExactMatchVersionSimple() throws RepositoryIndexSearchException
+    public void testExactMatchVersionSimple() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "archiva-common" }, "1.0" );
     }
 
-    public void testExactMatchVersionSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "continuum-webapp" }, "1.0.3-SNAPSHOT" );
     }
 
-    public void testExactMatchVersionAlphaSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionAlphaSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "redback-authorization-open" },
                                "1.0-alpha-1-SNAPSHOT" );
     }
 
-    public void testExactMatchVersionTimestampedSnapshot() throws RepositoryIndexSearchException
+    public void testExactMatchVersionTimestampedSnapshot() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.VERSION_EXACT, new String[] { "wagon-provider-api" },
                                "1.0-beta-3-20070209.213958-2" );
     }
 
-    public void testExactMatchVersionInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchVersionInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.VERSION_EXACT, "foo" );
     }
 
-    public void testExactMatchGroupIdOrgApacheMavenArchiva() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdOrgApacheMavenArchiva() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.GROUPID_EXACT, new String[] { "archiva-common" },
                                "org.apache.maven.archiva" );
     }
 
-    public void testExactMatchGroupIdOrgApacheMaven() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdOrgApacheMaven() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.GROUPID_EXACT, new String[] { "maven-archetype-simple" },
                                "org.apache.maven" );
     }
 
-    public void testExactMatchGroupIdInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchGroupIdInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.GROUPID_EXACT, "foo" );
     }
 
-    public void testExactMatchArtifactIdArchivaCommon() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdArchivaCommon() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.ARTIFACTID_EXACT, new String[] { "archiva-common" }, "archiva-common" );
     }
 
-    public void testExactMatchArtifactIdTestNg() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdTestNg() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.ARTIFACTID_EXACT, new String[] { "testng" }, "testng" );
     }
 
-    public void testExactMatchArtifactIdInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchArtifactIdInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.ARTIFACTID_EXACT, "foo" );
     }
 
-    public void testExactMatchTypeJar() throws RepositoryIndexSearchException
+    public void testExactMatchTypeJar() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "archiva-common", "redback-authorization-open",
             "testng", "wagon-provider-api" } ), "jar" );
     }
 
-    public void testExactMatchTypeWar() throws RepositoryIndexSearchException
+    public void testExactMatchTypeWar() throws Exception
     {
         assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "continuum-webapp" } ), "war" );
     }
 
     /* TODO: Fix 'maven-plugin' type
-     public void testExactMatchTypePlugin() throws RepositoryIndexSearchException
+     public void testExactMatchTypePlugin() throws Exception
      {
      assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "maven-help-plugin" } ), "maven-plugin" );
      } */
 
     /* TODO: Fix 'maven-archetype' type
-     public void testExactMatchTypeArchetype() throws RepositoryIndexSearchException
+     public void testExactMatchTypeArchetype() throws Exception
      {
      assertQueryExactMatch( ArtifactKeys.TYPE, ( new String[] { "maven-archetype-simple" } ), "maven-archetype" );
      }
      */
 
-    public void testExactMatchTypeInvalid() throws RepositoryIndexSearchException
+    public void testExactMatchTypeInvalid() throws Exception
     {
         assertQueryExactMatchNoResults( ArtifactKeys.TYPE, "foo" );
     }
 
-    public void testExactMatchMd5() throws RepositoryIndexSearchException
+    public void testExactMatchMd5() throws Exception
     {
         assertQueryExactMatch( HashcodesKeys.MD5, ( new String[] { "redback-authorization-open" } ),
                                "f42047fe2e177ac04d0df7aa44d408be" );
     }
 
-    public void testExactMatchMd5Invalid() throws RepositoryIndexSearchException
+    public void testExactMatchMd5Invalid() throws Exception
     {
         assertQueryExactMatchNoResults( HashcodesKeys.MD5, "foo" );
     }
 
-    public void testExactMatchSha1() throws RepositoryIndexSearchException
+    public void testExactMatchSha1() throws Exception
     {
         assertQueryExactMatch( HashcodesKeys.SHA1, ( new String[] { "archiva-common" } ),
                                "c2635a1b38bd4520a6604664c04b2b3c32330864" );
     }
 
-    public void testExactMatchSha1Invalid() throws RepositoryIndexSearchException
+    public void testExactMatchSha1Invalid() throws Exception
     {
         assertQueryExactMatchNoResults( HashcodesKeys.SHA1, "foo" );
     }
@@ -272,7 +271,7 @@
         BooleanQuery bQuery = new BooleanQuery();
         bQuery.add( new MatchAllDocsQuery(), BooleanClause.Occur.MUST );
         bQuery.add( createMatchQuery( ArtifactKeys.CLASSIFIER, "jdk15" ), BooleanClause.Occur.MUST_NOT );
-        List results = index.search( new LuceneQuery( bQuery ) );
+        List results = search( bQuery );
 
         assertResults( new String[] { "archiva-common", "continuum-webapp", "redback-authorization-open",
             "daytrader-ear", "maven-archetype-simple", "maven-help-plugin", "wagon-provider-api" }, results );

Added: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java?view=auto&rev=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java Fri May 25 08:05:51 2007
@@ -0,0 +1,41 @@
+package org.apache.maven.archiva.indexer.search;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * AllTests - conveinence test suite for IDE users. 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class AllTests
+{
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.indexer.search" );
+        //$JUnit-BEGIN$
+        suite.addTestSuite( DefaultCrossRepositorySearchTest.class );
+        //$JUnit-END$
+        return suite;
+    }
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/AllTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/BytecodeIndexPopulator.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/BytecodeIndexPopulator.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/BytecodeIndexPopulator.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/BytecodeIndexPopulator.java Fri May 25 08:05:51 2007
@@ -98,6 +98,7 @@
             ArchivaArtifact artifact = (ArchivaArtifact) entry.getValue();
             File dumpFile = getDumpFile( basedir, artifact );
             BytecodeRecord record = BytecodeRecordLoader.loadRecord( dumpFile, artifact );
+            record.setRepositoryId( "test-repo" );
             records.put( entry.getKey(), record );
         }
 

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java Fri May 25 08:05:51 2007
@@ -20,11 +20,16 @@
  */
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.lucene.search.Hits;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.Searcher;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.RepositoryConfiguration;
 import org.apache.maven.archiva.indexer.MockConfiguration;
 import org.apache.maven.archiva.indexer.RepositoryContentIndex;
 import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory;
+import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
 import org.apache.maven.archiva.model.ArchivaRepository;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.util.FileUtils;
@@ -68,6 +73,7 @@
         repoConfig.setName( repository.getModel().getName() );
         repoConfig.setUrl( repository.getModel().getUrl() );
         repoConfig.setIndexDir( indexLocation.getAbsolutePath() );
+        repoConfig.setIndexed( true );
 
         if ( indexLocation.exists() )
         {
@@ -84,10 +90,27 @@
         // Now populate them.
         Map hashcodesMap = ( new HashcodesIndexPopulator() ).populate( new File( getBasedir() ) );
         indexHashcode.indexRecords( hashcodesMap.values() );
+        assertEquals( "Hashcode Key Count", hashcodesMap.size(), indexHashcode.getAllRecordKeys().size() );
+        assertRecordCount( indexHashcode, hashcodesMap.size() );
+
         Map bytecodeMap = ( new BytecodeIndexPopulator() ).populate( new File( getBasedir() ) );
         indexBytecode.indexRecords( bytecodeMap.values() );
+        assertEquals( "Bytecode Key Count", bytecodeMap.size(), indexBytecode.getAllRecordKeys().size() );
+        assertRecordCount( indexBytecode, bytecodeMap.size() );
+
         Map contentMap = ( new FileContentIndexPopulator() ).populate( new File( getBasedir() ) );
         indexContents.indexRecords( contentMap.values() );
+        assertEquals( "File Content Key Count", contentMap.size(), indexContents.getAllRecordKeys().size() );
+        assertRecordCount( indexContents, contentMap.size() );
+    }
+
+    private void assertRecordCount( RepositoryContentIndex index, int expectedCount )
+        throws Exception
+    {
+        Query query = new MatchAllDocsQuery();
+        Searcher searcher = (Searcher) index.getSearchable();
+        Hits hits = searcher.search( query );
+        assertEquals( "Expected Record Count for " + index.getId(), expectedCount, hits.length() );
     }
 
     private CrossRepositorySearch lookupCrossRepositorySearch()
@@ -98,34 +121,47 @@
         return search;
     }
 
-    public void testSearchTerm()
+    public void testSearchTerm_Org()
+        throws Exception
+    {
+        CrossRepositorySearch search = lookupCrossRepositorySearch();
+
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 20 );
+
+        SearchResults results = search.searchForTerm( "org", limits );
+        assertResults( 1, 7, results );
+    }
+
+    public void testSearchTerm_Junit()
         throws Exception
     {
         CrossRepositorySearch search = lookupCrossRepositorySearch();
 
-        SearchResults results = search.searchForTerm( "org" );
-        assertHitCounts( 1, 8, 8, 1, results );
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 20 );
 
-        results = search.searchForTerm( "junit" );
-        assertHitCounts( 1, 1, 0, 1, results );
-        
-        results = search.searchForTerm( "monosodium" );
-        assertHitCounts( 1, 0, 0, 0, results );
+        SearchResults results = search.searchForTerm( "junit", limits );
+        assertResults( 1, 3, results );
     }
 
-    private void assertHitCounts( int repoCount, int bytecodeCount, int hashcodeCount, int contentCount,
-                                  SearchResults results )
+    public void testSearchInvalidTerm()
+        throws Exception
+    {
+        CrossRepositorySearch search = lookupCrossRepositorySearch();
+
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize( 20 );
+
+        SearchResults results = search.searchForTerm( "monosodium", limits );
+        assertResults( 1, 0, results );
+    }
+
+    private void assertResults( int repoCount, int hitCount, SearchResults results )
     {
         assertNotNull( "Search Results should not be null.", results );
         assertEquals( "Repository Hits", repoCount, results.getRepositories().size() );
 
-        if ( ( bytecodeCount != results.getBytecodeHits().size() )
-            || ( hashcodeCount != results.getHashcodeHits().size() )
-            /* || ( contentCount != results.getContentHits().size() ) */ )
-        {
-            fail( "Failed to get expected results hit count.  Expected: (bytecode,hashcode,content) <" + bytecodeCount
-                + "," + hashcodeCount + "," + contentCount + ">, but got <" + results.getBytecodeHits().size() + ","
-                + results.getHashcodeHits().size() + "," + results.getContentHits().size() + "> instead." );
-        }
+        assertEquals( "Search Result Hits", hitCount, results.getHits().size() );
     }
 }

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/FileContentIndexPopulator.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/FileContentIndexPopulator.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/FileContentIndexPopulator.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/FileContentIndexPopulator.java Fri May 25 08:05:51 2007
@@ -49,8 +49,18 @@
 
         File repoDir = new File( basedir, "src/test/managed-repository" );
 
-        map.put( "parent-pom-1",
-                 createFileContentRecord( repoDir, "org/apache/maven/archiva/record/parent-pom/1/parent-pom-1.pom" ) );
+        String prefix = "org/apache/maven/archiva/record/";
+
+        map.put( "parent-pom-1", createFileContentRecord( repoDir, prefix + "parent-pom/1/parent-pom-1.pom" ) );
+        map.put( "child-pom-1.0-SNAPSHOT", createFileContentRecord( repoDir, prefix
+            + "test-child-pom/1.0-SNAPSHOT/test-child-pom-1.0-20060728.121314-1.pom" ) );
+        map.put( "test-archetype-1.0", createFileContentRecord( repoDir, prefix
+            + "test-archetype/1.0/test-archetype-1.0.pom" ) );
+        map.put( "test-jar-and-pom-1.0-alpha-1", createFileContentRecord( repoDir, prefix
+            + "test-jar-and-pom/1.0-alpha-1/test-jar-and-pom-1.0-alpha-1.pom" ) );
+        map.put( "test-plugin-1.0", createFileContentRecord( repoDir, prefix + "test-plugin/1.0/test-plugin-1.0.pom" ) );
+        map.put( "test-pom-1.0", createFileContentRecord( repoDir, prefix + "test-pom/1.0/test-pom-1.0.pom" ) );
+        map.put( "test-skin-1.0", createFileContentRecord( repoDir, prefix + "test-skin/1.0/test-skin-1.0.pom" ) );
 
         return map;
     }
@@ -65,7 +75,8 @@
         }
 
         FileContentRecord record = new FileContentRecord();
-        record.setFile( pathToFile );
+        record.setRepositoryId( "test-repo" );
+        record.setFilename( path );
 
         try
         {

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/HashcodesIndexPopulator.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/HashcodesIndexPopulator.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/HashcodesIndexPopulator.java (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/HashcodesIndexPopulator.java Fri May 25 08:05:51 2007
@@ -64,6 +64,7 @@
             ArchivaArtifact artifact = (ArchivaArtifact) entry.getValue();
             File dumpFile = getDumpFile( basedir, artifact );
             HashcodesRecord record = HashcodesRecordLoader.loadRecord( dumpFile, artifact );
+            record.setRepositoryId( "test-repo" );
             records.put( entry.getKey(), record );
         }
 

Added: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml?view=auto&rev=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml (added)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml Fri May 25 08:05:51 2007
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+  <appender name="console" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out"/>
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d [%t] %-5p %-30c{1} - %m%n"/>
+    </layout>
+  </appender>
+
+  <!-- Help identify bugs during testing -->
+  <logger name="org.apache.maven">
+    <level value="debug"/>
+  </logger>
+
+  <logger name="org.codehaus.plexus.security">
+    <level value="info"/>
+  </logger>
+
+  <!-- squelch noisy objects (for now) -->
+  <logger name="org.codehaus.plexus.mailsender.MailSender">
+    <level value="info"/>
+  </logger>
+
+  <logger name="org.quartz">
+    <level value="info"/>
+  </logger>
+
+  <logger name="org.apache.jasper">
+    <level value="info"/>
+  </logger>
+
+  <logger name="com.opensymphony.xwork">
+    <level value="info"/>
+  </logger>
+
+  <logger name="com.opensymphony.webwork">
+    <level value="info"/>
+  </logger>
+
+  <logger name="org.codehaus.plexus.PlexusContainer">
+    <level value="info"/>
+  </logger>
+
+  <logger name="JPOX">
+    <level value="warn"/>
+  </logger>
+
+  <logger name="JPOX.MetaData">
+    <level value="error"/>
+  </logger>
+
+  <logger name="JPOX.RDBMS.SQL">
+    <level value="error"/>
+  </logger>
+
+  <logger name="SQL">
+    <level value="error"/>
+  </logger>
+
+  <logger name="freemarker">
+    <level value="warn"/>
+  </logger>
+
+  <logger name="org.codehaus.plexus.component.manager.ClassicSingletonComponentManager">
+    <level value="error"/>
+  </logger>
+
+  <root>
+    <priority value="debug" />
+    <appender-ref ref="console" />
+  </root>
+
+</log4j:configuration>

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.xml
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.xml?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.xml (original)
+++ maven/archiva/trunk/archiva-base/archiva-indexer/src/test/resources/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.xml Fri May 25 08:05:51 2007
@@ -25,9 +25,29 @@
       <description>DefaultCrossRepositorySearch</description>
       <requirements>
         <requirement>
-          <role>org.apache.maven.archiva.indexer.RepositoryContentIndexFactory</role>
-          <role-hint>lucene</role-hint>
-          <field-name>indexFactory</field-name>
+          <role>org.apache.commons.collections.Transformer</role>
+          <role-hint>bytecode</role-hint>
+          <field-name>bytecodeIndexTransformer</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.commons.collections.Transformer</role>
+          <role-hint>filecontent</role-hint>
+          <field-name>filecontentIndexTransformer</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.commons.collections.Transformer</role>
+          <role-hint>hashcodes</role-hint>
+          <field-name>hashcodesIndexTransformer</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.commons.collections.Transformer</role>
+          <role-hint>searchable</role-hint>
+          <field-name>searchableTransformer</field-name>
+        </requirement>
+        <requirement>
+          <role>org.apache.commons.collections.Predicate</role>
+          <role-hint>index-exists</role-hint>
+          <field-name>indexExistsPredicate</field-name>
         </requirement>
         <requirement>
           <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>

Added: maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java?view=auto&rev=541680
==============================================================================
--- maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java (added)
+++ maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java Fri May 25 08:05:51 2007
@@ -0,0 +1,53 @@
+package org.apache.maven.archiva.model.functors;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.Predicate;
+import org.apache.maven.archiva.model.ArchivaRepository;
+
+/**
+ * ManagedRepositoryPredicate 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+public class ManagedRepositoryPredicate
+    implements Predicate
+{
+    public static final Predicate INSTANCE = new ManagedRepositoryPredicate();
+
+    public static Predicate getInstance()
+    {
+        return INSTANCE;
+    }
+
+    public boolean evaluate( Object object )
+    {
+        boolean satisfies = false;
+
+        if ( object instanceof ArchivaRepository )
+        {
+            ArchivaRepository repo = (ArchivaRepository) object;
+            return repo.isManaged();
+        }
+
+        return satisfies;
+    }
+}

Propchange: maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: maven/archiva/trunk/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/functors/ManagedRepositoryPredicate.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java Fri May 25 08:05:51 2007
@@ -19,10 +19,12 @@
  * under the License.
  */
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.maven.archiva.indexer.RepositoryIndexException;
 import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
 import org.apache.maven.archiva.indexer.search.CrossRepositorySearch;
+import org.apache.maven.archiva.indexer.search.SearchResultLimits;
 import org.apache.maven.archiva.indexer.search.SearchResults;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
@@ -42,11 +44,6 @@
     private String q;
 
     /**
-     * The MD5 to search by.
-     */
-    private String md5;
-    
-    /**
      * The Search Results.
      */
     private SearchResults results;
@@ -65,13 +62,15 @@
     {
         /* TODO: give action message if indexing is in progress.
          * This should be based off a count of 'unprocessed' artifacts.
-         * This (yet to be written) routine could tell the user that X artifacts are not yet 
+         * This (yet to be written) routine could tell the user that X (unprocessed) artifacts are not yet 
          * present in the full text search.
          */
 
         assert q != null && q.length() != 0;
 
-        results = crossRepoSearch.searchForTerm( q );
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+
+        results = crossRepoSearch.searchForTerm( q, limits );
 
         if ( results.isEmpty() )
         {
@@ -80,7 +79,7 @@
         }
 
         // TODO: filter / combine the artifacts by version? (is that even possible with non-artifact hits?)
-        
+
         /* I don't think that we should, as I expect us to utilize the 'score' system in lucene in 
          * the future to return relevant links better.
          * I expect the lucene scoring system to take multiple hits on different areas of a single document
@@ -96,18 +95,25 @@
     {
         // TODO: give action message if indexing is in progress
 
-        assert md5 != null && md5.length() != 0;
+        if ( StringUtils.isBlank( q ) )
+        {
+            addActionError( "Unable to search for a blank checksum" );
+            return INPUT;
+        }
+
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+
+        results = crossRepoSearch.searchForChecksum( q, limits );
 
-        results = crossRepoSearch.searchForMd5( q );
-        
         if ( results.isEmpty() )
         {
             addActionError( "No results found" );
             return INPUT;
         }
-        
-        if ( results.getHashcodeHits().size() == 1 )
+
+        if ( results.getHits().size() == 1 )
         {
+            // 1 hit? return it's information directly!
             return ARTIFACT;
         }
         else
@@ -131,13 +137,8 @@
         this.q = q;
     }
 
-    public String getMd5()
-    {
-        return md5;
-    }
-
-    public void setMd5( String md5 )
+    public SearchResults getResults()
     {
-        this.md5 = md5;
+        return results;
     }
 }

Modified: maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp
URL: http://svn.apache.org/viewvc/maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp?view=diff&rev=541680&r1=541679&r2=541680
==============================================================================
--- maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp (original)
+++ maven/archiva/trunk/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/results.jsp Fri May 25 08:05:51 2007
@@ -19,6 +19,7 @@
 
 <%@ taglib uri="/webwork" prefix="ww" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
 <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
 
 <html>
@@ -39,48 +40,44 @@
   <h1>Results</h1>
 
   <div id="resultsBox">
-    <ww:set name="searchResults" value="searchResults"/>
-    <c:forEach items="${searchResults}" var="record" varStatus="i">
-
-
-      <h3 class="artifact-title">
-        <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
-                              version="${record.version}"/>
-      </h3>
-
-      <p>
-        <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
-                             version="${record.version}" versions="${record.versions}"/>
-
-          <%-- TODO: hits
-          <table border="1px" width="100%" cellspacing="0">
-            <c:forEach items="${result.fieldMatchesEntrySet}" var="entry">
-              <tr>
-                <td valign="top" width="15%" align="right"><c:out value="${entry.key}"/></td>
-                <td valign="top">
-                  <c:forEach items="${entry.value}" var="item">
-                    <c:out value="${item}" />
-                  </c:forEach>
-                  <br/>
-                </td>
-              </tr>
-            </c:forEach>
-          </table>
-        </td>
-          <td>
-
-            <code>org.apache.maven</code>
-            (package)
-            <br/>
-            <code>org.apache.maven.model</code>
-            (package)
-          </td>
-          <td>
-            <a href="artifact.html">Details</a>
-          </td>
-          --%>
-      </p>
-    </c:forEach>
+    <p>Hits: ${fn:length(results.hits)}</p>
+    
+    <c:choose>
+      <c:when test="${empty results.hits}">
+        <p>No results</p>
+      </c:when>
+      <c:otherwise>
+        <c:forEach items="${results.hits}" var="record" varStatus="i">
+          <p>${record.url}</p>
+          <p>${record.groupId}</p>
+          <p>${record.artifactId}</p>
+        </c:forEach>
+        <%--
+        <c:forEach items="${results.hachcodeHits}" var="record" varStatus="i">
+          <p>${record}</p>
+          <h3 class="artifact-title">
+            <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
+                                  version="${record.version}"/>
+          </h3>
+          <p>
+            <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
+                                 version="${record.version}" versions="${record.versions}"/>
+          </p>
+        </c:forEach>
+        <c:forEach items="${results.bytecodeHits}" var="record" varStatus="i">
+          <p>${record}</p>
+          <h3 class="artifact-title">
+            <my:showArtifactTitle groupId="${record.groupId}" artifactId="${record.artifactId}"
+                                  version="${record.version}"/>
+          </h3>
+          <p>
+            <my:showArtifactLink groupId="${record.groupId}" artifactId="${record.artifactId}"
+                                 version="${record.version}" versions="${record.versions}"/>
+          </p>
+        </c:forEach>
+         --%>
+      </c:otherwise>
+    </c:choose>
   </div>
 </div>
 </body>