From: Olivier Lamy Date: Wed, 2 Nov 2011 22:29:30 +0000 (+0000) Subject: do not display index directory in case of group X-Git-Tag: archiva-1.4-M2~190 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c814b9b98136f9756bbf833aaff58a56034d014d;p=archiva.git do not display index directory in case of group git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1196834 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index fa59079bf..057c7a872 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -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() ); + } } } }