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);
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;
/**
// 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() );
+ }
+ }
}
{
// 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;
}