mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
eb49de5e72
commit
ce50b0d6e3
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 + "]" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue