mirror of https://github.com/apache/archiva.git
check first if the request is .indexer browsing to not iterate over repositories (ie normal process)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1197905 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c437a85fb
commit
f0a3cbb416
|
@ -92,6 +92,7 @@ import javax.annotation.PostConstruct;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
|
@ -938,6 +939,29 @@ public class ArchivaDavResourceFactory
|
|||
boolean allow = isAllowedToContinue( request, repositories, activePrincipal );
|
||||
|
||||
if ( allow )
|
||||
{
|
||||
|
||||
// remove last /
|
||||
String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
|
||||
if ( StringUtils.endsWith( pathInfo, "/.indexer" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
File mergedRepoDir = buildMergedIndexDirectory( repositories, activePrincipal, request );
|
||||
mergedRepositoryContents.add( mergedRepoDir );
|
||||
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new DavException( 500, e );
|
||||
}
|
||||
catch ( IndexMergerException e )
|
||||
{
|
||||
throw new DavException( 500, e );
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( String repository : repositories )
|
||||
{
|
||||
|
@ -975,8 +999,8 @@ public class ArchivaDavResourceFactory
|
|||
}
|
||||
if ( StringUtils.isEmpty( repoIndexDirectory ) )
|
||||
{
|
||||
repoIndexDirectory =
|
||||
new File( managedRepository.getRepository().getLocation(), ".indexer" ).getAbsolutePath();
|
||||
repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
|
||||
".indexer" ).getAbsolutePath();
|
||||
}
|
||||
|
||||
if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory ),
|
||||
|
@ -998,9 +1022,8 @@ public class ArchivaDavResourceFactory
|
|||
// TODO: review exception handling
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug(
|
||||
"Skipping repository '" + managedRepository + "' for user '" + activePrincipal
|
||||
+ "': " + e.getMessage() );
|
||||
log.debug( "Skipping repository '" + managedRepository + "' for user '"
|
||||
+ activePrincipal + "': " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,59 +1046,14 @@ public class ArchivaDavResourceFactory
|
|||
// TODO: review exception handling
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug(
|
||||
"Skipping repository '" + managedRepository + "' for user '" + activePrincipal
|
||||
+ "': " + e.getMessage() );
|
||||
log.debug( "Skipping repository '" + managedRepository + "' for user '"
|
||||
+ activePrincipal + "': " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove last /
|
||||
String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
|
||||
if ( StringUtils.endsWith( path, ".indexer" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
Set<String> authzRepos = new HashSet<String>();
|
||||
for ( String repository : repositories )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( servletAuth.isAuthorized( activePrincipal, repository,
|
||||
WebdavMethodUtil.getMethodPermission(
|
||||
request.getMethod() ) ) )
|
||||
{
|
||||
authzRepos.add( repository );
|
||||
authzRepos.addAll( this.repositorySearch.getRemoteIndexingContextIds( repository ) );
|
||||
}
|
||||
}
|
||||
catch ( UnauthorizedException e )
|
||||
{
|
||||
// TODO: review exception handling
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug(
|
||||
"Skipping repository '" + repository + "' for user '" + activePrincipal + "': "
|
||||
+ e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File mergedRepoDir = indexMerger.buildMergedIndex( authzRepos, true );
|
||||
mergedRepositoryContents.add( mergedRepoDir );
|
||||
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new DavException( 500, e );
|
||||
}
|
||||
catch ( IndexMergerException e )
|
||||
{
|
||||
throw new DavException( 500, e );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1202,6 +1180,39 @@ public class ArchivaDavResourceFactory
|
|||
}
|
||||
}
|
||||
|
||||
protected File buildMergedIndexDirectory( List<String> repositories, String activePrincipal,
|
||||
DavServletRequest request )
|
||||
throws RepositoryAdminException, IndexMergerException
|
||||
{
|
||||
|
||||
Set<String> authzRepos = new HashSet<String>();
|
||||
for ( String repository : repositories )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( servletAuth.isAuthorized( activePrincipal, repository,
|
||||
WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
|
||||
{
|
||||
authzRepos.add( repository );
|
||||
authzRepos.addAll( this.repositorySearch.getRemoteIndexingContextIds( repository ) );
|
||||
}
|
||||
}
|
||||
catch ( UnauthorizedException e )
|
||||
{
|
||||
// TODO: review exception handling
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( "Skipping repository '" + repository + "' for user '" + activePrincipal + "': "
|
||||
+ e.getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File mergedRepoDir = indexMerger.buildMergedIndex( authzRepos, true );
|
||||
return mergedRepoDir;
|
||||
}
|
||||
|
||||
|
||||
public void setServletAuth( ServletAuthenticator servletAuth )
|
||||
{
|
||||
this.servletAuth = servletAuth;
|
||||
|
|
Loading…
Reference in New Issue