diff options
author | Maria Odea B. Ching <oching@apache.org> | 2009-10-15 09:40:40 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2009-10-15 09:40:40 +0000 |
commit | fa22abb913579d8c69f2a46161328700e7238748 (patch) | |
tree | 1af994b4331af2cffe250de43a89dba172231354 /archiva-modules/archiva-base/archiva-repository-layer | |
parent | 7ecf7e1e887d62d31adc2693463eabc2687337ad (diff) | |
download | archiva-fa22abb913579d8c69f2a46161328700e7238748.tar.gz archiva-fa22abb913579d8c69f2a46161328700e7238748.zip |
[MRM-747] Archiva should prevent re-deployment of released or non-snapshot versioned artifacts
o moved check for metadata support files to RepositoryRequest and added tests
o throw DavException error 409 immediately for released artifacts intead of a ReleaseArtifactAlreadyExistsException
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@825449 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-layer')
2 files changed, 40 insertions, 0 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java index 4f4a85a20..e39b56494 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/RepositoryRequest.java @@ -133,6 +133,20 @@ public class RepositoryRequest return ( ".sha1".equals( ext ) || ".md5".equals( ext ) || ".asc".equals( ext ) || ".pgp".equals( ext ) ); } + public boolean isMetadataSupportFile( String requestedPath ) + { + if( isSupportFile( requestedPath ) ) + { + String basefilePath = StringUtils.substring( requestedPath, 0, requestedPath.lastIndexOf( '.' ) ); + if( isMetadata( basefilePath ) ) + { + return true; + } + } + + return false; + } + /** * <p> * Tests the path to see if it conforms to the expectations of a default layout request. diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java index 892adaf9d..ddb3688b3 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/content/RepositoryRequestTest.java @@ -35,6 +35,16 @@ import java.io.File; public class RepositoryRequestTest extends AbstractRepositoryLayerTestCase { + public void testInvalidRequestEmptyPath() + { + assertInvalidRequest( "" ); + } + + public void testInvalidRequestSlashOnly() + { + assertInvalidRequest( "//" ); + } + public void testInvalidRequestNoArtifactId() { assertInvalidRequest( "groupId/jars/-1.0.jar" ); @@ -237,6 +247,22 @@ public class RepositoryRequestTest assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) ); assertFalse( repoRequest.isMetadata( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) ); } + + public void testIsMetadataSupprotFile() + { + assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml" )); + assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml" )); + assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml.sha1" )); + assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/maven-metadata.xml.md5" )); + + assertFalse( repoRequest.isMetadataSupportFile( "test.maven-arch/poms/test-arch-2.0.3-SNAPSHOT.pom" ) ); + assertFalse( repoRequest.isMetadataSupportFile( "test/maven-arch/test-arch/2.0.3-SNAPSHOT/test-arch-2.0.3-SNAPSHOT.jar" ) ); + assertFalse( repoRequest.isMetadataSupportFile( "org/apache/archiva/archiva-api/1.0/archiva-api-1.0.xml.zip" ) ); + assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz" ) ); + assertFalse( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/derby-10.2.2.0-bin.tar.gz.pgp" ) ); + assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.sha1" ) ); + assertTrue( repoRequest.isMetadataSupportFile( "org/apache/derby/derby/10.2.2.0/maven-metadata.xml.md5" ) ); + } public void testIsDefault() { |