]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1301] add back summary statistics for various counts
authorBrett Porter <brett@apache.org>
Wed, 16 Dec 2009 02:25:42 +0000 (02:25 +0000)
committerBrett Porter <brett@apache.org>
Wed, 16 Dec 2009 02:25:42 +0000 (02:25 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@891102 13f79535-47bb-0310-9956-ffa450edef68

24 files changed:
archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java
archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorTest.java
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestRepositoryStatisticsManager.java
archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/NewVersionsOfArtifactRssFeedProcessor.java
archiva-modules/archiva-web/archiva-rss/src/main/java/org/apache/archiva/rss/processor/RssFeedProcessor.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/rss/RssFeedServlet.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/BrowseActionTest.java
archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java
archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolverException.java [deleted file]
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java
archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatistics.java
archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManager.java
archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java

index 3275405d44a933241704d22b5389b88175e78d84..1d2ba0064517bce4b5917b565ed7eac3dd429bd4 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver;
 import org.apache.maven.archiva.common.utils.VersionUtil;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@@ -163,17 +162,9 @@ public class ArchivaMetadataCreationConsumer
 
         String projectVersion = VersionUtil.getBaseVersion( artifact.getVersion() );
         // TODO: maybe not too efficient since it may have already been read and stored for this artifact
-        ProjectVersionMetadata versionMetadata;
-        try
-        {
-            versionMetadata =
-                storageResolver.getProjectVersion( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(),
-                                                   projectVersion );
-        }
-        catch ( MetadataResolverException e )
-        {
-            throw new ConsumerException( e.getMessage(), e );
-        }
+        ProjectVersionMetadata versionMetadata =
+            storageResolver.getProjectVersion( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(),
+                                               projectVersion );
 
         if ( versionMetadata == null )
         {
index c424881051828bef121782ac873ca2e2319b0ac9..021a6a030b35934334c02b4aa491fd3496ae3683 100644 (file)
@@ -40,7 +40,6 @@ public class TestMetadataRepository
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -73,7 +72,6 @@ public class TestMetadataRepository
     }
 
     public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
index 7f0c65515afc7d3b9158cdd1b210e7285975f471..3cfa5786c09a9a676c74b49feb920b10b8c9c9ad 100644 (file)
@@ -142,14 +142,11 @@ public class ArchivaRepositoryScanningTaskExecutor
 
                 log.info( "Finished first scan: " + stats.toDump( arepo ) );
 
-                RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
-                repositoryStatistics.setScanStartTime( stats.getWhenGathered() );
-                repositoryStatistics.setScanEndTime(
-                    new Date( stats.getWhenGathered().getTime() + stats.getDuration() ) );
-                repositoryStatistics.setTotalFileCount( stats.getTotalFileCount() );
-                repositoryStatistics.setNewFileCount( stats.getTotalFileCount() - previousFileCount );
                 // further statistics will be populated by the following method
-                repositoryStatisticsManager.addStatisticsAfterScan( repoId, repositoryStatistics );
+                Date endTime = new Date( stats.getWhenGathered().getTime() + stats.getDuration() );
+                repositoryStatisticsManager.addStatisticsAfterScan( repoId, stats.getWhenGathered(), endTime,
+                                                                    stats.getTotalFileCount(),
+                                                                    stats.getTotalFileCount() - previousFileCount );
 
 //                log.info( "Scanning for removed repository content" );
 
index 419b9418e18b6d4bde25cabac809bc797eefe982..1df470dc9ebbb643a92e5468fa8da4d13e3d58b4 100644 (file)
@@ -282,17 +282,8 @@ public class ArchivaRepositoryScanningTaskExecutorTest
         repoTask.setScanAll( true );
 
         Date date = Calendar.getInstance().getTime();
-        RepositoryStatistics stats = new RepositoryStatistics();
-        stats.setScanStartTime( new Date( date.getTime() - 1234567 ) );
-        stats.setScanEndTime( date );
-        stats.setNewFileCount( 8 );
-        stats.setTotalArtifactCount( 8 );
-        stats.setTotalFileCount( 8 );
-        stats.setTotalGroupCount( 3 );
-        stats.setTotalProjectCount( 5 );
-        stats.setTotalArtifactFileSize( 999999 );
-
-        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, new Date( date.getTime() - 1234567 ), date, 8,
+                                                            8 );
 
         taskExecutor.executeTask( repoTask );
 
@@ -315,6 +306,7 @@ public class ArchivaRepositoryScanningTaskExecutorTest
         stats.setTotalProjectCount( 5 );
         stats.setTotalArtifactFileSize( 38545 );
 
-        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, new Date( date.getTime() - 1234567 ), date,
+                                                            31, 31 );
     }
 }
index 2129bc45f10aeecb34a37b8b5ba8abad1a2443dd..155f927d533371e2a0951286bbae3c55b112b717 100644 (file)
@@ -41,9 +41,17 @@ public class TestRepositoryStatisticsManager
             : null;
     }
 
-    public void addStatisticsAfterScan( String repositoryId, RepositoryStatistics repositoryStatistics )
+    public void addStatisticsAfterScan( String repositoryId, Date startTime, Date endTime, long totalFiles,
+                                        long newFiles )
     {
         List<RepositoryStatistics> stats = getStatsList( repositoryId );
+
+        RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
+        repositoryStatistics.setScanStartTime( startTime );
+        repositoryStatistics.setScanEndTime( endTime );
+        repositoryStatistics.setNewFileCount( newFiles );
+        repositoryStatistics.setTotalFileCount( totalFiles );
+
         stats.add( repositoryStatistics );
     }
 
index a1a80ed54025b304e443177eeedfc5de648fa554..53cf9f4cf9d4e7be1d16f4a55582809aed54678a 100644 (file)
@@ -27,7 +27,6 @@ import java.util.Map;
 
 import com.sun.syndication.feed.synd.SyndFeed;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.rss.RssFeedEntry;
 import org.apache.archiva.rss.RssFeedGenerator;
 
@@ -54,7 +53,6 @@ public class NewVersionsOfArtifactRssFeedProcessor
      * Process all versions of the artifact which had a rss feed request.
      */
     public SyndFeed process( Map<String, String> reqParams )
-        throws MetadataResolverException
     {
         String groupId = reqParams.get( RssFeedProcessor.KEY_GROUP_ID );
         String artifactId = reqParams.get( RssFeedProcessor.KEY_ARTIFACT_ID );
@@ -68,7 +66,6 @@ public class NewVersionsOfArtifactRssFeedProcessor
     }
 
     private SyndFeed processNewVersionsOfArtifact( String groupId, String artifactId )
-        throws MetadataResolverException
     {
         List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
         for ( String repoId : metadataRepository.getRepositories() )
index 7d4723e31c73e736c8335989be2743ec1aa7790d..face4bd5720ac6ac6b9a4f0833d6234152e7e88b 100644 (file)
@@ -22,7 +22,6 @@ package org.apache.archiva.rss.processor;
 import java.util.Map;
 
 import com.sun.syndication.feed.synd.SyndFeed;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 
 /**
  * Retrieve and process the data that will be fed into the RssFeedGenerator.
@@ -35,6 +34,5 @@ public interface RssFeedProcessor
 
     public static final String KEY_ARTIFACT_ID = "artifactId";
 
-    SyndFeed process( Map<String, String> reqParams )
-        throws MetadataResolverException;
+    SyndFeed process( Map<String, String> reqParams );
 }
index 738bc9747985da4c7a860e931532bd4b4bd08afd..86877a06c8106819c9d2f69b10242886521b6270 100644 (file)
@@ -28,7 +28,6 @@ import java.util.Set;
 
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
@@ -153,7 +152,6 @@ public class BrowseAction
     }
 
     public String browseArtifact()
-        throws MetadataResolverException
     {
         if ( StringUtils.isEmpty( groupId ) )
         {
@@ -190,7 +188,6 @@ public class BrowseAction
     }
 
     private void populateSharedModel( Collection<String> selectedRepos, Collection<String> projectVersions )
-        throws MetadataResolverException
     {
         sharedModel = new ProjectVersionMetadata();
 
index c41326b12a7b73a94b76f029b754e09dbd58ff0e..94f33f1dcbd531cd76db2800fb8da0a3575543db 100644 (file)
@@ -28,7 +28,6 @@ import org.apache.archiva.metadata.model.MailingList;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionReference;
 import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.commons.lang.StringUtils;
 
 /**
@@ -96,15 +95,7 @@ public class ShowArtifactAction
 
                 // we don't want the implementation being that intelligent - so another resolver to do the
                 // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
-                try
-                {
-                    versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
-                }
-                catch ( MetadataResolverException e )
-                {
-                    addActionError( "Error occurred resolving metadata for project: " + e.getMessage() );
-                    return ERROR;
-                }
+                versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
                 if ( versionMetadata != null )
                 {
                     repositoryId = repoId;
@@ -136,15 +127,7 @@ public class ShowArtifactAction
         {
             if ( versionMetadata == null )
             {
-                try
-                {
-                    versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
-                }
-                catch ( MetadataResolverException e )
-                {
-                    addActionError( "Error occurred resolving metadata for project: " + e.getMessage() );
-                    return ERROR;
-                }
+                versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
             }
         }
 
@@ -170,15 +153,7 @@ public class ShowArtifactAction
         {
             if ( versionMetadata == null )
             {
-                try
-                {
-                    versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
-                }
-                catch ( MetadataResolverException e )
-                {
-                    addActionError( "Error occurred resolving metadata for project: " + e.getMessage() );
-                    return ERROR;
-                }
+                versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
             }
         }
 
@@ -214,15 +189,7 @@ public class ShowArtifactAction
         {
             if ( versionMetadata == null )
             {
-                try
-                {
-                    versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
-                }
-                catch ( MetadataResolverException e )
-                {
-                    addActionError( "Error occurred resolving metadata for project: " + e.getMessage() );
-                    return ERROR;
-                }
+                versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version );
             }
         }
 
index 8135fbce36d9a2d5bddd41c744ac8c7ed7ecdbd4..093abb7d6dbfdfa88b2d026d1e61d4000687a50c 100644 (file)
@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletResponse;
 import com.sun.syndication.feed.synd.SyndFeed;
 import com.sun.syndication.io.FeedException;
 import com.sun.syndication.io.SyndFeedOutput;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.rss.processor.RssFeedProcessor;
 import org.apache.commons.codec.Decoder;
 import org.apache.commons.codec.DecoderException;
@@ -218,11 +217,6 @@ public class RssFeedServlet
             
             res.sendError( HttpServletResponse.SC_UNAUTHORIZED, USER_NOT_AUTHORIZED );
         }
-        catch ( MetadataResolverException e )
-        {
-            log.debug( COULD_NOT_GENERATE_FEED_ERROR, e );
-            res.sendError( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, COULD_NOT_GENERATE_FEED_ERROR );
-        }
     }
 
     /**
index 45d9106e6bec883ddad6facd72cf78dd29a67581..b883a4338768af4c7f3af518a4410f0b3960c5cd 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionReference;
 import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 
 public class TestMetadataRepository
     implements MetadataRepository
@@ -80,7 +79,6 @@ public class TestMetadataRepository
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         throw new UnsupportedOperationException();
     }
@@ -113,7 +111,6 @@ public class TestMetadataRepository
     }
 
     public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException
     {
         return versions;
     }
index d4d8e325702664442efea9daa2a00782f0425e3a..a2cdb6fd079fdb35bb39ad3313e724a1ab35463a 100644 (file)
@@ -25,7 +25,6 @@ import java.util.List;
 
 import com.opensymphony.xwork2.Action;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.memory.TestMetadataResolver;
 
 public class BrowseActionTest
@@ -90,7 +89,6 @@ public class BrowseActionTest
     }
 
     public void testBrowseArtifactNoObservableRepos()
-        throws MetadataResolverException
     {
         setObservableRepos( Collections.<String>emptyList() );
         String selectedGroupId = "org.apache";
@@ -205,7 +203,6 @@ public class BrowseActionTest
     }
 
     public void testBrowseArtifactNoGroupId()
-        throws MetadataResolverException
     {
         String selectedArtifactId = "apache";
 
@@ -223,7 +220,6 @@ public class BrowseActionTest
     }
 
     public void testBrowseArtifactNoArtifactId()
-        throws MetadataResolverException
     {
         String selectedGroupId = "org.apache";
 
@@ -241,7 +237,6 @@ public class BrowseActionTest
     }
 
     public void testBrowseArtifact()
-        throws MetadataResolverException
     {
         String selectedGroupId = "org.apache";
         String selectedArtifactId = "apache";
@@ -274,7 +269,6 @@ public class BrowseActionTest
     }
 
     public void testBrowseArtifactWithSnapshots()
-        throws MetadataResolverException
     {
         String selectedGroupId = "org.apache";
         String selectedArtifactId = "apache";
index c424881051828bef121782ac873ca2e2319b0ac9..021a6a030b35934334c02b4aa491fd3496ae3683 100644 (file)
@@ -40,7 +40,6 @@ public class TestMetadataRepository
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -73,7 +72,6 @@ public class TestMetadataRepository
     }
 
     public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
index aa762a2abdf76babc9dbe5fb43077fd274d02998..bef60346644672cf06afe9eae02f5682d9b3656a 100644 (file)
@@ -58,7 +58,6 @@ public class DefaultMetadataResolver
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             metadataRepository.getProjectVersion( repoId, namespace, projectId, projectVersion );
@@ -166,7 +165,6 @@ public class DefaultMetadataResolver
     }
 
     public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException
     {
         Collection<String> projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId );
         Collection<String> storageProjectVersions = storageResolver.getProjectVersions( repoId, namespace, projectId,
index d677a70f14b343662db33492cfb8ba54828e5185..c6ca461af53eece54a877dfe3b8cd3730d0b61aa 100644 (file)
@@ -30,8 +30,8 @@ public interface MetadataResolver
 {
     ProjectMetadata getProject( String repoId, String namespace, String projectId );
 
-    ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
-        throws MetadataResolverException;
+    ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
+                                              String projectVersion );
 
     Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion );
 
@@ -55,9 +55,8 @@ public interface MetadataResolver
 
     Collection<String> getProjects( String repoId, String namespace );
 
-    Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException;
+    Collection<String> getProjectVersions( String repoId, String namespace, String projectId );
 
     Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
-                                                      String projectVersion );
+                                               String projectVersion );
 }
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolverException.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolverException.java
deleted file mode 100644 (file)
index c62a257..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.archiva.metadata.repository;
-
-/*
- * 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.
- */
-
-public class MetadataResolverException
-    extends Exception
-{
-    public MetadataResolverException( String message, Exception cause )
-    {
-        super( message, cause );
-    }
-}
index 706349fe425d04a5ef7d62281cf8f899a93b4a1a..ab6cc04b5bb8aaeda78e93e8caccf2ee37bf544d 100644 (file)
@@ -30,7 +30,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
 import org.apache.archiva.metadata.repository.storage.maven2.RepositoryModelResolver;
 import org.apache.commons.lang.StringUtils;
@@ -421,25 +420,18 @@ public class DefaultDependencyTreeBuilder
                                                List remoteRepositories )
             throws ArtifactMetadataRetrievalException
         {
-            try
+            Set<ArtifactVersion> versions = new HashSet<ArtifactVersion>();
+            for ( String repoId : repositoryIds )
             {
-                Set<ArtifactVersion> versions = new HashSet<ArtifactVersion>();
-                for ( String repoId : repositoryIds )
+                Collection<String> projectVersions =
+                    metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), artifact.getArtifactId() );
+                for ( String version : projectVersions )
                 {
-                    Collection<String> projectVersions =
-                        metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), artifact.getArtifactId() );
-                    for ( String version : projectVersions )
-                    {
-                        versions.add( new DefaultArtifactVersion( version ) );
-                    }
+                    versions.add( new DefaultArtifactVersion( version ) );
                 }
-
-                return new ArrayList<ArtifactVersion>( versions );
-            }
-            catch ( MetadataResolverException e )
-            {
-                throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
             }
+
+            return new ArrayList<ArtifactVersion>( versions );
         }
     }
 }
index 2a90d7b7ca68303d8273ae9b9217f310d45fe4fb..05290b5aee3115c39c931145d6073c3fec2dbc0a 100644 (file)
@@ -36,7 +36,6 @@ import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionReference;
 import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.filter.AllFilter;
 import org.apache.archiva.metadata.repository.filter.Filter;
 import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
@@ -101,7 +100,6 @@ public class Maven2RepositoryMetadataResolver
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         ManagedRepositoryConfiguration repositoryConfiguration =
             archivaConfiguration.getConfiguration().findManagedRepositoryById( repoId );
index 43aefdd8bcde5f0097c93bdeb6128e4c292a8e35..bb26ecba6afbe67aa32cb08007ccc0f967413b61 100644 (file)
@@ -36,7 +36,6 @@ public class TestMetadataResolver
 
     public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
                                                      String projectVersion )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
@@ -69,7 +68,6 @@ public class TestMetadataResolver
     }
 
     public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
-        throws MetadataResolverException
     {
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
index 531b59fd52195616b1e75f6abc247dc7d9206f89..d9aca1fc4407bb8ef7c4d3ec5af06b709f5f550f 100644 (file)
@@ -31,7 +31,6 @@ import org.apache.archiva.metadata.model.License;
 import org.apache.archiva.metadata.model.MailingList;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.archiva.metadata.repository.MetadataResolverException;
 import org.apache.archiva.metadata.repository.filter.ExcludesFilter;
 import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver;
 import org.apache.archiva.reports.RepositoryProblemFacet;
@@ -78,7 +77,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadata()
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", "archiva-common", "1.2.1" );
@@ -149,7 +147,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForTimestampedSnapshot()
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", "5-SNAPSHOT" );
@@ -186,7 +183,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata()
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT" );
@@ -194,7 +190,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata()
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata", "1.0-SNAPSHOT" );
@@ -202,7 +197,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata()
-        throws MetadataResolverException
     {
         ProjectVersionMetadata metadata =
             resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata", "1.0-SNAPSHOT" );
@@ -210,7 +204,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForInvalidPom()
-        throws MetadataResolverException
     {
         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
 
@@ -226,7 +219,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForMislocatedPom()
-        throws MetadataResolverException
     {
         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
 
@@ -242,7 +234,6 @@ public class Maven2RepositoryMetadataResolverTest
     }
 
     public void testGetProjectVersionMetadataForMissingPom()
-        throws MetadataResolverException
     {
         assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
 
index 5d877951ae9008ca68726e044407a53de3f6aac5..506f593d934603c8c2daafcba5a60102366f344b 100644 (file)
@@ -21,10 +21,12 @@ package org.apache.archiva.metadata.repository.stats;
 
 import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
+import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -59,23 +61,60 @@ public class DefaultRepositoryStatisticsManager
         }
     }
 
-    public void addStatisticsAfterScan( String repositoryId, RepositoryStatistics repositoryStatistics )
+    private void walkRepository( RepositoryStatistics stats, String repositoryId, String ns )
     {
+        for ( String namespace : metadataRepository.getNamespaces( repositoryId, ns ) )
+        {
+            walkRepository( stats, repositoryId, ns + "." + namespace );
+        }
+
+        Collection<String> projects = metadataRepository.getProjects( repositoryId, ns );
+        if ( !projects.isEmpty() )
+        {
+            stats.setTotalGroupCount( stats.getTotalGroupCount() + 1 );
+            stats.setTotalProjectCount( stats.getTotalProjectCount() + projects.size() );
+
+            for ( String project : projects )
+            {
+                for ( String version : metadataRepository.getProjectVersions( repositoryId, ns, project ) )
+                {
+                    for ( ArtifactMetadata artifact : metadataRepository.getArtifacts( repositoryId, ns, project,
+                                                                                       version ) )
+                    {
+                        stats.setTotalArtifactCount( stats.getTotalArtifactCount() + 1 );
+                        stats.setTotalArtifactFileSize( stats.getTotalArtifactFileSize() + artifact.getSize() );
+
+                        // TODO: add by type
+                    }
+                }
+            }
+        }
+    }
+
+
+    public void addStatisticsAfterScan( String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles )
+    {
+        RepositoryStatistics repositoryStatistics = new RepositoryStatistics();
+        repositoryStatistics.setScanStartTime( startTime );
+        repositoryStatistics.setScanEndTime( endTime );
+        repositoryStatistics.setTotalFileCount( totalFiles );
+        repositoryStatistics.setNewFileCount( newFiles );
+
         // In the future, instead of being tied to a scan we might want to record information in the fly based on
         // events that are occurring. Even without these totals we could query much of the information on demand based
         // on information from the metadata content repository. In the mean time, we lock information in at scan time.
         // Note that if new types are later discoverable due to a code change or new plugin, historical stats will not
         // be updated and the repository will need to be rescanned.
 
-        // TODO, populate these and also a count per artifact type
-        // populate total artifact count from content repository
-//        repositoryStatistics.setTotalArtifactCount(  );
-        // populate total size from content repository
-//        repositoryStatistics.setTotalArtifactFileSize(  );
-        // populate total group count from content repository
-//        repositoryStatistics.setTotalGroupCount(  );
-        // populate total project count from content repository
-//        repositoryStatistics.setTotalProjectCount(  );
+        long startWalk = System.currentTimeMillis();
+        // TODO: we can probably get a more efficient implementation directly from the metadata repository, but for now
+        //       we just walk it. Alternatively, we could build an index, or store the aggregate information and update
+        //       it on the fly
+        for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) )
+        {
+            walkRepository( repositoryStatistics, repositoryId, ns );
+        }
+        log.info( "Repository walk for statistics executed in " + ( System.currentTimeMillis() - startWalk ) + "ms" );
 
         metadataRepository.addMetadataFacet( repositoryId, repositoryStatistics );
     }
index 272d524ddf2c9a520e0666ef1bffad029dca82e4..6b8020054ed038d475eadd2274bccfa414c9f2c2 100644 (file)
@@ -170,4 +170,77 @@ public class RepositoryStatistics
         totalProjectCount = Long.valueOf( properties.get( "totalProjectCount" ) );
         newFileCount = Long.valueOf( properties.get( "newFileCount" ) );
     }
+
+    @Override
+    public String toString()
+    {
+        return "RepositoryStatistics{" + "scanEndTime=" + scanEndTime + ", scanStartTime=" + scanStartTime +
+            ", totalArtifactCount=" + totalArtifactCount + ", totalArtifactFileSize=" + totalArtifactFileSize +
+            ", totalFileCount=" + totalFileCount + ", totalGroupCount=" + totalGroupCount + ", totalProjectCount=" +
+            totalProjectCount + ", newFileCount=" + newFileCount + '}';
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() )
+        {
+            return false;
+        }
+
+        RepositoryStatistics that = (RepositoryStatistics) o;
+
+        if ( newFileCount != that.newFileCount )
+        {
+            return false;
+        }
+        if ( totalArtifactCount != that.totalArtifactCount )
+        {
+            return false;
+        }
+        if ( totalArtifactFileSize != that.totalArtifactFileSize )
+        {
+            return false;
+        }
+        if ( totalFileCount != that.totalFileCount )
+        {
+            return false;
+        }
+        if ( totalGroupCount != that.totalGroupCount )
+        {
+            return false;
+        }
+        if ( totalProjectCount != that.totalProjectCount )
+        {
+            return false;
+        }
+        if ( !scanEndTime.equals( that.scanEndTime ) )
+        {
+            return false;
+        }
+        if ( !scanStartTime.equals( that.scanStartTime ) )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int result = scanEndTime.hashCode();
+        result = 31 * result + scanStartTime.hashCode();
+        result = 31 * result + (int) ( totalArtifactCount ^ ( totalArtifactCount >>> 32 ) );
+        result = 31 * result + (int) ( totalArtifactFileSize ^ ( totalArtifactFileSize >>> 32 ) );
+        result = 31 * result + (int) ( totalFileCount ^ ( totalFileCount >>> 32 ) );
+        result = 31 * result + (int) ( totalGroupCount ^ ( totalGroupCount >>> 32 ) );
+        result = 31 * result + (int) ( totalProjectCount ^ ( totalProjectCount >>> 32 ) );
+        result = 31 * result + (int) ( newFileCount ^ ( newFileCount >>> 32 ) );
+        return result;
+    }
 }
index f5388a4b59f752f43b0d6f6d7b6abe87f781a1f6..6abc4434862423a409c29689a8144b6f08b07531 100644 (file)
@@ -26,7 +26,7 @@ public interface RepositoryStatisticsManager
 {
     RepositoryStatistics getLastStatistics( String repositoryId );
 
-    void addStatisticsAfterScan( String repositoryId, RepositoryStatistics repositoryStatistics );
+    void addStatisticsAfterScan( String repositoryId, Date startTime, Date endTime, long totalFiles, long newFiles );
 
     void deleteStatistics( String repositoryId );
 
index f806291c8d8267c601e9e67647bab0e71e9560e5..289a338208b555bc65d48727924403bb2d4ecb66 100644 (file)
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Map;
 
 import junit.framework.TestCase;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.easymock.MockControl;
 
@@ -120,6 +121,8 @@ public class RepositoryStatisticsManagerTest
 
         RepositoryStatistics stats = createTestStats( startTime, current );
 
+        walkRepository( 1 );
+
         metadataRepository.addMetadataFacet( TEST_REPO_ID, stats );
         metadataRepositoryControl.expectAndReturn(
             metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryStatistics.FACET_ID ),
@@ -130,15 +133,15 @@ public class RepositoryStatisticsManagerTest
 
         metadataRepositoryControl.replay();
 
-        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime, current, 56345, 45 );
 
         stats = repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID );
         assertNotNull( stats );
-        assertEquals( 1400032000L, stats.getTotalArtifactFileSize() );
+        assertEquals( 246900, stats.getTotalArtifactFileSize() );
         assertEquals( 45, stats.getNewFileCount() );
-        assertEquals( 10412, stats.getTotalArtifactCount() );
-        assertEquals( 2036, stats.getTotalProjectCount() );
-        assertEquals( 531, stats.getTotalGroupCount() );
+        assertEquals( 20, stats.getTotalArtifactCount() );
+        assertEquals( 5, stats.getTotalProjectCount() );
+        assertEquals( 4, stats.getTotalGroupCount() );
         assertEquals( 56345, stats.getTotalFileCount() );
         assertEquals( current.getTime() - 12345, stats.getScanStartTime().getTime() );
         assertEquals( current, stats.getScanEndTime() );
@@ -148,6 +151,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testDeleteStats()
     {
+        walkRepository( 2 );
+
         Date current = new Date();
 
         Date startTime1 = new Date( current.getTime() - 12345 );
@@ -173,8 +178,10 @@ public class RepositoryStatisticsManagerTest
 
         metadataRepositoryControl.replay();
 
-        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats1 );
-        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats2 );
+        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime1, stats1.getScanEndTime(), 56345,
+                                                            45 );
+        repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, startTime2, stats2.getScanEndTime(), 56345,
+                                                            45 );
 
         assertNotNull( repositoryStatisticsManager.getLastStatistics( TEST_REPO_ID ) );
 
@@ -205,6 +212,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testGetStatsRangeInside()
     {
+        walkRepository( 3 );
+
         Date current = new Date();
 
         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
@@ -225,7 +234,8 @@ public class RepositoryStatisticsManagerTest
 
         for ( RepositoryStatistics stats : statsCreated.values() )
         {
-            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats.getScanStartTime(),
+                                                                stats.getScanEndTime(), 56345, 45 );
         }
 
         List<RepositoryStatistics> list =
@@ -240,6 +250,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testGetStatsRangeUpperOutside()
     {
+        walkRepository( 3 );
+
         Date current = new Date();
 
         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
@@ -263,7 +275,8 @@ public class RepositoryStatisticsManagerTest
 
         for ( RepositoryStatistics stats : statsCreated.values() )
         {
-            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats.getScanStartTime(),
+                                                                stats.getScanEndTime(), 56345, 45 );
         }
 
         List<RepositoryStatistics> list =
@@ -279,6 +292,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testGetStatsRangeLowerOutside()
     {
+        walkRepository( 3 );
+
         Date current = new Date();
 
         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
@@ -302,7 +317,8 @@ public class RepositoryStatisticsManagerTest
 
         for ( RepositoryStatistics stats : statsCreated.values() )
         {
-            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats.getScanStartTime(),
+                                                                stats.getScanEndTime(), 56345, 45 );
         }
 
         List<RepositoryStatistics> list =
@@ -318,6 +334,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testGetStatsRangeLowerAndUpperOutside()
     {
+        walkRepository( 3 );
+
         Date current = new Date();
 
         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
@@ -345,7 +363,8 @@ public class RepositoryStatisticsManagerTest
 
         for ( RepositoryStatistics stats : statsCreated.values() )
         {
-            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats.getScanStartTime(),
+                                                                stats.getScanEndTime(), 56345, 45 );
         }
 
         List<RepositoryStatistics> list =
@@ -362,6 +381,8 @@ public class RepositoryStatisticsManagerTest
 
     public void testGetStatsRangeNotInside()
     {
+        walkRepository( 3 );
+
         Date current = new Date();
 
         addStats( new Date( current.getTime() - 12345 ), new Date( current.getTime() - 6000 ) );
@@ -376,7 +397,8 @@ public class RepositoryStatisticsManagerTest
 
         for ( RepositoryStatistics stats : statsCreated.values() )
         {
-            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats );
+            repositoryStatisticsManager.addStatisticsAfterScan( TEST_REPO_ID, stats.getScanStartTime(),
+                                                                stats.getScanEndTime(), 56345, 45 );
         }
 
         List<RepositoryStatistics> list =
@@ -395,17 +417,130 @@ public class RepositoryStatisticsManagerTest
         statsCreated.put( stats.getName(), stats );
     }
 
+    private ArtifactMetadata createArtifact( String namespace, String projectId, String projectVersion, String type )
+    {
+        ArtifactMetadata metadata = new ArtifactMetadata();
+        metadata.setRepositoryId( TEST_REPO_ID );
+        metadata.setId( projectId + "-" + projectVersion + "." + type );
+        metadata.setProject( projectId );
+        metadata.setSize( 12345L );
+        metadata.setVersion( projectVersion );
+        metadata.setNamespace( namespace );
+        return metadata;
+    }
+
     private RepositoryStatistics createTestStats( Date startTime, Date endTime )
     {
         RepositoryStatistics stats = new RepositoryStatistics();
         stats.setScanStartTime( startTime );
         stats.setScanEndTime( endTime );
-        stats.setTotalArtifactFileSize( 1400032000L );
+        stats.setTotalArtifactFileSize( 20 * 12345L );
         stats.setNewFileCount( 45 );
-        stats.setTotalArtifactCount( 10412 );
-        stats.setTotalProjectCount( 2036 );
-        stats.setTotalGroupCount( 531 );
+        stats.setTotalArtifactCount( 20 );
+        stats.setTotalProjectCount( 5 );
+        stats.setTotalGroupCount( 4 );
         stats.setTotalFileCount( 56345 );
         return stats;
     }
+
+    private void walkRepository( int count )
+    {
+        for ( int i = 0; i < count; i++ )
+        {
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getRootNamespaces( TEST_REPO_ID ),
+                                                       Arrays.asList( "com", "org" ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com" ),
+                                                       Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com" ),
+                                                       Arrays.asList( "example" ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "com.example" ),
+                                                       Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "com.example" ),
+                                                       Arrays.asList( "example-project" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjectVersions( TEST_REPO_ID, "com.example", "example-project" ),
+                Arrays.asList( "1.0", "1.1" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.0" ),
+                Arrays.asList( createArtifact( "com.example", "example-project", "1.0", "jar" ),
+                               createArtifact( "com.example", "example-project", "1.0", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "com.example", "example-project", "1.1" ),
+                Arrays.asList( createArtifact( "com.example", "example-project", "1.1", "jar" ),
+                               createArtifact( "com.example", "example-project", "1.1", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org" ),
+                                                       Arrays.asList( "apache", "codehaus" ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache" ),
+                                                       Arrays.asList( "archiva", "maven" ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.apache" ),
+                                                       Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ), Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjects( TEST_REPO_ID, "org.apache.archiva" ),
+                Arrays.asList( "metadata-repository-api", "metadata-model" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api" ),
+                Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api",
+                                                 "1.3-SNAPSHOT" ),
+                Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
+                               createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT",
+                                               "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-repository-api", "1.3" ),
+                Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ),
+                               createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "metadata-model" ),
+                Arrays.asList( "1.3-SNAPSHOT", "1.3" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3-SNAPSHOT" ),
+                Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT", "jar" ),
+                               createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3-SNAPSHOT",
+                                               "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.archiva", "metadata-model", "1.3" ),
+                Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "jar" ),
+                               createArtifact( "org.apache.archiva", "metadata-repository-api", "1.3", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getNamespaces( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjects( TEST_REPO_ID, "org.apache.maven" ), Arrays.asList( "maven-model" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjectVersions( TEST_REPO_ID, "org.apache.maven", "maven-model" ),
+                Arrays.asList( "2.2.1" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.apache.maven", "maven-model", "2.2.1" ),
+                Arrays.asList( createArtifact( "org.apache.archiva", "metadata-repository-api", "2.2.1", "jar" ),
+                               createArtifact( "org.apache.archiva", "metadata-repository-api", "2.2.1", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus" ),
+                                                       Arrays.asList( "plexus" ) );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org" ),
+                                                       Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn( metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus" ),
+                                                       Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ), Arrays.asList() );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjects( TEST_REPO_ID, "org.codehaus.plexus" ),
+                Arrays.asList( "plexus-spring" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getProjectVersions( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring" ),
+                Arrays.asList( "1.0", "1.1", "1.2" ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.0" ),
+                Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "jar" ),
+                               createArtifact( "org.codehaus.plexus", "plexus-spring", "1.0", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.1" ),
+                Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "jar" ),
+                               createArtifact( "org.codehaus.plexus", "plexus-spring", "1.1", "pom" ) ) );
+            metadataRepositoryControl.expectAndReturn(
+                metadataRepository.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2" ),
+                Arrays.asList( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "jar" ),
+                               createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "pom" ) ) );
+        }
+    }
 }