]> source.dussan.org Git - archiva.git/commitdiff
[MRM-659] archiva cannot serve ejb artifacts from a maven1 repository
authorBrett Porter <brett@apache.org>
Tue, 25 Mar 2008 10:07:15 +0000 (10:07 +0000)
committerBrett Porter <brett@apache.org>
Tue, 25 Mar 2008 10:07:15 +0000 (10:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@640759 13f79535-47bb-0310-9956-ffa450edef68

archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
archiva-1.0.x/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java
archiva-1.0.x/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java

index 3c28cec2c110040370f87f4eb946d8f57822fc09..17702a192d5e297bee4ffdb67f553ea6fba048dd 100644 (file)
@@ -79,6 +79,12 @@ public class ArtifactExtensionMapping
     }
 
     public static String mapExtensionAndClassifierToType( String classifier, String extension )
+    {
+        return mapExtensionAndClassifierToType( classifier, extension, extension );
+    }
+
+    public static String mapExtensionAndClassifierToType( String classifier, String extension,
+                                                           String defaultExtension )
     {
         if ( "sources".equals( classifier ) )
         {
@@ -88,10 +94,15 @@ public class ArtifactExtensionMapping
         {
             return "javadoc";
         }
-        return mapExtensionToType( extension );
+        return mapExtensionToType( extension, defaultExtension );
     }
 
     public static String mapExtensionToType( String extension )
+    {
+        return mapExtensionToType( extension, extension );
+    }
+
+    private static String mapExtensionToType( String extension, String defaultExtension )
     {
         if ( "tar.gz".equals( extension ) )
         {
@@ -105,6 +116,6 @@ public class ArtifactExtensionMapping
         {
             return "distribution-zip";
         }
-        return extension;
+        return defaultExtension;
     }
 }
index e62d1516d28a1bffbac63d4e38fca871e74c4d40..0cf3b39978e07110dc52b634df554770e691eebe 100644 (file)
@@ -178,7 +178,9 @@ public class LegacyPathParser
         String extension = parser.getExtension();
 
         // Set Type
-        artifact.setType( ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension ) );
+        String defaultExtension = expectedType.substring( 0, expectedType.length() - 1 );
+        artifact.setType(
+            ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension, defaultExtension ) );
 
         // Sanity Check: does it have an extension?
         if ( StringUtils.isEmpty( artifact.getType() ) )
@@ -187,21 +189,19 @@ public class LegacyPathParser
         }
 
         // Special Case with Maven Plugins
-        if ( StringUtils.equals( "jar", artifact.getType() ) && StringUtils.equals( "plugins", expectedType ) )
+        if ( StringUtils.equals( "jar", extension ) && StringUtils.equals( "plugins", expectedType ) )
         {
             artifact.setType( ArtifactExtensionMapping.MAVEN_PLUGIN );
         }
         else
         {
             // Sanity Check: does extension match pathType on path?
-            String trimPathType = expectedType.substring( 0, expectedType.length() - 1 );
-
-            String expectedExtension = ArtifactExtensionMapping.getExtension( trimPathType );
+            String expectedExtension = ArtifactExtensionMapping.getExtension( artifact.getType() );
 
             if ( !expectedExtension.equals( extension ) )
             {
                 throw new LayoutException( INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension
-                    + "] and layout specified type [" + expectedType + "] (which maps to extension: ["
+                    + "] and layout specified type [" + artifact.getType() + "] (which maps to extension: ["
                     + expectedExtension + "]) on path [" + path + "]" );
             }
         }
index 7be0240517f3087c2a6ef02e1c47453601c72d3e..2991832b59de6ba30c6508eb9d26c2f29d28ce8a 100644 (file)
@@ -129,6 +129,8 @@ public class ManagedLegacyRepositoryContentTest
             "org.apache.maven/java-sources/testing-1.0-sources.jar",
             "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar",
             "org.apache.maven/poms/testing-1.0.pom",
+            "org.apache.maven/distributions/testing-1.0.tar.gz",
+            "org.apache.maven/distributions/testing-1.0.zip",
             "org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar" };
 
         StringBuffer relatedDebugString = new StringBuffer();
@@ -140,8 +142,6 @@ public class ManagedLegacyRepositoryContentTest
         }
         relatedDebugString.append( "]" );
 
-        assertEquals( "Related <" + relatedDebugString + ">:", expected.length, related.size() );
-
         for ( String expectedPath : expected )
         {
             boolean found = false;
@@ -160,6 +160,7 @@ public class ManagedLegacyRepositoryContentTest
                     + "Related <" + relatedDebugString + ">" );
             }
         }
+        assertEquals( "Related <" + relatedDebugString + ">:", expected.length, related.size() );
     }
 
     @Override
index d2507597319f679b96339f18f239138e06b9b2f5..6ee6f874a7f72d88e63d2a5a5edf111eab060fbc 100644 (file)
@@ -338,8 +338,38 @@ public class RepositoryRequestTest
         ManagedRepositoryContent repository = createManagedRepo( "default" );
 
         // Test (pom) legacy to default
-        assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom", repoRequest
-            .toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+        assertEquals( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0.pom",
+                      repoRequest.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+    }
+
+    public void testNativePathPomLegacyToLegacy()
+        throws Exception
+    {
+        ManagedRepositoryContent repository = createManagedRepo( "legacy" );
+
+        // Test (pom) legacy to default
+        assertEquals( "org.apache.derby/poms/derby-10.2.2.0.pom",
+                      repoRequest.toNativePath( "org.apache.derby/poms/derby-10.2.2.0.pom", repository ) );
+    }
+
+    public void testNativePathPomLegacyToDefaultEjb()
+        throws Exception
+    {
+        ManagedRepositoryContent repository = createManagedRepo( "default" );
+
+        // Test (pom) legacy to default
+        assertEquals( "mygroup/myejb/1.0/myejb-1.0.jar",
+                      repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ) );
+    }
+
+    public void testNativePathPomLegacyToLegacyEjb()
+        throws Exception
+    {
+        ManagedRepositoryContent repository = createManagedRepo( "legacy" );
+
+        // Test (pom) legacy to default
+        assertEquals( "mygroup/ejbs/myejb-1.0.jar",
+                      repoRequest.toNativePath( "mygroup/ejbs/myejb-1.0.jar", repository ) );
     }
 
     public void testNativePathSupportFileLegacyToDefault()