]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1804] IndexOutOfBoundsException when browsing a group with 0 or 1 repo
authorOlivier Lamy <olamy@apache.org>
Sat, 15 Feb 2014 11:59:13 +0000 (11:59 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 15 Feb 2014 11:59:13 +0000 (11:59 +0000)
fix display

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1568622 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaVirtualDavResource.java

index 260e4e4a32d6afb593339886fbeb0953773fbc9c..6739c1a3a4996e177330a8eba099ee8f9a33ad75 100644 (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
index 0ff1dfc6fa0acca85a3270aa594ae79ca649087a..f11c9a2cd392d90541ec634a221515784b1686e2 100644 (file)
@@ -343,4 +343,13 @@ public class ArchivaVirtualDavResource
         propsInitialized = true;
     }
 
+    public String getLogicalResource()
+    {
+        return logicalResource;
+    }
+
+    public void setLogicalResource( String logicalResource )
+    {
+        this.logicalResource = logicalResource;
+    }
 }