aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-base/archiva-repository-layer/src
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2008-03-25 10:17:36 +0000
committerBrett Porter <brett@apache.org>2008-03-25 10:17:36 +0000
commitce50b0d6e3cf14395bfc3e4749fe3fc7b03cab75 (patch)
treeece4ebe4e1617dbe480a364cd8292cf18e218c3b /archiva-base/archiva-repository-layer/src
parenteb49de5e7267ef610328d583579a4fb9a5f3ec7a (diff)
downloadarchiva-ce50b0d6e3cf14395bfc3e4749fe3fc7b03cab75.tar.gz
archiva-ce50b0d6e3cf14395bfc3e4749fe3fc7b03cab75.zip
[MRM-659] archiva cannot serve ejb artifacts from a maven1 repository
Merged from: r640759 git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@640761 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base/archiva-repository-layer/src')
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java15
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java12
-rw-r--r--archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java5
-rw-r--r--archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java34
4 files changed, 54 insertions, 12 deletions
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
index 3c28cec2c..17702a192 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java
@@ -80,6 +80,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 ) )
{
return "java-source";
@@ -88,11 +94,16 @@ 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 ) )
{
return "distribution-tgz";
@@ -105,6 +116,6 @@ public class ArtifactExtensionMapping
{
return "distribution-zip";
}
- return extension;
+ return defaultExtension;
}
}
diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
index e62d1516d..0cf3b3997 100644
--- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
+++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyPathParser.java
@@ -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 + "]" );
}
}
diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java
index 7be024051..2991832b5 100644
--- a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java
+++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/ManagedLegacyRepositoryContentTest.java
@@ -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
diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
index d25075973..6ee6f874a 100644
--- a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
+++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java
@@ -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()