mirror of https://github.com/apache/archiva.git
[MRM-1804] IndexOutOfBoundsException when browsing a group with 0 or 1 repo
avoid npe git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1568621 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d88a946f1
commit
b4f1eb21cf
|
@ -81,7 +81,14 @@ public class DefaultRepositoryGroupAdmin
|
||||||
{
|
{
|
||||||
for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
|
for ( RepositoryGroup repositoryGroup : getRepositoriesGroups() )
|
||||||
{
|
{
|
||||||
mergedRemoteIndexesScheduler.schedule( repositoryGroup, getMergedIndexDirectory( repositoryGroup.getId() ) );
|
mergedRemoteIndexesScheduler.schedule( repositoryGroup,
|
||||||
|
getMergedIndexDirectory( repositoryGroup.getId() ) );
|
||||||
|
// create the directory for each group if not exists
|
||||||
|
File groupPath = new File( groupsDirectory, repositoryGroup.getId() );
|
||||||
|
if ( !groupPath.exists() )
|
||||||
|
{
|
||||||
|
groupPath.mkdirs();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
|
@ -244,7 +251,8 @@ public class DefaultRepositoryGroupAdmin
|
||||||
{
|
{
|
||||||
throw new RepositoryAdminException(
|
throw new RepositoryAdminException(
|
||||||
"repositoryGroup with id " + repositoryGroupId + " doesn't not contains repository with id"
|
"repositoryGroup with id " + repositoryGroupId + " doesn't not contains repository with id"
|
||||||
+ repositoryId );
|
+ repositoryId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
repositoryGroup.removeRepository( repositoryId );
|
repositoryGroup.removeRepository( repositoryId );
|
||||||
|
|
|
@ -309,7 +309,8 @@ public class ArchivaDavResourceFactory
|
||||||
{
|
{
|
||||||
resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
|
resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
|
||||||
managedRepositoryAdmin.getManagedRepository(
|
managedRepositoryAdmin.getManagedRepository(
|
||||||
archivaLocator.getRepositoryId() ) );
|
archivaLocator.getRepositoryId() )
|
||||||
|
);
|
||||||
|
|
||||||
String logicalResource = getLogicalResource( archivaLocator, null, false );
|
String logicalResource = getLogicalResource( archivaLocator, null, false );
|
||||||
resourcesInAbsolutePath.add(
|
resourcesInAbsolutePath.add(
|
||||||
|
@ -408,8 +409,8 @@ public class ArchivaDavResourceFactory
|
||||||
catch ( DigesterException de )
|
catch ( DigesterException de )
|
||||||
{
|
{
|
||||||
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||||
"Error occurred while generating checksum files."
|
"Error occurred while generating checksum files." + de.getMessage()
|
||||||
+ de.getMessage() );
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -925,7 +926,8 @@ public class ArchivaDavResourceFactory
|
||||||
return servletAuth.isAuthenticated( request, result ) && servletAuth.isAuthorized( request, securitySession,
|
return servletAuth.isAuthenticated( request, result ) && servletAuth.isAuthorized( request, securitySession,
|
||||||
repositoryId,
|
repositoryId,
|
||||||
WebdavMethodUtil.getMethodPermission(
|
WebdavMethodUtil.getMethodPermission(
|
||||||
request.getMethod() ) );
|
request.getMethod() )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch ( AuthenticationException e )
|
catch ( AuthenticationException e )
|
||||||
{
|
{
|
||||||
|
@ -972,11 +974,23 @@ public class ArchivaDavResourceFactory
|
||||||
RepositoryGroupConfiguration repositoryGroupConfiguration )
|
RepositoryGroupConfiguration repositoryGroupConfiguration )
|
||||||
throws DavException, RepositoryAdminException
|
throws DavException, RepositoryAdminException
|
||||||
{
|
{
|
||||||
|
if ( repositoryGroupConfiguration.getRepositories() == null
|
||||||
|
|| repositoryGroupConfiguration.getRepositories().isEmpty() )
|
||||||
|
{
|
||||||
|
|
||||||
|
return new ArchivaVirtualDavResource( new ArrayList<File>(), //
|
||||||
|
new File( System.getProperty( "appserver.base" ) + "/groups/"
|
||||||
|
+ repositoryGroupConfiguration.getId() ).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
|
||||||
// so use the first one
|
// so use the first one
|
||||||
// FIXME add a method with group in the repository storage
|
// FIXME add a method with group in the repository storage
|
||||||
String firstRepoId = repositoryGroupConfiguration.getRepositories().get( 1 );
|
String firstRepoId = repositoryGroupConfiguration.getRepositories().get( 0 );
|
||||||
|
|
||||||
String path = getLogicalResource( locator, managedRepositoryAdmin.getManagedRepository( firstRepoId ), false );
|
String path = getLogicalResource( locator, managedRepositoryAdmin.getManagedRepository( firstRepoId ), false );
|
||||||
if ( path.startsWith( "/" ) )
|
if ( path.startsWith( "/" ) )
|
||||||
|
@ -1012,7 +1026,8 @@ public class ArchivaDavResourceFactory
|
||||||
{
|
{
|
||||||
File tmpDirectory = new File( SystemUtils.getJavaIoTmpDir(),
|
File tmpDirectory = new File( SystemUtils.getJavaIoTmpDir(),
|
||||||
repositoryGroupConfiguration.getId() + "/"
|
repositoryGroupConfiguration.getId() + "/"
|
||||||
+ repositoryGroupConfiguration.getMergedIndexPath() );
|
+ repositoryGroupConfiguration.getMergedIndexPath()
|
||||||
|
);
|
||||||
if ( !tmpDirectory.exists() )
|
if ( !tmpDirectory.exists() )
|
||||||
{
|
{
|
||||||
synchronized ( tmpDirectory.getAbsolutePath() )
|
synchronized ( tmpDirectory.getAbsolutePath() )
|
||||||
|
@ -1056,7 +1071,8 @@ public class ArchivaDavResourceFactory
|
||||||
repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
|
repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
|
||||||
StringUtils.isEmpty( repoIndexDirectory )
|
StringUtils.isEmpty( repoIndexDirectory )
|
||||||
? ".indexer"
|
? ".indexer"
|
||||||
: repoIndexDirectory ).getAbsolutePath();
|
: repoIndexDirectory
|
||||||
|
).getAbsolutePath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( StringUtils.isEmpty( repoIndexDirectory ) )
|
if ( StringUtils.isEmpty( repoIndexDirectory ) )
|
||||||
|
@ -1096,7 +1112,8 @@ public class ArchivaDavResourceFactory
|
||||||
{
|
{
|
||||||
if ( servletAuth.isAuthorized( activePrincipal, repository,
|
if ( servletAuth.isAuthorized( activePrincipal, repository,
|
||||||
WebdavMethodUtil.getMethodPermission(
|
WebdavMethodUtil.getMethodPermission(
|
||||||
request.getMethod() ) ) )
|
request.getMethod() )
|
||||||
|
) )
|
||||||
{
|
{
|
||||||
mergedRepositoryContents.add( resourceFile );
|
mergedRepositoryContents.add( resourceFile );
|
||||||
log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
|
log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
|
||||||
|
@ -1312,13 +1329,14 @@ public class ArchivaDavResourceFactory
|
||||||
File tempRepoFile = Files.createTempDir();
|
File tempRepoFile = Files.createTempDir();
|
||||||
tempRepoFile.deleteOnExit();
|
tempRepoFile.deleteOnExit();
|
||||||
|
|
||||||
IndexMergerRequest indexMergerRequest = new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
|
IndexMergerRequest indexMergerRequest =
|
||||||
repositoryGroupConfiguration.getMergedIndexPath(),
|
new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
|
||||||
repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory( tempRepoFile )
|
repositoryGroupConfiguration.getMergedIndexPath(),
|
||||||
.temporary( true );
|
repositoryGroupConfiguration.getMergedIndexTtl() ).mergedIndexDirectory(
|
||||||
|
tempRepoFile ).temporary( true );
|
||||||
|
|
||||||
MergedRemoteIndexesTaskRequest taskRequest =
|
MergedRemoteIndexesTaskRequest taskRequest =
|
||||||
new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger);
|
new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger );
|
||||||
|
|
||||||
MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );
|
MergedRemoteIndexesTask job = new MergedRemoteIndexesTask( taskRequest );
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class IndexWriter
|
||||||
writer.println( "ul{list-style:none;}" );
|
writer.println( "ul{list-style:none;}" );
|
||||||
|
|
||||||
StringBuilder relative = new StringBuilder("../../");
|
StringBuilder relative = new StringBuilder("../../");
|
||||||
if ( logicalResource.length() > 0 )
|
if ( logicalResource != null && logicalResource.length() > 0 )
|
||||||
{
|
{
|
||||||
String tmpRelative = StringUtils.replace( logicalResource, "\\", "/" );
|
String tmpRelative = StringUtils.replace( logicalResource, "\\", "/" );
|
||||||
for (int i=0;i<tmpRelative.split("/").length;i++)
|
for (int i=0;i<tmpRelative.split("/").length;i++)
|
||||||
|
@ -109,7 +109,7 @@ public class IndexWriter
|
||||||
writer.println( "<h3>Collection: /" + logicalResource + "</h3>" );
|
writer.println( "<h3>Collection: /" + logicalResource + "</h3>" );
|
||||||
|
|
||||||
//Check if not root
|
//Check if not root
|
||||||
if ( logicalResource.length() > 0 )
|
if ( logicalResource != null && logicalResource.length() > 0 )
|
||||||
{
|
{
|
||||||
File file = new File( logicalResource );
|
File file = new File( logicalResource );
|
||||||
String parentName = file.getParent() == null ? "/" : file.getParent();
|
String parentName = file.getParent() == null ? "/" : file.getParent();
|
||||||
|
|
Loading…
Reference in New Issue