]> source.dussan.org Git - archiva.git/commitdiff
do not display index directory in case of group
authorOlivier Lamy <olamy@apache.org>
Wed, 2 Nov 2011 22:29:30 +0000 (22:29 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 2 Nov 2011 22:29:30 +0000 (22:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1196834 13f79535-47bb-0310-9956-ffa450edef68

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

index fa59079bf8d561fc758cb2ee3e0cbc3299b6b794..057c7a872d15c11b7157ac8248a9fc0f340d67c9 100644 (file)
@@ -50,6 +50,7 @@ import org.apache.archiva.webdav.util.MimeTypes;
 import org.apache.archiva.webdav.util.RepositoryPathUtil;
 import org.apache.archiva.webdav.util.WebdavMethodUtil;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.jackrabbit.webdav.DavException;
 import org.apache.jackrabbit.webdav.DavResource;
@@ -948,49 +949,69 @@ public class ArchivaDavResourceFactory
                 File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
                 if ( resourceFile.exists() )
                 {
-                    // for prompted authentication
-                    if ( httpAuth.getSecuritySession( request.getSession( true ) ) != null )
+                    // in case of group displaying index directory doesn't have sense !!
+                    String repoIndexDirectory = managedRepository.getRepository().getIndexDirectory();
+                    if ( !new File( repoIndexDirectory ).isAbsolute() )
                     {
-                        try
+                        repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
+                                                       StringUtils.isEmpty( repoIndexDirectory )
+                                                           ? ".indexer"
+                                                           : repoIndexDirectory ).getAbsolutePath();
+                    }
+                    if ( StringUtils.isEmpty( repoIndexDirectory ) )
+                    {
+                        repoIndexDirectory =
+                            new File( managedRepository.getRepository().getLocation(), ".indexer" ).getAbsolutePath();
+                    }
+
+                    if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory ),
+                                              FilenameUtils.normalize( resourceFile.getAbsolutePath() ) ) )
+                    {
+                        // for prompted authentication
+                        if ( httpAuth.getSecuritySession( request.getSession( true ) ) != null )
                         {
-                            if ( isAuthorized( request, repository ) )
+                            try
                             {
-                                mergedRepositoryContents.add( resourceFile );
-                                log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
+                                if ( isAuthorized( request, repository ) )
+                                {
+                                    mergedRepositoryContents.add( resourceFile );
+                                    log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
+                                }
                             }
-                        }
-                        catch ( DavException e )
-                        {
-                            // TODO: review exception handling
-                            if ( log.isDebugEnabled() )
+                            catch ( DavException e )
                             {
-                                log.debug(
-                                    "Skipping repository '" + managedRepository + "' for user '" + activePrincipal
-                                        + "': " + e.getMessage() );
+                                // TODO: review exception handling
+                                if ( log.isDebugEnabled() )
+                                {
+                                    log.debug(
+                                        "Skipping repository '" + managedRepository + "' for user '" + activePrincipal
+                                            + "': " + e.getMessage() );
+                                }
                             }
+
                         }
-                    }
-                    else
-                    {
-                        // for the current user logged in
-                        try
+                        else
                         {
-                            if ( servletAuth.isAuthorized( activePrincipal, repository,
-                                                           WebdavMethodUtil.getMethodPermission(
-                                                               request.getMethod() ) ) )
+                            // for the current user logged in
+                            try
                             {
-                                mergedRepositoryContents.add( resourceFile );
-                                log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
+                                if ( servletAuth.isAuthorized( activePrincipal, repository,
+                                                               WebdavMethodUtil.getMethodPermission(
+                                                                   request.getMethod() ) ) )
+                                {
+                                    mergedRepositoryContents.add( resourceFile );
+                                    log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
+                                }
                             }
-                        }
-                        catch ( UnauthorizedException e )
-                        {
-                            // TODO: review exception handling
-                            if ( log.isDebugEnabled() )
+                            catch ( UnauthorizedException e )
                             {
-                                log.debug(
-                                    "Skipping repository '" + managedRepository + "' for user '" + activePrincipal
-                                        + "': " + e.getMessage() );
+                                // TODO: review exception handling
+                                if ( log.isDebugEnabled() )
+                                {
+                                    log.debug(
+                                        "Skipping repository '" + managedRepository + "' for user '" + activePrincipal
+                                            + "': " + e.getMessage() );
+                                }
                             }
                         }
                     }