You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by br...@apache.org on 2008/04/20 13:13:59 UTC
svn commit: r649910 - in /archiva/trunk/archiva-modules/archiva-web:
archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/
archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/
archiva-webdav/src/main/java/org/apache/mav...
Author: brett
Date: Sun Apr 20 04:13:55 2008
New Revision: 649910
URL: http://svn.apache.org/viewvc?rev=649910&view=rev
Log:
[MRM-780] Access to indexes files with a browser is not possible
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java
archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java?rev=649910&r1=649909&r2=649910&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/RepositoryServlet.java Sun Apr 20 04:13:55 2008
@@ -124,8 +124,10 @@
final String msg = "Should throw " + UnauthorizedDavException.class.getName();
log.error(msg);
webdavResponse.sendError(e.getErrorCode(), msg);
+ } else if ( e.getCause() != null ) {
+ webdavResponse.sendError(e.getErrorCode(), e.getCause().getMessage());
} else {
- webdavResponse.sendError(e);
+ webdavResponse.sendError(e.getErrorCode(), e.getMessage());
}
} finally {
getDavSessionProvider().releaseSession(webdavRequest);
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java?rev=649910&r1=649909&r2=649910&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/repository/RepositoryServletTest.java Sun Apr 20 04:13:55 2008
@@ -23,6 +23,12 @@
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
+import com.meterware.httpunit.GetMethodWebRequest;
+import com.meterware.httpunit.HttpNotFoundException;
+import com.meterware.httpunit.HttpUnitOptions;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebResponse;
+
import java.io.File;
/**
@@ -90,5 +96,35 @@
// check other is still intact
assertRepositoryValid( servlet, REPOID_INTERNAL );
+ }
+
+ public void testGetRepositoryInvalidPathPassthroughPresent()
+ throws Exception
+ {
+ String path = REQUEST_PATH + ".index/filecontent/segments.gen";
+
+ populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );
+
+ WebRequest request = new GetMethodWebRequest( path );
+ WebResponse response = sc.getResponse( request );
+ assertResponseOK( response );
+ assertEquals( "index file", response.getText() );
+ }
+
+ public void testGetRepositoryInvalidPathPassthroughMissing()
+ throws Exception
+ {
+ String path = REQUEST_PATH + ".index/filecontent/foo.bar";
+
+ WebRequest request = new GetMethodWebRequest( path );
+ try
+ {
+ sc.getResponse( request );
+ fail( "should have been not found" );
+ }
+ catch ( HttpNotFoundException e )
+ {
+ assertEquals( "Error on HTTP request: 404 Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path. [http://machine.com/repository/internal/.index/filecontent/foo.bar]", e.getMessage() );
+ }
}
}
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java?rev=649910&r1=649909&r2=649910&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/ArchivaDavResourceFactory.java Sun Apr 20 04:13:55 2008
@@ -148,29 +148,32 @@
{
// At this point the incoming request can either be in default or
// legacy layout format.
+ boolean fromProxy = fetchContentFromProxies(managedRepository, request, logicalResource );
+
+ boolean previouslyExisted = resourceFile.exists();
+
try
{
- boolean fromProxy = fetchContentFromProxies(managedRepository, request, logicalResource );
-
// Perform an adjustment of the resource to the managed
// repository expected path.
String localResourcePath = repositoryRequest.toNativePath( logicalResource.getPath(), managedRepository );
resourceFile = new File( managedRepository.getRepoRoot(), localResourcePath );
-
- boolean previouslyExisted = resourceFile.exists();
-
- // Attempt to fetch the resource from any defined proxy.
- if ( fromProxy )
- {
- processAuditEvents(request, locator.getWorkspaceName(), logicalResource.getPath(), previouslyExisted, resourceFile, " (proxied)");
- }
- resource = new ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, locator, this, null);
-
}
catch ( LayoutException e )
{
+ if ( previouslyExisted )
+ {
+ return resource;
+ }
throw new DavException(HttpServletResponse.SC_NOT_FOUND, e);
}
+
+ // Attempt to fetch the resource from any defined proxy.
+ if ( fromProxy )
+ {
+ processAuditEvents(request, locator.getWorkspaceName(), logicalResource.getPath(), previouslyExisted, resourceFile, " (proxied)");
+ }
+ resource = new ArchivaDavResource(resourceFile.getAbsolutePath(), logicalResource.getPath(), mimeTypes, locator, this, null);
}
return resource;
}