From 19987e6e17e3271dcf08647bd845219d1956d74e Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 14 Feb 2007 13:43:26 +0000 Subject: [PATCH] only scan if the repository actually exists (it may not have been created yet) git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@507529 13f79535-47bb-0310-9956-ffa450edef68 --- .../AbstractArtifactDiscoverer.java | 34 +++++++++--------- .../discoverer/DefaultMetadataDiscoverer.java | 36 ++++++++++--------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/AbstractArtifactDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/AbstractArtifactDiscoverer.java index 0f4b7bfde..f3002ec53 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/AbstractArtifactDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/AbstractArtifactDiscoverer.java @@ -63,31 +63,33 @@ public abstract class AbstractArtifactDiscoverer List artifacts = new ArrayList(); - List artifactPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns ); - - for ( Iterator i = artifactPaths.iterator(); i.hasNext(); ) + if ( repositoryBase.exists() ) { - String path = (String) i.next(); + List artifactPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns ); - try + for ( Iterator i = artifactPaths.iterator(); i.hasNext(); ) { - Artifact artifact = buildArtifactFromPath( path, repository ); - - if ( filter.include( artifact ) ) + String path = (String) i.next(); + + try { - artifacts.add( artifact ); + Artifact artifact = buildArtifactFromPath( path, repository ); + + if ( filter.include( artifact ) ) + { + artifacts.add( artifact ); + } + else + { + addExcludedPath( path, "Omitted by filter" ); + } } - else + catch ( DiscovererException e ) { - addExcludedPath( path, "Omitted by filter" ); + addKickedOutPath( path, e.getMessage() ); } } - catch ( DiscovererException e ) - { - addKickedOutPath( path, e.getMessage() ); - } } - return artifacts; } diff --git a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/DefaultMetadataDiscoverer.java b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/DefaultMetadataDiscoverer.java index dd18c5da3..f97972381 100644 --- a/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/DefaultMetadataDiscoverer.java +++ b/archiva-discoverer/src/main/java/org/apache/maven/archiva/discoverer/DefaultMetadataDiscoverer.java @@ -69,31 +69,35 @@ public class DefaultMetadataDiscoverer } List metadataFiles = new ArrayList(); - List metadataPaths = scanForArtifactPaths( new File( repository.getBasedir() ), blacklistedPatterns, - STANDARD_DISCOVERY_INCLUDES, null ); - for ( Iterator i = metadataPaths.iterator(); i.hasNext(); ) + File repositoryBase = new File( repository.getBasedir() ); + if ( repositoryBase.exists() ) { - String metadataPath = (String) i.next(); - try + List metadataPaths = scanForArtifactPaths( repositoryBase, blacklistedPatterns, + STANDARD_DISCOVERY_INCLUDES, null ); + + for ( Iterator i = metadataPaths.iterator(); i.hasNext(); ) { - RepositoryMetadata metadata = buildMetadata( repository.getBasedir(), metadataPath ); - File f = new File( repository.getBasedir(), metadataPath ); - if ( filter.include( metadata, f.lastModified() ) ) + String metadataPath = (String) i.next(); + try { - metadataFiles.add( metadata ); + RepositoryMetadata metadata = buildMetadata( repository.getBasedir(), metadataPath ); + File f = new File( repository.getBasedir(), metadataPath ); + if ( filter.include( metadata, f.lastModified() ) ) + { + metadataFiles.add( metadata ); + } + else + { + addExcludedPath( metadataPath, "Metadata excluded by filter" ); + } } - else + catch ( DiscovererException e ) { - addExcludedPath( metadataPath, "Metadata excluded by filter" ); + addKickedOutPath( metadataPath, e.getMessage() ); } } - catch ( DiscovererException e ) - { - addKickedOutPath( metadataPath, e.getMessage() ); - } } - return metadataFiles; } -- 2.39.5