summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webdav
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2013-12-09 11:22:27 +0000
committerOlivier Lamy <olamy@apache.org>2013-12-09 11:22:27 +0000
commitd1de91d8241b99ad89620df8da72aaece6c835c9 (patch)
tree6df6f846ba91fd98d771515e5f39f71ea61c31ff /archiva-modules/archiva-web/archiva-webdav
parentab7ef5c73f417537e81f149702260d5a4c7282ab (diff)
downloadarchiva-d1de91d8241b99ad89620df8da72aaece6c835c9.tar.gz
archiva-d1de91d8241b99ad89620df8da72aaece6c835c9.zip
use a temporary redirect for SNAPSHOT download
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1549551 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav')
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java10
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java21
2 files changed, 21 insertions, 10 deletions
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 beb08e2c5..e24df205e 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
@@ -528,7 +528,7 @@ public class ArchivaDavResourceFactory
return path;
}
- private String evaluatePathWithVersion( ArchivaDavResourceLocator archivaLocator, ManagedRepositoryContent managedRepositoryContent )
+ private String evaluatePathWithVersion( ArchivaDavResourceLocator archivaLocator, ManagedRepositoryContent managedRepositoryContent, String contextPath )
throws DavException
{
String layout = managedRepositoryContent.getRepository() == null ? new ManagedRepository( ).getLayout() : managedRepositoryContent.getRepository().getLayout();
@@ -540,8 +540,10 @@ public class ArchivaDavResourceFactory
}
catch ( RelocationException e )
{
- log.debug( "Relocation to {}", e.getPath() );
- throw new BrowserRedirectException( e.getPath(), e.getRelocationType() );
+ String path = e.getPath();
+ log.debug( "Relocation to {}", path );
+
+ throw new BrowserRedirectException(contextPath + ( StringUtils.startsWith( path, "/" ) ? "": "/" ) + path, e.getRelocationType() );
}
catch ( XMLException e )
{
@@ -559,7 +561,7 @@ public class ArchivaDavResourceFactory
if ( isAuthorized( request, managedRepositoryContent.getId() ) )
{
// Maven Centric part ask evaluation if -SNAPSHOT
- String path = evaluatePathWithVersion(archivaLocator, managedRepositoryContent);
+ String path = evaluatePathWithVersion(archivaLocator, managedRepositoryContent, request.getContextPath());
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
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 20b1ad8e3..573e93e2b 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
@@ -240,8 +240,9 @@ public class ArchivaDavResourceFactoryTest
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
- expect( repoRequest.isSupportFile(
- "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( true );
+ expect( request.getContextPath() ).andReturn( "" ).times( 2 );
+
+ expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( true );
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
@@ -319,8 +320,9 @@ public class ArchivaDavResourceFactoryTest
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
- expect( repoRequest.isSupportFile(
- "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
+ expect( request.getContextPath() ).andReturn( "" ).times( 2 );
+
+ expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false );
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
@@ -400,8 +402,9 @@ public class ArchivaDavResourceFactoryTest
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 4 );
- expect( repoRequest.isSupportFile(
- "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
+ expect( request.getContextPath() ).andReturn( "" ).times( 2 );
+
+ expect( repoRequest.isSupportFile( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn( false ).times( 2 );
expect(
repoRequest.isDefault( "org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar" ) ).andReturn(
@@ -469,6 +472,8 @@ public class ArchivaDavResourceFactoryTest
expect( request.getRemoteAddr() ).andReturn( "http://localhost:8080" ).times( 3 );
+ expect( request.getContextPath() ).andReturn( "" ).times( 1 );
+
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
expect( request.getRequestURI() ).andReturn( "http://localhost:8080/archiva/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml" );
@@ -530,6 +535,8 @@ public class ArchivaDavResourceFactoryTest
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
+ expect( request.getContextPath() ).andReturn( "" ).times( 2 );
+
archivaConfigurationControl.replay();
repoContentFactoryControl.replay();
requestControl.replay();
@@ -579,6 +586,8 @@ public class ArchivaDavResourceFactoryTest
expect( request.getDavSession() ).andReturn( new ArchivaDavSession() ).times( 2 );
+ expect( request.getContextPath() ).andReturn( "" ).times( 2 );
+
archivaConfigurationControl.replay();
repoContentFactoryControl.replay();
requestControl.replay();