]> source.dussan.org Git - archiva.git/commitdiff
Upgrading bidirlayout usage to RepoContent usage to eliminate bugs around missing...
authorJoakim Erdfelt <joakime@apache.org>
Wed, 17 Oct 2007 17:23:04 +0000 (17:23 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Wed, 17 Oct 2007 17:23:04 +0000 (17:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585583 13f79535-47bb-0310-9956-ffa450edef68

archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/DuplicateArtifactsConsumer.java
archiva-reporting/archiva-artifact-reports/src/main/java/org/apache/maven/archiva/reporting/artifact/LocationArtifactsConsumer.java

index 389a78667359ea0db51b738fbfd36061aaa2ad89..360af29d115bad038863b809294476d0c51ed4b6 100644 (file)
@@ -32,16 +32,15 @@ import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.RepositoryProblem;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
-import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.registry.Registry;
 import org.codehaus.plexus.registry.RegistryListener;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -85,9 +84,9 @@ public class DuplicateArtifactsConsumer
     /**
      * @plexus.requirement
      */
-    private BidirectionalRepositoryLayoutFactory layoutFactory;
+    private RepositoryContentFactory repositoryFactory;
 
-    private List includes = new ArrayList();
+    private List<String> includes = new ArrayList<String>();
 
     public String getId()
     {
@@ -114,7 +113,7 @@ public class DuplicateArtifactsConsumer
         /* do nothing */
     }
 
-    public List getIncludedTypes()
+    public List<String> getIncludedTypes()
     {
         return null;
     }
@@ -124,7 +123,7 @@ public class DuplicateArtifactsConsumer
     {
         String checksumSha1 = artifact.getModel().getChecksumSHA1();
 
-        List results = null;
+        List<ArchivaArtifact> results = null;
         try
         {
             results = dao.getArtifactDAO().queryArtifacts( new ArtifactsByChecksumConstraint(
@@ -150,11 +149,8 @@ public class DuplicateArtifactsConsumer
                 return;
             }
 
-            Iterator it = results.iterator();
-            while ( it.hasNext() )
+            for ( ArchivaArtifact dupArtifact : results )
             {
-                ArchivaArtifact dupArtifact = (ArchivaArtifact) it.next();
-
                 if ( dupArtifact.equals( artifact ) )
                 {
                     // Skip reference to itself.
@@ -190,10 +186,11 @@ public class DuplicateArtifactsConsumer
     {
         try
         {
-            BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
-            return layout.toPath( artifact );
+            String repoId = artifact.getModel().getRepositoryId();
+            ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId );
+            return repo.toPath( artifact );
         }
-        catch ( LayoutException e )
+        catch ( RepositoryException e )
         {
             getLogger().warn( "Unable to calculate path for artifact: " + artifact );
             return "";
index e9cc8416bb4b4efdf223ece1ad7c2b5c1fe6f8f6..1aa9d8223350ec96f0957a694e60a21c5d4a81e0 100644 (file)
@@ -32,9 +32,9 @@ import org.apache.maven.archiva.database.ArchivaDatabaseException;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArchivaProjectModel;
 import org.apache.maven.archiva.model.RepositoryProblem;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
-import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
+import org.apache.maven.archiva.repository.RepositoryContentFactory;
+import org.apache.maven.archiva.repository.RepositoryException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.registry.Registry;
@@ -93,11 +93,11 @@ public class LocationArtifactsConsumer
     /**
      * @plexus.requirement
      */
-    private BidirectionalRepositoryLayoutFactory layoutFactory;
+    private RepositoryContentFactory repositoryFactory;
 
     private Map repositoryMap = new HashMap();
 
-    private List includes = new ArrayList();
+    private List<String> includes = new ArrayList<String>();
 
     public String getId()
     {
@@ -219,14 +219,14 @@ public class LocationArtifactsConsumer
         return null;
     }
 
-    private List findJarEntryPattern( JarFile jar, String pattern )
+    private List<JarEntry> findJarEntryPattern( JarFile jar, String pattern )
     {
-        List hits = new ArrayList();
+        List<JarEntry> hits = new ArrayList<JarEntry>();
 
-        Enumeration entries = jar.entries();
+        Enumeration<JarEntry> entries = jar.entries();
         while ( entries.hasMoreElements() )
         {
-            JarEntry entry = (JarEntry) entries.nextElement();
+            JarEntry entry = entries.nextElement();
             if ( SelectorUtils.match( pattern, entry.getName() ) )
             {
                 hits.add( entry );
@@ -294,13 +294,14 @@ public class LocationArtifactsConsumer
     {
         try
         {
-            BidirectionalRepositoryLayout layout = layoutFactory.getLayout( artifact );
-            return layout.toPath( artifact );
+            String repoId = artifact.getModel().getRepositoryId();
+            ManagedRepositoryContent repo = repositoryFactory.getManagedRepositoryContent( repoId );
+            return repo.toPath( artifact );
         }
-        catch ( LayoutException e )
+        catch ( RepositoryException e )
         {
             getLogger().warn( "Unable to calculate path for artifact: " + artifact );
-            return null;
+            return "";
         }
     }