archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r921791 - in /archiva/trunk/archiva-modules: archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/ plugins/repository-statistics/ plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/ plugins/repository-sta...
Date Thu, 11 Mar 2010 10:39:34 GMT
Author: brett
Date: Thu Mar 11 10:39:33 2010
New Revision: 921791

URL: http://svn.apache.org/viewvc?rev=921791&view=rev
Log:
remove dependency on repository-layer from repository-statistics module

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
    archiva/trunk/archiva-modules/plugins/repository-statistics/pom.xml
    archiva/trunk/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
    archiva/trunk/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml?rev=921791&r1=921790&r2=921791&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml
Thu Mar 11 10:39:33 2010
@@ -52,6 +52,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
+      <artifactId>archiva-repository-layer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-scheduler-repository</artifactId>
     </dependency>
     <dependency>

Modified: archiva/trunk/archiva-modules/plugins/repository-statistics/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/repository-statistics/pom.xml?rev=921791&r1=921790&r2=921791&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/repository-statistics/pom.xml (original)
+++ archiva/trunk/archiva-modules/plugins/repository-statistics/pom.xml Thu Mar 11 10:39:33
2010
@@ -32,6 +32,11 @@
       <groupId>org.apache.archiva</groupId>
       <artifactId>metadata-repository-api</artifactId>
     </dependency>
+    <!-- TODO: look at making this optional -->
+    <dependency>
+      <groupId>org.apache.archiva</groupId>
+      <artifactId>maven2-repository</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-spring</artifactId>
@@ -51,9 +56,5 @@
       <artifactId>jcl-over-slf4j</artifactId>
       <scope>test</scope>
     </dependency>
-    <dependency>
-      <groupId>org.apache.archiva</groupId>
-      <artifactId>archiva-repository-layer</artifactId>
-    </dependency>
   </dependencies>
 </project>

Modified: archiva/trunk/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java?rev=921791&r1=921790&r2=921791&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
(original)
+++ archiva/trunk/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java
Thu Mar 11 10:39:33 2010
@@ -19,6 +19,12 @@ package org.apache.archiva.metadata.repo
  * under the License.
  */
 
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -28,15 +34,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.TimeZone;
 
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.maven.archiva.repository.ManagedRepositoryContent;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.RepositoryException;
-import org.apache.maven.archiva.repository.layout.LayoutException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * @plexus.component role="org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager"
role-hint="default"
  */
@@ -50,11 +47,6 @@ public class DefaultRepositoryStatistics
      */
     private MetadataRepository metadataRepository;
 
-    /**
-     * @plexus.requirement
-     */
-    private RepositoryContentFactory repositoryContentFactory;
-
     private static final TimeZone UTC_TIME_ZONE = TimeZone.getTimeZone( "UTC" );
 
     public RepositoryStatistics getLastStatistics( String repositoryId )
@@ -74,12 +66,11 @@ public class DefaultRepositoryStatistics
         }
     }
 
-    private void walkRepository( RepositoryStatistics stats, String repositoryId, String
ns,
-                                 ManagedRepositoryContent repositoryContent )
+    private void walkRepository( RepositoryStatistics stats, String repositoryId, String
ns )
     {
         for ( String namespace : metadataRepository.getNamespaces( repositoryId, ns ) )
         {
-            walkRepository( stats, repositoryId, ns + "." + namespace, repositoryContent
);
+            walkRepository( stats, repositoryId, ns + "." + namespace );
         }
 
         Collection<String> projects = metadataRepository.getProjects( repositoryId,
ns );
@@ -98,18 +89,12 @@ public class DefaultRepositoryStatistics
                         stats.setTotalArtifactCount( stats.getTotalArtifactCount() + 1 );
                         stats.setTotalArtifactFileSize( stats.getTotalArtifactFileSize()
+ artifact.getSize() );
 
-                        // TODO: need a maven2 metadata repository API equivalent
-                        try
+                        MavenArtifactFacet facet = (MavenArtifactFacet) artifact.getFacet(
MavenArtifactFacet.FACET_ID );
+                        if ( facet != null )
                         {
-                            String type = repositoryContent.toArtifactReference(
-                                ns.replace( '.', '/' ) + "/" + project + "/" + version +
"/" +
-                                    artifact.getId() ).getType();
+                            String type = facet.getType();
                             stats.setTotalCountForType( type, stats.getTotalCountForType(
type ) + 1 );
                         }
-                        catch ( LayoutException e )
-                        {
-                            // ignore
-                        }
                     }
                 }
             }
@@ -138,16 +123,7 @@ public class DefaultRepositoryStatistics
         //       it on the fly
         for ( String ns : metadataRepository.getRootNamespaces( repositoryId ) )
         {
-            ManagedRepositoryContent content;
-            try
-            {
-                content = repositoryContentFactory.getManagedRepositoryContent( repositoryId
);
-            }
-            catch ( RepositoryException e )
-            {
-                throw new RuntimeException( e );
-            }
-            walkRepository( repositoryStatistics, repositoryId, ns, content );
+            walkRepository( repositoryStatistics, repositoryId, ns );
         }
         log.info( "Repository walk for statistics executed in " + ( System.currentTimeMillis()
- startWalk ) + "ms" );
 
@@ -199,9 +175,4 @@ public class DefaultRepositoryStatistics
     {
         this.metadataRepository = metadataRepository;
     }
-
-    public void setRepositoryContentFactory( RepositoryContentFactory repositoryContentFactory
)
-    {
-        this.repositoryContentFactory = repositoryContentFactory;
-    }
 }

Modified: archiva/trunk/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java?rev=921791&r1=921790&r2=921791&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
(original)
+++ archiva/trunk/archiva-modules/plugins/repository-statistics/src/test/java/org/apache/archiva/metadata/repository/stats/RepositoryStatisticsManagerTest.java
Thu Mar 11 10:39:33 2010
@@ -19,6 +19,11 @@ package org.apache.archiva.metadata.repo
  * under the License.
  */
 
+import junit.framework.TestCase;
+import org.apache.archiva.metadata.model.ArtifactMetadata;
+import org.apache.archiva.metadata.repository.MetadataRepository;
+import org.easymock.MockControl;
+
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -30,15 +35,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
 
-import junit.framework.TestCase;
-import org.apache.archiva.metadata.model.ArtifactMetadata;
-import org.apache.archiva.metadata.repository.MetadataRepository;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.repository.RepositoryContentFactory;
-import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
-import org.easymock.MockControl;
-import org.easymock.classextension.MockClassControl;
-
 public class RepositoryStatisticsManagerTest
     extends TestCase
 {
@@ -76,18 +72,6 @@ public class RepositoryStatisticsManager
         metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
         metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
         repositoryStatisticsManager.setMetadataRepository( metadataRepository );
-
-        ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
-        repository.setId( TEST_REPO_ID );
-        repository.setLocation( "" );
-        ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( repository );
-        MockControl control = MockClassControl.createControl( RepositoryContentFactory.class
);
-        RepositoryContentFactory contentFactory = (RepositoryContentFactory) control.getMock();
-        contentFactory.getManagedRepositoryContent( TEST_REPO_ID );
-        control.setDefaultReturnValue( content );
-        control.replay();
-        repositoryStatisticsManager.setRepositoryContentFactory( contentFactory );
     }
 
     public void testGetLatestStats()



Mime
View raw message