From 3c805f8f2db934930f537496591c147c332c4708 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 30 Jul 2012 14:39:31 +0000 Subject: [PATCH] [MRM-1645] mvn archetype:generate -DarchetypeCatalog (archetype-catalog.xml) failing with Not a valid artifact path. Submitted by Charles Kim. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1367107 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/repository/content/RepositoryRequest.java | 11 +++++++++++ .../archiva/webdav/ArchivaDavResourceFactory.java | 8 ++++++++ .../archiva/webdav/ArchivaDavResourceFactoryTest.java | 10 ++++++++++ 3 files changed, 29 insertions(+) diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/RepositoryRequest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/RepositoryRequest.java index 93b6af4ee..dcf825031 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/RepositoryRequest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/RepositoryRequest.java @@ -103,6 +103,17 @@ public class RepositoryRequest return requestedPath.endsWith( "/" + MetadataTools.MAVEN_METADATA ); } + /** + * + * @param requestedPath + * @return true if the requestedPath is likely an archetype catalog request. + */ + public boolean isArchetypeCatalog( String requestedPath ) + { + //TODO: Make it static final String + return requestedPath.endsWith( "/archetype-catalog.xml"); + } + /** *

* Tests the path to see if it conforms to the expectations of a support file request. diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 6b4d395da..b7d6e27d0 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -688,6 +688,14 @@ public class ArchivaDavResourceFactory return connectors.fetchMetatadaFromProxies( managedRepository, path ) != null; } + // Is it an Archetype Catalog? + if ( repositoryRequest.isArchetypeCatalog( path ) ) + { + File proxiedFile = connectors.fetchFromProxies( managedRepository, path ); + + return ( proxiedFile != null ); + } + // Not any of the above? Then it's gotta be an artifact reference. try { diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java index 3e9981f01..68b9b581f 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java @@ -241,6 +241,9 @@ public class ArchivaDavResourceFactoryTest "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); repoContentFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( INTERNAL_REPO ), internalRepo ); + repoRequestControl.expectAndReturn( + repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), + false ); archivaConfigurationControl.replay(); requestControl.replay(); @@ -309,6 +312,9 @@ public class ArchivaDavResourceFactoryTest internalRepo ), new File( config.findManagedRepositoryById( INTERNAL_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + repoRequestControl.expectAndReturn( + repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), + false ); archivaConfigurationControl.replay(); requestControl.replay(); @@ -387,6 +393,10 @@ public class ArchivaDavResourceFactoryTest new File( config.findManagedRepositoryById( LOCAL_MIRROR_REPO ).getLocation(), "target/test-classes/internal/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ).getPath() ); + repoRequestControl.expectAndReturn( + repoRequest.isArchetypeCatalog( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ), + false , 2); + archivaConfigurationControl.replay(); requestControl.replay(); repoContentFactoryControl.replay(); -- 2.39.5