[MRM-1804] IndexOutOfBoundsException when browsing a group with 0 or 1 repo

fix display

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1568622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2014-02-15 11:59:13 +00:00
parent b4f1eb21cf
commit 1cbce6c13b
2 changed files with 40 additions and 19 deletions

View File

@ -107,6 +107,7 @@ import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -117,7 +118,7 @@ import java.util.Set;
/**
*
*/
@Service("davResourceFactory#archiva")
@Service( "davResourceFactory#archiva" )
public class ArchivaDavResourceFactory
implements DavResourceFactory, Auditable
{
@ -136,7 +137,7 @@ public class ArchivaDavResourceFactory
private RepositoryRequest repositoryRequest;
@Inject
@Named(value = "repositoryProxyConnectors#default")
@Named( value = "repositoryProxyConnectors#default" )
private RepositoryProxyConnectors connectors;
@Inject
@ -151,7 +152,7 @@ public class ArchivaDavResourceFactory
private ServletAuthenticator servletAuth;
@Inject
@Named(value = "httpAuthenticator#basic")
@Named( value = "httpAuthenticator#basic" )
private HttpAuthenticator httpAuth;
@Inject
@ -178,11 +179,11 @@ public class ArchivaDavResourceFactory
private Digester digestMd5;
@Inject
@Named(value = "archivaTaskScheduler#repository")
@Named( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler scheduler;
@Inject
@Named(value = "fileLockManager#default")
@Named( value = "fileLockManager#default" )
private FileLockManager fileLockManager;
private ApplicationContext applicationContext;
@ -239,8 +240,14 @@ public class ArchivaDavResourceFactory
{
try
{
return getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
repoGroupConfig );
DavResource davResource =
getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
repoGroupConfig );
setHeaders( response, locator, davResource );
return davResource;
}
catch ( RepositoryAdminException e )
{
@ -853,8 +860,8 @@ public class ArchivaDavResourceFactory
{
// [MRM-503] - Metadata file need Pragma:no-cache response
// header.
if ( locator.getResourcePath().endsWith( "/maven-metadata.xml" )
|| ( (ArchivaDavResource) resource ).getLocalResource().isDirectory() )
if ( locator.getResourcePath().endsWith( "/maven-metadata.xml" ) || ( resource instanceof ArchivaDavResource
&& ( ArchivaDavResource.class.cast( resource ).getLocalResource().isDirectory() ) ) )
{
response.setHeader( "Pragma", "no-cache" );
response.setHeader( "Cache-Control", "no-cache" );
@ -862,10 +869,13 @@ public class ArchivaDavResourceFactory
}
// if the resource is a directory don't cache it as new groupId deployed will be available
// without need of refreshing browser
else
else if ( locator.getResourcePath().endsWith( "/maven-metadata.xml" ) || (
resource instanceof ArchivaVirtualDavResource && ( new File(
ArchivaVirtualDavResource.class.cast( resource ).getLogicalResource() ).isDirectory() ) ) )
{
// We need to specify this so connecting wagons can work correctly
response.setDateHeader( "Last-Modified", resource.getModificationTime() );
response.setHeader( "Pragma", "no-cache" );
response.setHeader( "Cache-Control", "no-cache" );
response.setDateHeader( "Last-Modified", new Date().getTime() );
}
// TODO: [MRM-524] determine http caching options for other types of files (artifacts, sha1, md5, snapshots)
}
@ -978,13 +988,15 @@ public class ArchivaDavResourceFactory
|| repositoryGroupConfiguration.getRepositories().isEmpty() )
{
return new ArchivaVirtualDavResource( new ArrayList<File>(), //
new File( System.getProperty( "appserver.base" ) + "/groups/"
+ repositoryGroupConfiguration.getId() ).getPath(), //
mimeTypes, //
locator, //
this
);
File file =
new File( System.getProperty( "appserver.base"), "groups/" + repositoryGroupConfiguration.getId() );
return new ArchivaDavResource( file.getPath(), "groups/" + repositoryGroupConfiguration.getId(),
null,request.getDavSession(), locator, this,
mimeTypes, auditListeners,
scheduler, fileLockManager );
//return new ArchivaVirtualDavResource( Collections.<File>emptyList(), file.getPath(), mimeTypes, locator,
// this );
}
List<File> mergedRepositoryContents = new ArrayList<File>();
// multiple repo types so we guess they are all the same type

View File

@ -343,4 +343,13 @@ public class ArchivaVirtualDavResource
propsInitialized = true;
}
public String getLogicalResource()
{
return logicalResource;
}
public void setLogicalResource( String logicalResource )
{
this.logicalResource = logicalResource;
}
}