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

View File

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