archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r702347 [2/4] - in /archiva/branches/MRM-124: ./ archiva-docs/src/site/apt/userguide/ archiva-jetty/ archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/ archiva-modules/archiva-base/archiva-consumers/archiva-core-consumer...
Date Tue, 07 Oct 2008 05:12:37 GMT
Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/maven/archiva/consumers/core/repository/RetentionCountRepositoryPurgeTest.java Mon Oct  6 22:12:33 2008
@@ -1,5 +1,7 @@
 package org.apache.maven.archiva.consumers.core.repository;
 
+import java.util.Collections;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,14 +21,6 @@
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexStub;
-import org.apache.maven.archiva.indexer.RepositoryContentIndex;
-
 /**
  * Test RetentionsCountRepositoryPurgeTest
  *
@@ -41,13 +35,11 @@
     {
         super.setUp();
 
-        Map<String, RepositoryContentIndex> map = new HashMap<String, RepositoryContentIndex>();
-        map.put( "filecontent", new LuceneRepositoryContentIndexStub( 2 ) );
-        map.put( "hashcodes", new LuceneRepositoryContentIndexStub( 2 ) );
-        map.put( "bytecode", new LuceneRepositoryContentIndexStub( 2 ) );
-        
-        repoPurge = new RetentionCountRepositoryPurge( getRepository(), dao,
-                                                       getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(), map );
+        repoPurge =
+            new RetentionCountRepositoryPurge(
+                                               getRepository(),
+                                               getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ).getRetentionCount(),
+                                               Collections.singletonList( listener ) );
     }
 
     /**
@@ -58,12 +50,23 @@
     public void testIfAJarWasFound()
         throws Exception
     {
-        populateIfJarWasFoundDb();
-
         String repoRoot = prepareTestRepos();
 
+        // test listeners for the correct artifacts
+        listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
+                                                                  "1.0RC1-20070504.153317-1", "jar" ) );
+        listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
+                                                                  "1.0RC1-20070504.153317-1", "pom" ) );
+        listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
+                                                                  "1.0RC1-20070504.160758-2", "jar" ) );
+        listener.deleteArtifact( getRepository(), createArtifact( "org.jruby.plugins", "jruby-rake-plugin",
+                                                                  "1.0RC1-20070504.160758-2", "pom" ) );
+        listenerControl.replay();
+        
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_ARTIFACT );
         
+        listenerControl.verify();
+
         String versionRoot = repoRoot + "/org/jruby/plugins/jruby-rake-plugin/1.0RC1-SNAPSHOT";
 
         // assert if removed from repo
@@ -105,11 +108,18 @@
     public void testIfAPomWasFound()
         throws Exception
     {
-        populateIfPomWasFoundDb();
-
         String repoRoot = prepareTestRepos();
 
+        // test listeners for the correct artifacts
+        listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks",
+                                                                  "1.1.2-20070427.065136-1", "jar" ) );
+        listener.deleteArtifact( getRepository(), createArtifact( "org.codehaus.castor", "castor-anttasks",
+                                                                  "1.1.2-20070427.065136-1", "pom" ) );
+        listenerControl.replay();
+        
         repoPurge.process( PATH_TO_BY_RETENTION_COUNT_POM );
+        
+        listenerControl.verify();
 
         String versionRoot = repoRoot + "/org/codehaus/castor/castor-anttasks/1.1.2-SNAPSHOT";
         
@@ -146,12 +156,19 @@
     public void testOrderOfDeletion()
         throws Exception
     {
-        populateDbForTestOrderOfDeletion();
-
         String repoRoot = prepareTestRepos();
 
+        // test listeners for the correct artifacts
+        listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin",
+                                                                  "1.1.2-20070427.065136-1", "maven-plugin" ) );
+        listener.deleteArtifact( getRepository(), createArtifact( "org.apache.maven.plugins", "maven-assembly-plugin",
+                                                                  "1.1.2-20070427.065136-1", "pom" ) );
+        listenerControl.replay();
+        
         repoPurge.process( PATH_TO_TEST_ORDER_OF_DELETION );
 
+        listenerControl.verify();
+
         String versionRoot = repoRoot + 
             "/org/apache/maven/plugins/maven-assembly-plugin/1.1.2-SNAPSHOT";
         
@@ -177,27 +194,4 @@
         assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.sha1" );
         assertExists( versionRoot + "/maven-assembly-plugin-1.1.2-20070615.105019-3.pom.md5" );
     }
-    
-    public void populateIfJarWasFoundDb()
-        throws Exception
-    {
-        List<String> versions = new ArrayList<String>();
-        versions.add( "1.0RC1-20070504.153317-1" );
-        versions.add( "1.0RC1-20070504.160758-2" );
-        versions.add( "1.0RC1-20070505.090015-3" );
-        versions.add( "1.0RC1-20070506.090132-4" );
-
-        populateDb( "org.jruby.plugins", "jruby-rake-plugin", versions );
-    }
-
-    public void populateIfPomWasFoundDb()
-        throws Exception
-    {
-        List<String> versions = new ArrayList<String>();
-        versions.add( "1.1.2-20070427.065136-1" );
-        versions.add( "1.1.2-20070615.105019-3" );
-        versions.add( "1.1.2-20070506.163513-2" );
-
-        populateDb( "org.codehaus.castor", "castor-anttasks", versions );
-    }
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/resources/org/apache/maven/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.xml Mon Oct  6 22:12:33 2008
@@ -32,10 +32,6 @@
           <role-hint>retention-count</role-hint>
         </requirement>
         <requirement>
-          <role>org.apache.maven.archiva.database.ArchivaDAO</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-        <requirement>
           <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
           <role-hint>retention-count</role-hint>
         </requirement>
@@ -46,11 +42,6 @@
           <role>org.apache.maven.archiva.configuration.FileTypes</role>
           <role-hint>retention-count</role-hint>
         </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.indexer.RepositoryContentIndexFactory</role>
-          <role-hint>lucene</role-hint>
-          <field-name>indexFactory</field-name>
-        </requirement>
       </requirements>
       <configuration>
         <id>repository-purge</id>
@@ -124,10 +115,6 @@
           <role-hint>days-old</role-hint>
         </requirement>
         <requirement>
-          <role>org.apache.maven.archiva.database.ArchivaDAO</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-        <requirement>
           <role>org.apache.maven.archiva.repository.RepositoryContentFactory</role>
           <role-hint>days-old</role-hint>
         </requirement>
@@ -138,11 +125,6 @@
           <role>org.apache.maven.archiva.configuration.FileTypes</role>
           <role-hint>days-old</role-hint>
         </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.indexer.RepositoryContentIndexFactory</role>
-          <role-hint>lucene</role-hint>
-          <field-name>indexFactory</field-name>
-        </requirement>
       </requirements>
       <configuration>
         <id>repository-purge</id>
@@ -203,106 +185,5 @@
         </requirement>
       </requirements>
     </component>
-
-
-    <!-- DAOs -->
-    <component>
-      <role>org.apache.maven.archiva.database.ArchivaDAO</role>
-      <role-hint>jdo</role-hint>
-      <implementation>org.apache.maven.archiva.database.jdo.JdoArchivaDAO</implementation>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
-          <role-hint>archiva</role-hint>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.database.ArtifactDAO</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.database.ProjectModelDAO</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-        <requirement>
-          <role>org.apache.maven.archiva.database.RepositoryProblemDAO</role>
-          <role-hint>jdo</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.database.ArtifactDAO</role>
-      <role-hint>jdo</role-hint>
-      <implementation>org.apache.maven.archiva.database.jdo.JdoArtifactDAO</implementation>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
-          <role-hint>archiva</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.database.ProjectModelDAO</role>
-      <role-hint>jdo</role-hint>
-      <implementation>org.apache.maven.archiva.database.jdo.JdoProjectModelDAO</implementation>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
-          <role-hint>archiva</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-    <component>
-      <role>org.apache.maven.archiva.database.RepositoryProblemDAO</role>
-      <role-hint>jdo</role-hint>
-      <implementation>org.apache.maven.archiva.database.jdo.JdoRepositoryProblemDAO</implementation>
-      <requirements>
-        <requirement>
-          <role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
-          <role-hint>archiva</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-
-
-    <!-- JdoAccess -->
-    <component>
-      <role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
-      <role-hint>archiva</role-hint>
-      <implementation>org.apache.maven.archiva.database.jdo.JdoAccess</implementation>
-      <requirements>
-        <requirement>
-          <role>org.codehaus.plexus.jdo.JdoFactory</role>
-          <role-hint>archiva</role-hint>
-        </requirement>
-      </requirements>
-    </component>
-
-    <!-- JDO Factory -->
-    <component>
-      <role>org.codehaus.plexus.jdo.JdoFactory</role>
-      <role-hint>archiva</role-hint>
-      <implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
-      <configuration>
-        <persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
-        <driverName>org.hsqldb.jdbcDriver</driverName>
-        <userName>sa</userName>
-        <password></password>
-        <url>jdbc:hsqldb:mem:testdb</url>
-        <otherProperties>
-          <property>
-            <name>javax.jdo.PersistenceManagerFactoryClass</name>
-            <value>org.jpox.PersistenceManagerFactoryImpl</value>
-          </property>
-        </otherProperties>
-      </configuration>
-    </component>
-    
-    <!-- LuceneRepositoryIndexFactory -->
-    <component>
-      <role>org.apache.maven.archiva.indexer.RepositoryContentIndexFactory</role>
-      <role-hint>lucene</role-hint>
-      <implementation>org.apache.maven.archiva.consumers.core.repository.stubs.LuceneRepositoryContentIndexFactoryStub</implementation>
-    </component>
-
   </components>
 </component-set>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/maven/archiva/consumers/lucene/IndexContentConsumer.java Mon Oct  6 22:12:33 2008
@@ -21,6 +21,7 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
+import org.apache.maven.archiva.configuration.ConfigurationNames;
 import org.apache.maven.archiva.configuration.FileTypes;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
@@ -98,9 +99,7 @@
      * @plexus.requirement role-hint="lucene"
      */
     private RepositoryContentIndexFactory indexFactory;
-
-    private List<String> propertyNameTriggers = new ArrayList<String>();
-
+    
     private List<String> includes = new ArrayList<String>();
 
     private RepositoryContentIndex index;
@@ -198,7 +197,7 @@
 
     public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
     {
-        if ( propertyNameTriggers.contains( propertyName ) )
+        if ( ConfigurationNames.isRepositoryScanning( propertyName ) )
         {
             initIncludes();
         }
@@ -219,13 +218,6 @@
     public void initialize()
         throws InitializationException
     {
-        propertyNameTriggers = new ArrayList<String>();
-        propertyNameTriggers.add( "repositoryScanning" );
-        propertyNameTriggers.add( "fileTypes" );
-        propertyNameTriggers.add( "fileType" );
-        propertyNameTriggers.add( "patterns" );
-        propertyNameTriggers.add( "pattern" );
-
         configuration.addChangeListener( this );
 
         initIncludes();

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/CrossRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/CrossRepositorySearch.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/CrossRepositorySearch.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/CrossRepositorySearch.java Mon Oct  6 22:12:33 2008
@@ -69,4 +69,21 @@
      * @return the results.
      */
     public SearchResults searchForChecksum( String principal, List<String> selectedRepos, String checksum, SearchResultLimits limits );
+    
+    /**
+     * Search for a specific artifact matching the given field values. The search is performed on the bytecode
+     * index/indices.
+     * 
+     * @param principal
+     * @param selectedRepos repository to be searched
+     * @param groupId groupId to be matched
+     * @param artifactId artifactId to be matched
+     * @param version version to be matched
+     * @param className Java class or package name to be matched
+     * @param limits the limits to apply to the search results
+     * @return
+     */
+    public SearchResults executeFilteredSearch( String principal, List<String> selectedRepos, String groupId,
+                                                String artifactId, String version, String className,
+                                                SearchResultLimits limits );
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearch.java Mon Oct  6 22:12:33 2008
@@ -24,6 +24,7 @@
 import java.util.List;
 
 import org.apache.lucene.document.Document;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.queryParser.MultiFieldQueryParser;
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.lucene.queryParser.QueryParser;
@@ -32,16 +33,20 @@
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.MultiSearcher;
+import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryWrapperFilter;
 import org.apache.lucene.search.Searchable;
+import org.apache.lucene.search.TermQuery;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ConfigurationNames;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+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.RepositoryIndexException;
 import org.apache.maven.archiva.indexer.RepositoryIndexSearchException;
 import org.apache.maven.archiva.indexer.bytecode.BytecodeHandlers;
+import org.apache.maven.archiva.indexer.bytecode.BytecodeKeys;
 import org.apache.maven.archiva.indexer.filecontent.FileContentHandlers;
 import org.apache.maven.archiva.indexer.hashcodes.HashcodesHandlers;
 import org.apache.maven.archiva.indexer.hashcodes.HashcodesKeys;
@@ -57,7 +62,7 @@
 
 /**
  * DefaultCrossRepositorySearch
- *
+ * 
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
  * @plexus.component role="org.apache.maven.archiva.indexer.search.CrossRepositorySearch" role-hint="default"
@@ -66,12 +71,12 @@
     implements CrossRepositorySearch, RegistryListener, Initializable
 {
     private Logger log = LoggerFactory.getLogger( DefaultCrossRepositorySearch.class );
-    
+
     /**
      * @plexus.requirement role-hint="lucene"
      */
     private RepositoryContentIndexFactory indexFactory;
-    
+
     /**
      * @plexus.requirement
      */
@@ -79,14 +84,61 @@
 
     private List<ManagedRepositoryConfiguration> localIndexedRepositories = new ArrayList<ManagedRepositoryConfiguration>();
 
-    public SearchResults searchForChecksum( String principal, List<String> selectedRepos, String checksum, SearchResultLimits limits )
+    public SearchResults executeFilteredSearch( String principal, List<String> selectedRepos, String groupId,
+                                                String artifactId, String version, String className,
+                                                SearchResultLimits limits )
+    {
+        List<RepositoryContentIndex> indexes = getBytecodeIndexes( principal, selectedRepos );
+        SearchResults results = new SearchResults();
+        BooleanQuery booleanQuery = new BooleanQuery();
+
+        if ( groupId != null && groupId.length() > 0 )
+        {
+            parseAndAdd( booleanQuery, ArtifactKeys.GROUPID, groupId, "\\.|-" );
+        }
+
+        if ( artifactId != null && artifactId.length() > 0 )
+        {
+            parseAndAdd( booleanQuery, ArtifactKeys.ARTIFACTID, artifactId, "\\.|-" );
+        }
+
+        if ( version != null && version.length() > 0 )
+        {
+            parseAndAdd( booleanQuery, ArtifactKeys.VERSION, version, "\\.|-" );
+        }
+
+        if ( className != null && className.length() > 0 )
+        {
+
+            try
+            {
+                QueryParser parser =
+                    new MultiFieldQueryParser( new String[] { BytecodeKeys.CLASSES, BytecodeKeys.FILES,
+                        BytecodeKeys.METHODS }, new BytecodeHandlers().getAnalyzer() );
+                booleanQuery.add( parser.parse( className ), BooleanClause.Occur.MUST );
+            }
+            catch ( ParseException e )
+            {
+
+            }
+        }
+
+        LuceneQuery query = new LuceneQuery( booleanQuery );
+        results = searchAll( query, limits, indexes, null );
+        results.getRepositories().add( this.localIndexedRepositories );
+
+        return results;
+    }
+
+    public SearchResults searchForChecksum( String principal, List<String> selectedRepos, String checksum,
+                                            SearchResultLimits limits )
     {
         List<RepositoryContentIndex> indexes = getHashcodeIndexes( principal, selectedRepos );
 
         try
         {
             QueryParser parser = new MultiFieldQueryParser( new String[]{HashcodesKeys.MD5, HashcodesKeys.SHA1},
-                                                            new HashcodesHandlers().getAnalyzer() );
+                                           new HashcodesHandlers().getAnalyzer() );
             LuceneQuery query = new LuceneQuery( parser.parse( checksum ) );
             SearchResults results = searchAll( query, limits, indexes, null );
             results.getRepositories().addAll( this.localIndexedRepositories );
@@ -124,23 +176,22 @@
         return new SearchResults();
     }
 
-    
     public SearchResults searchForTerm( String principal, List<String> selectedRepos, String term, SearchResultLimits limits )
     {
         return searchForTerm( principal, selectedRepos, term, limits, null );        
     }
-    
+
     public SearchResults searchForTerm( String principal, List<String> selectedRepos, String term,
                                         SearchResultLimits limits, List<String> previousSearchTerms )
     {
         List<RepositoryContentIndex> indexes = getFileContentIndexes( principal, selectedRepos );
-        
+
         try
         {
             QueryParser parser = new FileContentHandlers().getQueryParser();
             LuceneQuery query = null;
             SearchResults results = null;
-            if( previousSearchTerms == null || previousSearchTerms.isEmpty() )
+            if ( previousSearchTerms == null || previousSearchTerms.isEmpty() )
             {
                 query = new LuceneQuery( parser.parse( term ) );
                 results = searchAll( query, limits, indexes, null );
@@ -149,17 +200,17 @@
             {
                 // AND the previous search terms
                 BooleanQuery booleanQuery = new BooleanQuery();
-                for( String previousSearchTerm : previousSearchTerms )
+                for ( String previousSearchTerm : previousSearchTerms )
                 {
                     booleanQuery.add( parser.parse( previousSearchTerm ), BooleanClause.Occur.MUST );
                 }
-                
-                query = new LuceneQuery( booleanQuery );                
+
+                query = new LuceneQuery( booleanQuery );
                 Filter filter = new QueryWrapperFilter( parser.parse( term ) );
                 results = searchAll( query, limits, indexes, filter );
-            }            
+            }
             results.getRepositories().addAll( this.localIndexedRepositories );
-            
+
             return results;
         }
         catch ( ParseException e )
@@ -168,9 +219,9 @@
         }
 
         // empty results.
-        return new SearchResults(); 
+        return new SearchResults();
     }
-    
+
     private SearchResults searchAll( LuceneQuery luceneQuery, SearchResultLimits limits, List<RepositoryContentIndex> indexes, Filter filter )
     {
         org.apache.lucene.search.Query specificQuery = luceneQuery.getLuceneQuery();
@@ -203,7 +254,7 @@
 
             // Perform the search.
             Hits hits = null;
-            if( filter != null )
+            if ( filter != null )
             {
                 hits = searcher.search( specificQuery, filter );
             }
@@ -355,7 +406,7 @@
 
         return ret;
     }
-    
+
     private boolean indexExists( RepositoryContentIndex index )
     {
         try
@@ -402,6 +453,26 @@
         }
     }
 
+    private void parseAndAdd( BooleanQuery query, String key, String value, String delimiter )
+    {
+        if ( value != null && value.length() > 0 )
+        {
+            String[] terms = value.split( delimiter );
+            for ( int i = 0; i < terms.length; i++ )
+            {
+                Term valueTerm = new Term( key, terms[i] );
+                Query valueQuery = new TermQuery( valueTerm );
+                query.add( valueQuery, BooleanClause.Occur.MUST );
+            }
+        }
+        else
+        {
+            Term valueTerm = new Term( key, value );
+            Query valueQuery = new TermQuery( valueTerm );
+            query.add( valueQuery, BooleanClause.Occur.MUST );
+        }
+    }
+
     public void initialize()
         throws InitializationException
     {

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/search/SearchResults.java Mon Oct  6 22:12:33 2008
@@ -74,7 +74,7 @@
     private void addBytecodeHit( BytecodeRecord bytecode )
     {
         String key = toKey( bytecode.getArtifact() );
-
+        
         SearchResultHit hit = (SearchResultHit) this.hits.get( key );
 
         if ( hit == null )
@@ -95,7 +95,8 @@
 
         key.append( StringUtils.defaultString( artifact.getModel().getRepositoryId() ) ).append( ":" );
         key.append( StringUtils.defaultString( artifact.getGroupId() ) ).append( ":" );
-        key.append( StringUtils.defaultString( artifact.getArtifactId() ) );
+        key.append( StringUtils.defaultString( artifact.getArtifactId() ) ).append( ":" );
+        key.append( StringUtils.defaultString( artifact.getVersion() ) );
 
         return key.toString();
     }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/maven/archiva/indexer/search/DefaultCrossRepositorySearchTest.java Mon Oct  6 22:12:33 2008
@@ -242,6 +242,51 @@
                              "org.apache.maven.continuum.web.action.BuildDefinitionAction.isBuildFresh", null, true );        
     }
     
+    public void testExecuteFilteredSearch()
+        throws Exception
+    {
+        CrossRepositorySearch search = lookupCrossRepositorySearch();
+
+        String expectedRepos[] = new String[] { TEST_DEFAULT_REPO_ID };
+
+        String expectedResults[] = new String[] { "org1", "org2", "org3", "org4", "org5", "org6", "org7", "org8" };
+
+        String secondExpectedResults[] = new String[] { "continuum-webapp" };
+
+        String thirdExpectedResults[] = new String[] { "archiva-common" };
+
+        // search for groupId
+        assertFilteredSearchResults( expectedRepos, expectedResults, search, "org", null, null, null, 30 );
+
+        // search for groupId and artifactId
+        assertFilteredSearchResults( expectedRepos, secondExpectedResults, search, "org.apache.maven",
+                                     "continuum-webapp", null, null, 30 );
+
+        // search for groupId , artifactId and version
+        assertFilteredSearchResults( expectedRepos, thirdExpectedResults, search, "org.apache.maven.archiva",
+                                     "archiva-common", "1.0", null, 30 );
+    }
+    
+    private void assertFilteredSearchResults ( String expectedRepos[], String expectedResults[], CrossRepositorySearch search, 
+                                               String groupId, String artifactId, String version, String className , int rowCount )
+    {
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+        limits.setPageSize(  rowCount );
+        
+        List<String> selectedRepos = new ArrayList<String>();
+        selectedRepos.addAll( Arrays.asList( expectedRepos ) );
+        
+        SearchResults results = null;
+        
+        results = search.executeFilteredSearch( "guest" , selectedRepos, groupId, artifactId, version, className, limits );
+        
+        assertNotNull( "Search Results should not be null.", results );
+        assertEquals( "Repository Hits", expectedRepos.length, results.getRepositories().size() );
+        assertEquals( expectedRepos.length, 1);
+        assertEquals( TEST_DEFAULT_REPO_ID , selectedRepos.get( 0 ) );
+        assertEquals( "Search Result Hits", expectedResults.length, results.getHits().size() );
+    }
+    
     private void assertSearchResults( String expectedRepos[], String expectedResults[], CrossRepositorySearch search,
                                       String term, List<String> previousSearchTerms, boolean bytecode )
         throws Exception
@@ -251,11 +296,12 @@
         
         List<String> selectedRepos = new ArrayList<String>();
         selectedRepos.addAll( Arrays.asList( expectedRepos ) );
-        
+       
         SearchResults results = null;
+
         if( previousSearchTerms == null )
-        {
-            if( bytecode )
+            {
+                if( bytecode )
             {
                 results = search.searchForBytecode( "guest", selectedRepos, term, limits );
             }
@@ -268,16 +314,18 @@
         {
             results = search.searchForTerm( "guest", selectedRepos, term, limits, previousSearchTerms );
         }
+
         
         assertNotNull( "Search Results should not be null.", results );
         assertEquals( "Repository Hits", expectedRepos.length, results.getRepositories().size() );
+        
         // TODO: test the repository ids returned.
 
         assertEquals( "Search Result Hits", expectedResults.length, results.getHits().size() );
         // TODO: test the order of hits.
         // TODO: test the value of the hits.
     }
-
+    
     protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
     {
         ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();

Modified: archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-base/archiva-model/src/main/mdo/archiva-base.xml Mon Oct  6 22:12:33 2008
@@ -2346,6 +2346,46 @@
             The number of new files discovered.
           </description>
         </field>
+        <field>
+          <name>totalProjectCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of unique projects in the repository.
+          </description>
+        </field>
+        <field>
+          <name>totalGroupCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of unique groups in the repository.
+          </description>
+        </field>
+        <field>
+          <name>totalArtifactCount</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total number of artifacts in the repository. 
+          </description>
+        </field>
+        <field>
+          <name>totalSize</name>
+          <version>1.0.0+</version>
+          <identifier>false</identifier>
+          <required>true</required>
+          <type>long</type>
+          <description>
+            The total size in bytes of the repository.
+          </description>
+        </field>
       </fields>
       <codeSegments>
         <codeSegment>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/pom.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/pom.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/pom.xml Mon Oct  6 22:12:33 2008
@@ -74,10 +74,6 @@
       <groupId>log4j</groupId>
       <artifactId>log4j</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-    </dependency>
     <!--  TEST DEPS  -->
     <dependency>
       <groupId>org.codehaus.plexus.registry</groupId>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/AbstractDeclarativeConstraint.java Mon Oct  6 22:12:33 2008
@@ -40,6 +40,8 @@
     protected Object[] params;
 
     protected int[] range;
+    
+    protected String sortDirection = Constraint.ASCENDING;
 
     public String getFilter()
     {
@@ -68,7 +70,7 @@
 
     public String getSortDirection()
     {
-        return Constraint.ASCENDING;
+        return sortDirection;
     }
     
     public String[] getVariables()

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraint.java Mon Oct  6 22:12:33 2008
@@ -44,14 +44,26 @@
         params = new Object[] { repoId };
 	}
 		
-	public ArtifactsByRepositoryConstraint( String repoId, Date targetWhenGathered, String sortColumn )
+	public ArtifactsByRepositoryConstraint( String repoId, Date targetWhenGathered, String sortColumn, boolean isBefore )
     {
+	    String condition = isBefore ? "<=" : ">=";
+	    
 	    declImports = new String[] { "import java.util.Date" };
-	    whereClause = "this.repositoryId == repoId && this.whenGathered >= targetWhenGathered";        
+	    whereClause = "this.repositoryId == repoId && this.whenGathered " + condition + " targetWhenGathered";        
         declParams = new String[] { "String repoId", "Date targetWhenGathered" };
         params = new Object[] { repoId, targetWhenGathered };        
         this.sortColumn = sortColumn;
     }
+	
+	public ArtifactsByRepositoryConstraint( String repoId, String type, Date before, String sortColumn )
+	{
+	    declImports = new String[] { "import java.util.Date" };
+        whereClause =
+            "this.repositoryId == repoId && this.type == type && this.whenGathered <= before";        
+        declParams = new String[] { "String repoId", "String type", "Date before" };
+        params = new Object[] { repoId, type, before };        
+        this.sortColumn = sortColumn;
+	}
 		
 	public String getSortColumn() 
 	{		

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraint.java Mon Oct  6 22:12:33 2008
@@ -1,5 +1,9 @@
 package org.apache.maven.archiva.database.constraints;
 
+import java.util.Date;
+
+import org.apache.maven.archiva.database.Constraint;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -36,6 +40,16 @@
         declParams = new String[] { "String repoId" };
         params = new Object[] { repoId };
     }
+    
+    public RepositoryContentStatisticsByRepositoryConstraint( String repoId, Date startDate, Date endDate )
+    {    
+        declImports = new String[] { "import java.util.Date" };
+        whereClause = "repositoryId == repoId && whenGathered >= startDate && whenGathered <= endDate";
+        declParams = new String[] { "String repoId", "Date startDate", "Date endDate" };
+        params = new Object[] { repoId, startDate, endDate };
+        
+        sortDirection = Constraint.DESCENDING;
+    }
 
     public String getSortColumn()
     {

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraint.java Mon Oct  6 22:12:33 2008
@@ -35,7 +35,9 @@
     implements Constraint
 {
     private StringBuffer sql = new StringBuffer();
-
+    
+    private Class resultClass;
+    
     /**
      * Obtain a set of unique ArtifactIds for the specified groupId.
      * 
@@ -43,7 +45,7 @@
      */
     public UniqueArtifactIdConstraint( List<String> selectedRepositoryIds, String groupId )
     {
-        appendSelect( sql );
+        appendSelect( sql, false );
         sql.append( " WHERE " );
         SqlBuilder.appendWhereSelectedRepositories( sql, "repositoryId", selectedRepositoryIds );
         sql.append( " && " );
@@ -60,17 +62,36 @@
      */
     public UniqueArtifactIdConstraint( String groupId )
     {
-        appendSelect( sql );
+        appendSelect( sql, false );
         sql.append( " WHERE " );
         appendWhereSelectedGroupId( sql );
         appendGroupBy( sql );
 
         super.params = new Object[] { groupId };
     }
+    
+    /**
+     * Obtain a set of unique artifactIds with respect to their groups from the specified repository.
+     * 
+     * @param repoId
+     * @param isUnique
+     */
+    public UniqueArtifactIdConstraint( String repoId, boolean isUnique )
+    {
+        appendSelect( sql, isUnique );
+        sql.append( " WHERE repositoryId == \"" + repoId + "\"" );
+        
+        resultClass = Object[].class;
+    }
 
     @SuppressWarnings("unchecked")
     public Class getResultClass()
     {
+        if( resultClass != null )
+        {
+            return resultClass;
+        }
+        
         return String.class;
     }
 
@@ -84,9 +105,16 @@
         buf.append( " GROUP BY artifactId ORDER BY artifactId ASCENDING" );
     }
 
-    private void appendSelect( StringBuffer buf )
+    private void appendSelect( StringBuffer buf, boolean isUnique )
     {
-        buf.append( "SELECT artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        if( isUnique )
+        {
+            buf.append( "SELECT DISTINCT groupId, artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        }
+        else
+        {
+            buf.append( "SELECT artifactId FROM " ).append( ArchivaArtifactModel.class.getName() );
+        }
     }
 
     private void appendWhereSelectedGroupId( StringBuffer buf )

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ArtifactsByRepositoryConstraintTest.java Mon Oct  6 22:12:33 2008
@@ -37,20 +37,20 @@
 public class ArtifactsByRepositoryConstraintTest
     extends AbstractArchivaDatabaseTestCase
 {
-    private ArtifactDAO artifactDao;
+    private ArtifactDAO artifactDao; 
 
     public void setUp()
         throws Exception
     {
-        super.setUp();
+        super.setUp(); 
 
         ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" );
         artifactDao = dao.getArtifactDAO();
     }
 
-    private ArchivaArtifact createArtifact( String groupId, String artifactId, String version )
+    private ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
     {
-        ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, "jar" );
+        ArchivaArtifact artifact = artifactDao.createArtifact( groupId, artifactId, version, null, type );
         artifact.getModel().setLastModified( new Date() );
         artifact.getModel().setRepositoryId( "test-repo" );
 
@@ -63,19 +63,19 @@
         Date whenGathered = Calendar.getInstance().getTime();
         whenGathered.setTime( 123456789 );
 
-        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" );
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.0.2" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.0.2", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
         artifact.getModel().setRepositoryId( "different-repo" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
@@ -88,19 +88,19 @@
     {
         Date whenGathered = Calendar.getInstance().getTime();
 
-        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0" );
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
         artifact.getModel().setRepositoryId( "different-repo" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
@@ -108,18 +108,63 @@
         Date olderWhenGathered = Calendar.getInstance().getTime();
         olderWhenGathered.setTime( 123456789 );
         
-        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "jar" );
         artifact.getModel().setWhenGathered( olderWhenGathered );
         artifactDao.saveArtifact( artifact );
 
-        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1" );
+        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "jar" );
         artifact.getModel().setWhenGathered( whenGathered );
         artifactDao.saveArtifact( artifact );
 
         assertConstraint( "Artifacts By Repository and When Gathered", 4,
-                          new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId" ) );
+                          new ArtifactsByRepositoryConstraint( "test-repo", whenGathered, "repositoryId", false ) );
     }
+    
+    public void testQueryArtifactsInRepoByType()
+        throws Exception
+    {
+        Calendar cal = Calendar.getInstance();
+        cal.set( 2008, 9, 1 );
+        Date whenGathered = cal.getTime();
+
+        ArchivaArtifact artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.1", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "1.0.2", "jar" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+        
+        artifact = createArtifact( "org.apache.archiva", "artifact-two", "1.1-SNAPSHOT", "war" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
+
+        artifact = createArtifact( "org.apache.archiva", "artifact-three", "2.0-beta-1", "war" );
+        artifact.getModel().setWhenGathered( whenGathered );
+        artifactDao.saveArtifact( artifact );
 
+        Calendar cal2 = Calendar.getInstance();
+        cal2.set( 2008, 12, 12 );
+        Date diffWhenGathered = cal2.getTime();
+        
+        artifact = createArtifact( "org.apache.archiva", "artifact-one", "2.0", "jar" );
+        artifact.getModel().setWhenGathered( diffWhenGathered );
+        artifactDao.saveArtifact( artifact );
+        
+        cal2 = Calendar.getInstance();
+        cal2.set( 2008, 10, 30 );
+        Date before = cal2.getTime();
+        
+        assertConstraint( "Artifacts of Type 'jar' By Repository and When Gathered", 3,
+                          new ArtifactsByRepositoryConstraint( "test-repo", "jar", before, "whenGathered" ) );
+        assertConstraint( "Artifacts of Type 'war' By Repository and When Gathered", 2,
+                          new ArtifactsByRepositoryConstraint( "test-repo", "war", before, "whenGathered" ) );
+    }
+    
     private void assertConstraint( String msg, int count, ArtifactsByRepositoryConstraint constraint )
         throws Exception
     {

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryContentStatisticsByRepositoryConstraintTest.java Mon Oct  6 22:12:33 2008
@@ -32,7 +32,7 @@
  * @version
  */
 public class RepositoryContentStatisticsByRepositoryConstraintTest
-    extends AbstractArchivaDatabaseTestCase
+    extends AbstractArchivaDatabaseTestCase 
 {
     private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
                                                      long newfiles )
@@ -76,4 +76,27 @@
         assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 2 ) ).getRepositoryId() );
         assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 3 ) ).getRepositoryId() );
     }
+    
+    public void testStatsWithDateRange()
+        throws Exception
+    {
+        Constraint constraint =
+            new RepositoryContentStatisticsByRepositoryConstraint( "internal", toDate( "2007/10/18 8:00:00" ),
+                                                                   toDate( "2007/10/20 8:00:00" ) );
+        List results = dao.getRepositoryContentStatisticsDAO().queryRepositoryContentStatistics( constraint );
+        assertNotNull( "Stats: results (not null)", results );
+        assertEquals( "Stats: results.size", 3, results.size() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 0 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/20 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 0 ) ).getWhenGathered() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 1 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/19 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 1 ) ).getWhenGathered() );
+
+        assertEquals( "internal", ( (RepositoryContentStatistics) results.get( 2 ) ).getRepositoryId() );
+        assertEquals( toDate( "2007/10/18 8:00:00" ),
+                      ( (RepositoryContentStatistics) results.get( 2 ) ).getWhenGathered() );
+    }
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueArtifactIdConstraintTest.java Mon Oct  6 22:12:33 2008
@@ -22,6 +22,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
 import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.database.ArtifactDAO;
 import org.apache.maven.archiva.database.SimpleConstraint;
 import org.apache.maven.archiva.model.ArchivaArtifact;
@@ -62,9 +63,31 @@
     public void testConstraint()
         throws Exception
     {
-        ArchivaArtifact artifact;
+        setUpArtifacts();
 
-        // Setup artifacts in fresh DB.
+        assertConstraint( new String[] {}, new UniqueArtifactIdConstraint( "org.apache" ) );
+        assertConstraint( new String[] { "commons-lang" }, new UniqueArtifactIdConstraint( "commons-lang" ) );
+        assertConstraint( new String[] { "test-one" }, new UniqueArtifactIdConstraint( "org.apache.maven.test" ) );
+        assertConstraint( new String[] { "test-two", "test-bar" },
+                          new UniqueArtifactIdConstraint( "org.apache.maven.shared" ) );
+        assertConstraint( new String[] { "modellong" }, new UniqueArtifactIdConstraint( "org.codehaus.modello" ) );
+    }
+    
+    public void testConstraintDisregardGroupId()
+        throws Exception
+    {
+        setUpArtifacts();
+        
+        assertConstraintWithMultipleResultTypes( new String[] { "commons-lang", "test-one", "test-two", "test-two", "test-bar", "modellong" },
+                          new UniqueArtifactIdConstraint( "testable_repo", true ) );
+    }
+
+    private void setUpArtifacts()
+        throws ArchivaDatabaseException
+    {
+        ArchivaArtifact artifact;
+        
+     // Setup artifacts in fresh DB.
         artifact = createArtifact( "commons-lang", "commons-lang", "2.0" );
         artifactDao.saveArtifact( artifact );
 
@@ -88,26 +111,41 @@
 
         artifact = createArtifact( "org.codehaus.modello", "modellong", "3.0" );
         artifactDao.saveArtifact( artifact );
-
-        assertConstraint( new String[] {}, new UniqueArtifactIdConstraint( "org.apache" ) );
-        assertConstraint( new String[] { "commons-lang" }, new UniqueArtifactIdConstraint( "commons-lang" ) );
-        assertConstraint( new String[] { "test-one" }, new UniqueArtifactIdConstraint( "org.apache.maven.test" ) );
-        assertConstraint( new String[] { "test-two", "test-bar" },
-                          new UniqueArtifactIdConstraint( "org.apache.maven.shared" ) );
-        assertConstraint( new String[] { "modellong" }, new UniqueArtifactIdConstraint( "org.codehaus.modello" ) );
     }
-
+    
+    private void assertConstraintWithMultipleResultTypes( String[] artifactIds, SimpleConstraint constraint )
+        throws Exception
+    {
+        String prefix = "Unique Artifact IDs: ";
+    
+        List<Object[]> results = dao.query( constraint );
+        assertNotNull( prefix + "Not Null", results );
+        assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
+    
+        List<String> expectedArtifactIds = Arrays.asList( artifactIds );
+    
+        Iterator<Object[]> it = results.iterator();
+        while ( it.hasNext() )
+        {
+            Object[] actualArtifactIds = (Object[]) it.next();            
+            String actualArtifactId = ( String ) actualArtifactIds[1];
+            assertTrue( prefix + "artifactId result should not be blank.", StringUtils.isNotBlank( actualArtifactId ) );
+            assertTrue( prefix + " artifactId result <" + actualArtifactId + "> exists in expected artifactIds.",
+                        expectedArtifactIds.contains( actualArtifactId ) );            
+        }
+    }
+    
     private void assertConstraint( String[] artifactIds, SimpleConstraint constraint )
     {
         String prefix = "Unique Artifact IDs: ";
 
-        List results = dao.query( constraint );
+        List<String> results = dao.query( constraint );
         assertNotNull( prefix + "Not Null", results );
         assertEquals( prefix + "Results.size", artifactIds.length, results.size() );
 
-        List expectedArtifactIds = Arrays.asList( artifactIds );
+        List<String> expectedArtifactIds = Arrays.asList( artifactIds );
 
-        Iterator it = results.iterator();
+        Iterator<String> it = results.iterator();
         while ( it.hasNext() )
         {
             String actualArtifactId = (String) it.next();

Modified: archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueGroupIdConstraintTest.java Mon Oct  6 22:12:33 2008
@@ -230,8 +230,8 @@
 
         assertConstraint( new String[] { "org.codehaus.modello", "org.codehaus.mojo", "org.apache.archiva" },
                           new UniqueGroupIdConstraint( observableRepositories ) );
-    }
-
+    }   
+    
     private void assertConstraint( String[] expectedGroupIds, SimpleConstraint constraint )
         throws Exception
     {

Modified: archiva/branches/MRM-124/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-reporting/archiva-report-manager/pom.xml Mon Oct  6 22:12:33 2008
@@ -48,6 +48,11 @@
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-spring</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
   </build>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-scheduled/src/main/java/org/apache/maven/archiva/scheduled/executors/ArchivaRepositoryScanningTaskExecutor.java Mon Oct  6 22:12:33 2008
@@ -20,11 +20,17 @@
  */
 
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.database.ArchivaDAO;
+import org.apache.maven.archiva.database.ArchivaDatabaseException;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
+import org.apache.maven.archiva.database.constraints.ArtifactsByRepositoryConstraint;
 import org.apache.maven.archiva.database.constraints.MostRecentRepositoryScanStatistics;
+import org.apache.maven.archiva.database.constraints.UniqueArtifactIdConstraint;
+import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
 import org.apache.maven.archiva.model.RepositoryContentStatistics;
 import org.apache.maven.archiva.repository.RepositoryException;
 import org.apache.maven.archiva.repository.scanner.RepositoryScanStatistics;
@@ -38,6 +44,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -112,19 +120,59 @@
 
             log.info( "Finished repository task: " + stats.toDump( arepo ) );
             
-            // I hate jpox and modello
-            RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
-            dbstats.setDuration( stats.getDuration() );
-            dbstats.setNewFileCount( stats.getNewFileCount() );
-            dbstats.setRepositoryId( stats.getRepositoryId() );
-            dbstats.setTotalFileCount( stats.getTotalFileCount() );
-            dbstats.setWhenGathered( stats.getWhenGathered() );
+            RepositoryContentStatistics dbstats = constructRepositoryStatistics( arepo, sinceWhen, results, stats );
             
-            dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );
+            dao.getRepositoryContentStatisticsDAO().saveRepositoryContentStatistics( dbstats );            
         }
         catch ( RepositoryException e )
-        {
+        {   
             throw new TaskExecutionException( "Repository error when executing repository job.", e );
-        }        
+        }    
     }
+
+    private RepositoryContentStatistics constructRepositoryStatistics( ManagedRepositoryConfiguration arepo,
+                                                                       long sinceWhen,
+                                                                       List<RepositoryContentStatistics> results,
+                                                                       RepositoryScanStatistics stats )        
+    {
+        // I hate jpox and modello <-- and so do I
+        RepositoryContentStatistics dbstats = new RepositoryContentStatistics();
+        dbstats.setDuration( stats.getDuration() );
+        dbstats.setNewFileCount( stats.getNewFileCount() );
+        dbstats.setRepositoryId( stats.getRepositoryId() );
+        dbstats.setTotalFileCount( stats.getTotalFileCount() );
+        dbstats.setWhenGathered( stats.getWhenGathered() );
+                
+        // total artifact count
+        try
+        {
+            List artifacts = dao.getArtifactDAO().queryArtifacts( 
+                      new ArtifactsByRepositoryConstraint( arepo.getId(), stats.getWhenGathered(), "groupId", true ) );            
+            dbstats.setTotalArtifactCount( artifacts.size() );
+        }
+        catch ( ObjectNotFoundException oe )
+        {
+            log.error( "Object not found in the database : " + oe.getMessage() );
+        }
+        catch ( ArchivaDatabaseException ae )
+        {   
+            log.error( "Error occurred while querying artifacts for artifact count : " + ae.getMessage() );
+        }
+        
+        // total repo size
+        long size = FileUtils.sizeOfDirectory( new File( arepo.getLocation() ) );
+        dbstats.setTotalSize( size );
+          
+          // total unique groups
+        List<String> repos = new ArrayList<String>();
+        repos.add( arepo.getId() ); 
+        
+        List<String> groupIds = dao.query( new UniqueGroupIdConstraint( repos ) );
+        dbstats.setTotalGroupCount( groupIds.size() );
+                
+        List<Object[]> artifactIds = dao.query( new UniqueArtifactIdConstraint( arepo.getId(), true ) );
+        dbstats.setTotalProjectCount( artifactIds.size() );
+                        
+        return dbstats;
+    }    
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/pom.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/pom.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/pom.xml Mon Oct  6 22:12:33 2008
@@ -18,6 +18,7 @@
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-model</artifactId>
     </dependency>
+    <!-- TODO: replace with metadata processor -->
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-database</artifactId>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessor.java Mon Oct  6 22:12:33 2008
@@ -89,7 +89,7 @@
         Calendar greaterThanThisDate = Calendar.getInstance( DateUtils.UTC_TIME_ZONE );
         greaterThanThisDate.add( Calendar.DATE, -( getNumberOfDaysBeforeNow() ) );
         
-        Constraint artifactsByRepo = new ArtifactsByRepositoryConstraint( repoId, greaterThanThisDate.getTime(), "whenGathered" );
+        Constraint artifactsByRepo = new ArtifactsByRepositoryConstraint( repoId, greaterThanThisDate.getTime(), "whenGathered", false );
         List<ArchivaArtifact> artifacts = artifactDAO.queryArtifacts( artifactsByRepo );
 
         List<RssFeedEntry> entries = processData( artifacts, true );

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/pom.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/pom.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/pom.xml Mon Oct  6 22:12:33 2008
@@ -43,35 +43,35 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-system</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-rbac-model</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-rbac-role-manager</artifactId>
     </dependency>
     <!-- Test Scoped -->
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-authorization-rbac</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-keys-memory</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-users-memory</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-rbac-memory</artifactId>
       <scope>test</scope>
     </dependency>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaServletAuthenticator.java Mon Oct  6 22:12:33 2008
@@ -93,11 +93,18 @@
         return true;
     }
 
-    public boolean isAuthorizedToAccessVirtualRepository( String principal, String repoId )
+    public boolean isAuthorized( String principal, String repoId, boolean isWriteRequest )
         throws UnauthorizedException
     {
         try
         {
+            String permission = ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS;
+
+            if ( isWriteRequest )
+            {
+                permission = ArchivaRoleConstants.OPERATION_REPOSITORY_UPLOAD;
+            }
+            
             User user = securitySystem.getUserManager().findUser( principal );
             if ( user.isLocked() )
             {
@@ -107,8 +114,7 @@
             AuthenticationResult authn = new AuthenticationResult( true, principal, null );
             SecuritySession securitySession = new DefaultSecuritySession( authn, user );
 
-            return securitySystem.isAuthorized( securitySession, ArchivaRoleConstants.OPERATION_REPOSITORY_ACCESS,
-                                                repoId );
+            return securitySystem.isAuthorized( securitySession, permission, repoId );
         }
         catch ( UserNotFoundException e )
         {

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ArchivaXworkUser.java Mon Oct  6 22:12:33 2008
@@ -19,27 +19,38 @@
  * under the License.
  */
 
-import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
 import org.codehaus.plexus.redback.system.SecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySystemConstants;
 import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.registry.Registry;
 
 /**
  * ArchivaXworkUser 
  *
  * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
  * @version $Id$
+ * 
+ * @plexus.component role="org.apache.maven.archiva.security.ArchivaXworkUser"
  */
 public class ArchivaXworkUser
 {
-    public static String getActivePrincipal( Map<String, Object> sessionMap )
-    {
+    /**
+     * @plexus.requirement role-hint="commons-configuration"
+     */
+    private Registry registry;
+    
+    private static final String KEY = "org.codehaus.plexus.redback";
+    
+    private static String guest;
+            
+    public String getActivePrincipal( Map<String, Object> sessionMap )
+    {   
         if ( sessionMap == null )
         {
-            return ArchivaRoleConstants.PRINCIPAL_GUEST;
+            return getGuest();
         }
 
     	SecuritySession securitySession =
@@ -52,15 +63,31 @@
 
         if ( securitySession == null )
         {
-            return ArchivaRoleConstants.PRINCIPAL_GUEST;
+            return getGuest();
         }
 
         User user = securitySession.getUser();        
         if ( user == null )
         {
-            return ArchivaRoleConstants.PRINCIPAL_GUEST;
+            return getGuest();
         }
 
         return (String) user.getPrincipal();
+    }    
+   
+    public String getGuest()
+    {
+        if( guest == null || "".equals( guest ) )
+        {
+            Registry subset = registry.getSubset( KEY );
+            guest = subset.getString( "redback.default.guest", ArchivaRoleConstants.PRINCIPAL_GUEST );
+        }
+        
+        return guest;
+    }
+    
+    public void setGuest( String guesT )
+    {
+        guest = guesT;
     }
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/main/java/org/apache/maven/archiva/security/ServletAuthenticator.java Mon Oct  6 22:12:33 2008
@@ -35,12 +35,46 @@
  */
 public interface ServletAuthenticator
 {
+    /**
+     * Authentication check for users.
+     * 
+     * @param request
+     * @param result
+     * @return
+     * @throws AuthenticationException
+     * @throws AccountLockedException
+     * @throws MustChangePasswordException
+     */
     public boolean isAuthenticated( HttpServletRequest request, AuthenticationResult result )
         throws AuthenticationException, AccountLockedException, MustChangePasswordException;
 
+    /**
+     * Authorization check for valid users.
+     * 
+     * @param request
+     * @param securitySession
+     * @param repositoryId
+     * @param isWriteRequest
+     * @return
+     * @throws AuthorizationException
+     * @throws UnauthorizedException
+     */
     public boolean isAuthorized( HttpServletRequest request, SecuritySession securitySession, String repositoryId,
         boolean isWriteRequest ) throws AuthorizationException, UnauthorizedException;
     
-    public boolean isAuthorizedToAccessVirtualRepository( String principal, String repoId )
+    /**
+     * Authorization check specific for user guest, which doesn't go through 
+     * HttpBasicAuthentication#getAuthenticationResult( HttpServletRequest request, HttpServletResponse response )
+     * since no credentials are attached to the request. 
+     * 
+     * See also MRM-911
+     * 
+     * @param principal
+     * @param repoId
+     * @param isWriteRequest
+     * @return
+     * @throws UnauthorizedException
+     */
+    public boolean isAuthorized( String principal, String repoId, boolean isWriteRequest )
         throws UnauthorizedException;
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-security/src/test/java/org/apache/maven/archiva/security/DefaultUserRepositoriesTest.java Mon Oct  6 22:12:33 2008
@@ -19,19 +19,9 @@
  * under the License.
  */
 
-import java.io.File;
 import java.util.List;
 
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-import org.codehaus.plexus.redback.rbac.RBACManager;
-import org.codehaus.plexus.redback.role.RoleManager;
-import org.codehaus.plexus.redback.system.SecuritySystem;
-import org.codehaus.plexus.redback.users.User;
-import org.codehaus.plexus.redback.users.UserManager;
 
 /**
  * DefaultUserRepositoriesTest 
@@ -40,24 +30,14 @@
  * @version $Id$
  */
 public class DefaultUserRepositoriesTest
-    extends PlexusInSpringTestCase
-{
-    private static final String USER_GUEST = "guest";
-
-    private static final String USER_ADMIN = "admin";
-
-    private static final String USER_ALPACA = "alpaca";
-
-    private SecuritySystem securitySystem;
-
-    private RBACManager rbacManager;
-
-    private RoleManager roleManager;
-
-    private ArchivaConfiguration archivaConfiguration;
-
-    private UserRepositories userRepos;
-
+    extends AbstractSecurityTest
+{   
+    @Override
+    protected String getPlexusConfigLocation()
+    {
+        return "org/apache/maven/archiva/security/DefaultUserRepositoriesTest.xml";
+    }
+    
     public void testGetObservableRepositoryIds()
         throws Exception
     {
@@ -98,78 +78,9 @@
         }
     }
 
-    private void setupRepository( String repoId )
-        throws Exception
-    {
-        // Add repo to configuration.
-        ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
-        repoConfig.setId( repoId );
-        repoConfig.setName( "Testable repo <" + repoId + ">" );
-        repoConfig.setLocation( getTestPath( "target/test-repo/" + repoId ) );
-        archivaConfiguration.getConfiguration().addManagedRepository( repoConfig );
-
-        // Add repo roles to security.
-        userRepos.createMissingRepositoryRoles( repoId );
-    }
-
     private void assignGlobalRepositoryObserverRole( String principal )
         throws Exception
     {
         roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GLOBAL_REPOSITORY_OBSERVER, principal );
     }
-
-    private void assignRepositoryObserverRole( String principal, String repoId )
-        throws Exception
-    {
-        roleManager.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId, principal );
-    }
-
-    private User createUser( String principal, String fullname )
-    {
-        UserManager userManager = securitySystem.getUserManager();
-
-        User user = userManager.createUser( principal, fullname, principal + "@testable.archiva.apache.org" );
-        securitySystem.getPolicy().setEnabled( false );
-        userManager.addUser( user );
-        securitySystem.getPolicy().setEnabled( true );
-
-        return user;
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        File srcConfig = getTestFile( "src/test/resources/repository-archiva.xml" );
-        File destConfig = getTestFile( "target/test-conf/archiva.xml" );
-
-        destConfig.getParentFile().mkdirs();
-        destConfig.delete();
-
-        FileUtils.copyFile( srcConfig, destConfig );
-
-        securitySystem = (SecuritySystem) lookup( SecuritySystem.class, "testable" );
-        rbacManager = (RBACManager) lookup( RBACManager.class, "memory" );
-        roleManager = (RoleManager) lookup( RoleManager.class, "default" );
-        userRepos = (UserRepositories) lookup( UserRepositories.class, "default" );
-        archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
-
-        // Some basic asserts.
-        assertNotNull( securitySystem );
-        assertNotNull( rbacManager );
-        assertNotNull( roleManager );
-        assertNotNull( userRepos );
-        assertNotNull( archivaConfiguration );
-
-        // Setup Admin User.
-        User adminUser = createUser( USER_ADMIN, "Admin User" );
-        roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN, adminUser.getPrincipal().toString() );
-
-        // Setup Guest User.
-        User guestUser = createUser( USER_GUEST, "Guest User" );
-        roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, guestUser.getPrincipal().toString() );
-
-    }
 }

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/pom.xml
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/pom.xml?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/pom.xml (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/pom.xml Mon Oct  6 22:12:33 2008
@@ -85,14 +85,6 @@
       <artifactId>archiva-rss</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>archiva-xmlrpc-services</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>archiva-xmlrpc-security</artifactId>
-    </dependency>
-    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
       <scope>provided</scope>
@@ -153,17 +145,17 @@
     </dependency>
     <!-- Plexus Security Dependencies -->
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-xwork-content</artifactId>
       <type>war</type>
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-xwork-integration</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus.redback</groupId>
+      <groupId>org.codehaus.redback</groupId>
       <artifactId>redback-taglib</artifactId>
     </dependency>
     <!-- Other dependencies -->
@@ -180,11 +172,6 @@
       <artifactId>spring-web</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.derby</groupId>
-      <artifactId>derby</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
       <groupId>javax.mail</groupId>
       <artifactId>mail</artifactId>
       <scope>provided</scope>
@@ -229,11 +216,6 @@
       <artifactId>commons-logging-api</artifactId>
       <version>1.1</version>
     </dependency>
-    <dependency>
-      <groupId>com.atlassian.xmlrpc</groupId>
-      <artifactId>atlassian-xmlrpc-binder-server-spring</artifactId>
-      <scope>runtime</scope>
-    </dependency>
   </dependencies>
   <build>
     <resources>

Modified: archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java?rev=702347&r1=702346&r2=702347&view=diff
==============================================================================
--- archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java (original)
+++ archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java Mon Oct  6 22:12:33 2008
@@ -52,6 +52,11 @@
      */
     private UserRepositories userRepositories;
     
+    /**
+     * @plexus.requirement
+     */
+    private ArchivaXworkUser archivaXworkUser;
+    
     private BrowsingResults results;
 
     private String groupId;
@@ -121,7 +126,7 @@
     
     private String getPrincipal()
     {
-        return ArchivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
+        return archivaXworkUser.getActivePrincipal( ActionContext.getContext().getSession() );
     }
     
     private List<String> getObservableRepos()



Mime
View raw message