mirror of https://github.com/apache/archiva.git
[MRM-1693] exposing index downloaded from remote repositories
pack index. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1398259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac5d5d5f47
commit
b0b8c3c08a
|
@ -36,6 +36,7 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.apache.maven.index.NexusIndexer;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
|
||||
import org.apache.maven.index.packer.IndexPacker;
|
||||
import org.apache.maven.index.updater.IndexUpdater;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -92,6 +93,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
|||
|
||||
private IndexUpdater indexUpdater;
|
||||
|
||||
private IndexPacker indexPacker;
|
||||
|
||||
// store ids about currently running remote download : updated in DownloadRemoteIndexTask
|
||||
private List<String> runningRemoteDownloadIds = new CopyOnWriteArrayList<String>();
|
||||
|
||||
|
@ -107,6 +110,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
|||
|
||||
indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class );
|
||||
|
||||
this.indexPacker = plexusSisuBridge.lookup( IndexPacker.class );
|
||||
|
||||
for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() )
|
||||
{
|
||||
String contextKey = "remote-" + remoteRepository.getId();
|
||||
|
@ -176,7 +181,8 @@ public class DefaultDownloadRemoteIndexScheduler
|
|||
DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest =
|
||||
new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy(
|
||||
networkProxy ).setFullDownload( fullDownload ).setWagonFactory(
|
||||
wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater( indexUpdater );
|
||||
wagonFactory ).setRemoteRepositoryAdmin( remoteRepositoryAdmin ).setIndexUpdater(
|
||||
indexUpdater ).setIndexPacker( this.indexPacker );
|
||||
|
||||
if ( now )
|
||||
{
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.apache.archiva.proxy.common.WagonFactoryException;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.time.StopWatch;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.apache.maven.index.packer.IndexPacker;
|
||||
import org.apache.maven.index.packer.IndexPackingRequest;
|
||||
import org.apache.maven.index.updater.IndexUpdateRequest;
|
||||
import org.apache.maven.index.updater.IndexUpdater;
|
||||
import org.apache.maven.index.updater.ResourceFetcher;
|
||||
|
@ -78,6 +80,8 @@ public class DownloadRemoteIndexTask
|
|||
|
||||
private IndexUpdater indexUpdater;
|
||||
|
||||
private IndexPacker indexPacker;
|
||||
|
||||
public DownloadRemoteIndexTask( DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest,
|
||||
List<String> runningRemoteDownloadIds )
|
||||
{
|
||||
|
@ -88,6 +92,7 @@ public class DownloadRemoteIndexTask
|
|||
this.runningRemoteDownloadIds = runningRemoteDownloadIds;
|
||||
this.indexUpdater = downloadRemoteIndexTaskRequest.getIndexUpdater();
|
||||
this.remoteRepositoryAdmin = downloadRemoteIndexTaskRequest.getRemoteRepositoryAdmin();
|
||||
this.indexPacker = downloadRemoteIndexTaskRequest.getIndexPacker();
|
||||
}
|
||||
|
||||
public void run()
|
||||
|
@ -170,6 +175,13 @@ public class DownloadRemoteIndexTask
|
|||
stopWatch.stop();
|
||||
log.info( "time to download remote repository index for repository {}: {} s", this.remoteRepository.getId(),
|
||||
( stopWatch.getTime() / 1000 ) );
|
||||
|
||||
// index packing optionnal ??
|
||||
IndexPackingRequest indexPackingRequest =
|
||||
new IndexPackingRequest( indexingContext, indexingContext.getIndexDirectoryFile() );
|
||||
indexPacker.packIndex( indexPackingRequest );
|
||||
indexingContext.updateTimestamp( true );
|
||||
|
||||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.beans.RemoteRepository;
|
|||
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
|
||||
import org.apache.archiva.proxy.common.WagonFactory;
|
||||
import org.apache.maven.index.NexusIndexer;
|
||||
import org.apache.maven.index.packer.IndexPacker;
|
||||
import org.apache.maven.index.updater.IndexUpdater;
|
||||
|
||||
/**
|
||||
|
@ -43,6 +44,8 @@ public class DownloadRemoteIndexTaskRequest
|
|||
|
||||
private IndexUpdater indexUpdater;
|
||||
|
||||
private IndexPacker indexPacker;
|
||||
|
||||
public DownloadRemoteIndexTaskRequest()
|
||||
{
|
||||
// no op
|
||||
|
@ -114,4 +117,15 @@ public class DownloadRemoteIndexTaskRequest
|
|||
this.remoteRepositoryAdmin = remoteRepositoryAdmin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexPacker getIndexPacker()
|
||||
{
|
||||
return indexPacker;
|
||||
}
|
||||
|
||||
public DownloadRemoteIndexTaskRequest setIndexPacker( IndexPacker indexPacker )
|
||||
{
|
||||
this.indexPacker = indexPacker;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue