]> source.dussan.org Git - archiva.git/commitdiff
Added a new class "DiscovererPath" for use to represent paths processed by the Discov...
authorEdwin L. Punzalan <epunzalan@apache.org>
Tue, 13 Jun 2006 07:57:20 +0000 (07:57 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Tue, 13 Jun 2006 07:57:20 +0000 (07:57 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@413827 13f79535-47bb-0310-9956-ffa450edef68

maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/AbstractDiscoverer.java
maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java [new file with mode: 0644]
maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultArtifactDiscovererTest.java
maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/DefaultMetadataDiscovererTest.java
maven-repository-discovery/src/test/java/org/apache/maven/repository/discovery/LegacyArtifactDiscovererTest.java

index 3fbc8778889594827e6450031aaddfa8ad1bb858..349239a0b69851dffc49b4f019ef78b2938c1817 100644 (file)
@@ -20,14 +20,13 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 
 /**
  * Base class for the artifact and metadata discoverers.
@@ -38,7 +37,7 @@ public abstract class AbstractDiscoverer
     extends AbstractLogEnabled
     implements Discoverer
 {
-    private Map kickedOutPaths = new HashMap();
+    private List kickedOutPaths = new ArrayList();
 
     /**
      * @plexus.requirement
@@ -57,12 +56,12 @@ public abstract class AbstractDiscoverer
      */
     protected void addKickedOutPath( String path, String reason )
     {
-        kickedOutPaths.put( path, reason );
+        kickedOutPaths.add( new DiscovererPath( path, reason ) );
     }
 
     public Iterator getKickedOutPathsIterator()
     {
-        return kickedOutPaths.keySet().iterator();
+        return kickedOutPaths.iterator();
     }
 
     /**
@@ -78,7 +77,7 @@ public abstract class AbstractDiscoverer
             allExcludes.addAll( Arrays.asList( excludes ) );
         }
 
-        if ( blacklistedPatterns != null && blacklistedPatterns.length() > 0 )
+        if ( !StringUtils.isEmpty( blacklistedPatterns ) )
         {
             allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) );
         }
@@ -93,7 +92,12 @@ public abstract class AbstractDiscoverer
 
         scanner.scan();
 
-        excludedPaths.addAll( Arrays.asList( scanner.getExcludedFiles() ) );
+        for ( Iterator files = Arrays.asList( scanner.getExcludedFiles() ).iterator(); files.hasNext(); )
+        {
+            String path = files.next().toString();
+
+            excludedPaths.add( new DiscovererPath( path, "Excluded by DirectoryScanner" ) );
+        }
 
         return scanner.getIncludedFiles();
     }
diff --git a/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java b/maven-repository-discovery/src/main/java/org/apache/maven/repository/discovery/DiscovererPath.java
new file mode 100644 (file)
index 0000000..20f621d
--- /dev/null
@@ -0,0 +1,56 @@
+package org.apache.maven.repository.discovery;
+
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public class DiscovererPath
+{
+    private String path;
+    private String comment;
+
+    public DiscovererPath()
+    {
+    }
+
+    public DiscovererPath( String path, String comment )
+    {
+        setPath( path );
+        setComment( comment );
+    }
+
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath( String path )
+    {
+        this.path = path;
+    }
+
+    public String getComment()
+    {
+        return comment;
+    }
+
+    public void setComment( String comment )
+    {
+        this.comment = comment;
+    }
+}
index 8d62a87909768bbc40e4ddffd87ae63644c5898a..4343cb546cd6fff56121c6e0977448eaa60b2c33 100644 (file)
@@ -71,7 +71,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = path.indexOf( ".svn" ) >= 0;
         }
@@ -91,7 +93,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "KEYS".equals( path );
         }
@@ -111,7 +115,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "javax/sql/jdbc/2.0/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -127,7 +133,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -147,7 +155,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar".equals(
                 path.replace( '\\', '/' ) );
@@ -169,7 +179,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid/1/invalid-1".equals( path.replace( '\\', '/' ) );
         }
@@ -189,7 +201,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid/1.0/invalid-2.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -209,7 +223,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid/1.0/invalid-1.0b.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -229,7 +245,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -249,7 +267,9 @@ public class DefaultArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar".equals(
                 path.replace( '\\', '/' ) );
index ca5845e2be21f072cf5d2cd7618eb6dc229a13ca..0caffd1a8fae67e0c7bde60c762dba985698d758 100644 (file)
@@ -75,7 +75,9 @@ public class DefaultMetadataDiscovererTest
         boolean found = false;
         while ( iter.hasNext() && !found )
         {
-            String dir = (String) iter.next();
+            DiscovererPath dPath = (DiscovererPath) iter.next();
+            String dir = dPath.getPath();
+
             String normalizedDir = dir.replace( '\\', '/' );
             if ( "javax/maven-metadata-repository.xml".equals( normalizedDir ) )
             {
@@ -95,7 +97,9 @@ public class DefaultMetadataDiscovererTest
         boolean found = false;
         while ( iter.hasNext() && !found )
         {
-            String dir = (String) iter.next();
+            DiscovererPath dPath = (DiscovererPath) iter.next();
+            String dir = dPath.getPath();
+
             String normalizedDir = dir.replace( '\\', '/' );
             if ( "org/apache/maven/some-ejb/1.0/maven-metadata-repository.xml".equals( normalizedDir ) )
             {
index 1e35aaefab67e18a62dffbf90a00f255b0d4b0d9..87cf546cead2626b4c0c11c863a020e6b9451446 100644 (file)
@@ -69,7 +69,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = path.indexOf( ".svn" ) >= 0;
         }
@@ -89,7 +91,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "KEYS".equals( path );
         }
@@ -109,7 +113,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "javax.sql/jars/jdbc-2.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -125,7 +131,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -145,7 +153,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/jars/1.0/invalid-1.0.jar".equals( path.replace( '\\', '/' ) );
         }
@@ -165,7 +175,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/foo/invalid-1.0.foo".equals( path.replace( '\\', '/' ) );
         }
@@ -185,7 +197,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/jars/no-extension".equals( path.replace( '\\', '/' ) );
         }
@@ -205,7 +219,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/jars/invalid-1.0.rar".equals( path.replace( '\\', '/' ) );
         }
@@ -225,7 +241,9 @@ public class LegacyArtifactDiscovererTest
         boolean found = false;
         for ( Iterator i = discoverer.getKickedOutPathsIterator(); i.hasNext() && !found; )
         {
-            String path = (String) i.next();
+            DiscovererPath dPath = (DiscovererPath) i.next();
+
+            String path = dPath.getPath();
 
             found = "invalid/jars/invalid.jar".equals( path.replace( '\\', '/' ) );
         }