diff options
author | Brett Porter <brett@apache.org> | 2006-09-01 01:47:48 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2006-09-01 01:47:48 +0000 |
commit | 96ba48bf47f30f099a9b2bf83cd2f3686f5382ed (patch) | |
tree | 2a8598e15ebf5331c7f5bdbe75344a3169927f62 /archiva-discoverer | |
parent | f8dd7d4c5d7d09afa61e8de69999fb7517de6b28 (diff) | |
download | archiva-96ba48bf47f30f099a9b2bf83cd2f3686f5382ed.tar.gz archiva-96ba48bf47f30f099a9b2bf83cd2f3686f5382ed.zip |
[MRM-144] various minor improvements to code
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@439134 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-discoverer')
7 files changed, 17 insertions, 13 deletions
diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractArtifactDiscoverer.java index 5c184cd7c..9b3a8b98b 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractArtifactDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractArtifactDiscoverer.java @@ -46,13 +46,13 @@ public abstract class AbstractArtifactDiscoverer "**/*.MD5", "**/*.sha1", "**/*.SHA1", "**/*snapshot-version", "*/website/**", "*/licenses/**", "*/licences/**", "**/.htaccess", "**/*.html", "**/*.asc", "**/*.txt", "**/*.xml", "**/README*", "**/CHANGELOG*", "**/KEYS*"}; - private List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, long comparisonTimestamp ) + private List scanForArtifactPaths( File repositoryBase, List blacklistedPatterns, long comparisonTimestamp ) { return scanForArtifactPaths( repositoryBase, blacklistedPatterns, null, STANDARD_DISCOVERY_EXCLUDES, comparisonTimestamp ); } - public List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns, + public List discoverArtifacts( ArtifactRepository repository, String operation, List blacklistedPatterns, boolean includeSnapshots ) throws DiscovererException { diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractDiscoverer.java index 34abf41eb..dc90ef0c0 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/AbstractDiscoverer.java @@ -22,7 +22,6 @@ import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.codehaus.plexus.util.xml.Xpp3DomWriter; @@ -89,7 +88,7 @@ public abstract class AbstractDiscoverer return kickedOutPaths.iterator(); } - protected List scanForArtifactPaths( File repositoryBase, String blacklistedPatterns, String[] includes, + protected List scanForArtifactPaths( File repositoryBase, List blacklistedPatterns, String[] includes, String[] excludes, long comparisonTimestamp ) { List allExcludes = new ArrayList(); @@ -98,10 +97,9 @@ public abstract class AbstractDiscoverer { allExcludes.addAll( Arrays.asList( excludes ) ); } - - if ( !StringUtils.isEmpty( blacklistedPatterns ) ) + if ( blacklistedPatterns != null ) { - allExcludes.addAll( Arrays.asList( blacklistedPatterns.split( "," ) ) ); + allExcludes.addAll( blacklistedPatterns ); } DirectoryScanner scanner = new DirectoryScanner(); diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/ArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/ArtifactDiscoverer.java index b818adb14..353a72f6e 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/ArtifactDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/ArtifactDiscoverer.java @@ -47,7 +47,7 @@ public interface ArtifactDiscoverer * @return the list of artifacts discovered * @throws DiscovererException if there was an unrecoverable problem discovering artifacts or recording progress */ - List discoverArtifacts( ArtifactRepository repository, String operation, String blacklistedPatterns, + List discoverArtifacts( ArtifactRepository repository, String operation, List blacklistedPatterns, boolean includeSnapshots ) throws DiscovererException; diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/DefaultMetadataDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/DefaultMetadataDiscoverer.java index 10ab005b5..7074774b9 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/DefaultMetadataDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/DefaultMetadataDiscoverer.java @@ -62,7 +62,7 @@ public class DefaultMetadataDiscoverer */ private static final String[] STANDARD_DISCOVERY_INCLUDES = {"**/maven-metadata.xml"}; - public List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns ) + public List discoverMetadata( ArtifactRepository repository, String operation, List blacklistedPatterns ) throws DiscovererException { if ( !"file".equals( repository.getProtocol() ) ) diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/MetadataDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/MetadataDiscoverer.java index 1492c0742..04990808b 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/MetadataDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discovery/MetadataDiscoverer.java @@ -35,7 +35,8 @@ public interface MetadataDiscoverer * @param operation the operation being performed (used for timestamp comparison) * @param blacklistedPatterns Patterns that are to be excluded from the discovery process. * @return the list of artifacts found + * @throws DiscovererException if there is a problem during the discovery process */ - List discoverMetadata( ArtifactRepository repository, String operation, String blacklistedPatterns ) + List discoverMetadata( ArtifactRepository repository, String operation, List blacklistedPatterns ) throws DiscovererException; } diff --git a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/DefaultArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/DefaultArtifactDiscovererTest.java index 355cbfbaf..9c68b02b8 100644 --- a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/DefaultArtifactDiscovererTest.java +++ b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/DefaultArtifactDiscovererTest.java @@ -37,6 +37,8 @@ import java.util.Map; public class DefaultArtifactDiscovererTest extends AbstractArtifactDiscovererTest { + private static final List JAVAX_BLACKLIST = Collections.singletonList( "javax/**" ); + protected String getLayout() { return "default"; @@ -105,7 +107,7 @@ public class DefaultArtifactDiscovererTest public void testBlacklistedExclude() throws DiscovererException { - List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax/**", false ); + List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, JAVAX_BLACKLIST, false ); assertNotNull( "Check artifacts not null", artifacts ); boolean found = false; for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; ) diff --git a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/LegacyArtifactDiscovererTest.java b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/LegacyArtifactDiscovererTest.java index e622372c0..d514da90a 100644 --- a/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/LegacyArtifactDiscovererTest.java +++ b/archiva-discoverer/src/test/java/org/apache/maven/archiva/discovery/LegacyArtifactDiscovererTest.java @@ -21,6 +21,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import java.io.File; import java.net.MalformedURLException; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -28,11 +29,13 @@ import java.util.List; * Test the legacy artifact discoverer. * * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @version $Id$ + * @version $Id:LegacyArtifactDiscovererTest.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $ */ public class LegacyArtifactDiscovererTest extends AbstractArtifactDiscovererTest { + private static final List JAVAX_SQL_BLACKLIST = Collections.singletonList( "javax.sql/**" ); + protected String getLayout() { return "legacy"; @@ -100,7 +103,7 @@ public class LegacyArtifactDiscovererTest public void testBlacklistedExclude() throws DiscovererException { - List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, "javax.sql/**", false ); + List artifacts = discoverer.discoverArtifacts( repository, TEST_OPERATION, JAVAX_SQL_BLACKLIST, false ); assertNotNull( "Check artifacts not null", artifacts ); boolean found = false; for ( Iterator i = discoverer.getExcludedPathsIterator(); i.hasNext() && !found; ) |