diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-01-31 22:49:06 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-01-31 22:49:06 +0100 |
commit | 21220fcd57d228a7a87694998e354493e92eb978 (patch) | |
tree | 19b73236d4208233b687254b14629ec56bb17931 /archiva-modules/archiva-scheduler | |
parent | 847727d57d17b35b108063b45999cff6d506da10 (diff) | |
download | archiva-21220fcd57d228a7a87694998e354493e92eb978.tar.gz archiva-21220fcd57d228a7a87694998e354493e92eb978.zip |
Starting refactoring of proxy handling.
Diffstat (limited to 'archiva-modules/archiva-scheduler')
4 files changed, 66 insertions, 74 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/pom.xml index f1f04f2e9..fe377f571 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/pom.xml @@ -58,7 +58,7 @@ </dependency> <dependency> <groupId>org.apache.archiva</groupId> - <artifactId>archiva-proxy-common</artifactId> + <artifactId>archiva-proxy-maven</artifactId> </dependency> <dependency> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DefaultDownloadRemoteIndexScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DefaultDownloadRemoteIndexScheduler.java index 685478830..2496c1d81 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DefaultDownloadRemoteIndexScheduler.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DefaultDownloadRemoteIndexScheduler.java @@ -18,16 +18,16 @@ package org.apache.archiva.scheduler.indexing.maven; * under the License. */ +import org.apache.archiva.proxy.ProxyRegistry; +import org.apache.archiva.proxy.model.NetworkProxy; import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexException; import org.apache.archiva.scheduler.indexing.DownloadRemoteIndexScheduler; import org.apache.archiva.admin.model.RepositoryAdminException; -import org.apache.archiva.admin.model.beans.NetworkProxy; -import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ConfigurationEvent; import org.apache.archiva.configuration.ConfigurationListener; import org.apache.archiva.indexer.UnsupportedBaseContextException; -import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.archiva.proxy.maven.WagonFactory; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.features.RemoteIndexFeature; import org.apache.commons.lang.StringUtils; @@ -72,14 +72,14 @@ public class DefaultDownloadRemoteIndexScheduler private WagonFactory wagonFactory; @Inject - private NetworkProxyAdmin networkProxyAdmin; - - @Inject private IndexUpdater indexUpdater; @Inject private IndexPacker indexPacker; + @Inject + private ProxyRegistry proxyRegistry; + // store ids about currently running remote download : updated in DownloadRemoteIndexTask private List<String> runningRemoteDownloadIds = new CopyOnWriteArrayList<String>(); @@ -124,81 +124,73 @@ public class DefaultDownloadRemoteIndexScheduler public void scheduleDownloadRemote( String repositoryId, boolean now, boolean fullDownload ) throws DownloadRemoteIndexException { - try - { - org.apache.archiva.repository.RemoteRepository remoteRepo = repositoryRegistry.getRemoteRepository(repositoryId); + org.apache.archiva.repository.RemoteRepository remoteRepo = repositoryRegistry.getRemoteRepository(repositoryId); - if ( remoteRepo == null ) - { - log.warn( "ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId ); - return; - } - if (!remoteRepo.supportsFeature(RemoteIndexFeature.class)) { - log.warn("ignore scheduleDownloadRemote for repo with id {}. Does not support remote index.", repositoryId); - return; - } - RemoteIndexFeature rif = remoteRepo.getFeature(RemoteIndexFeature.class).get(); - NetworkProxy networkProxy = null; - if ( StringUtils.isNotBlank( rif.getProxyId() ) ) + if ( remoteRepo == null ) + { + log.warn( "ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId ); + return; + } + if (!remoteRepo.supportsFeature(RemoteIndexFeature.class)) { + log.warn("ignore scheduleDownloadRemote for repo with id {}. Does not support remote index.", repositoryId); + return; + } + RemoteIndexFeature rif = remoteRepo.getFeature(RemoteIndexFeature.class).get(); + NetworkProxy networkProxy = null; + if ( StringUtils.isNotBlank( rif.getProxyId() ) ) + { + networkProxy = proxyRegistry.getNetworkProxy( rif.getProxyId() ); + if ( networkProxy == null ) { - networkProxy = networkProxyAdmin.getNetworkProxy( rif.getProxyId() ); - if ( networkProxy == null ) - { - log.warn( - "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", - rif.getProxyId() ); - } + log.warn( + "your remote repository is configured to download remote index trought a proxy we cannot find id:{}", + rif.getProxyId() ); } + } - DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() // - .setRemoteRepository( remoteRepo ) // - .setNetworkProxy( networkProxy ) // - .setFullDownload( fullDownload ) // - .setWagonFactory( wagonFactory ) // - .setIndexUpdater( indexUpdater ) // - .setIndexPacker( this.indexPacker ); + DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = new DownloadRemoteIndexTaskRequest() // + .setRemoteRepository( remoteRepo ) // + .setNetworkProxy( networkProxy ) // + .setFullDownload( fullDownload ) // + .setWagonFactory( wagonFactory ) // + .setIndexUpdater( indexUpdater ) // + .setIndexPacker( this.indexPacker ); - if ( now ) + if ( now ) + { + log.info( "schedule download remote index for repository {}", remoteRepo.getId() ); + // do it now + taskScheduler.schedule( + new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), + new Date() ); + } + else + { + log.info( "schedule download remote index for repository {} with cron expression {}", + remoteRepo.getId(), remoteRepo.getSchedulingDefinition()); + try { - log.info( "schedule download remote index for repository {}", remoteRepo.getId() ); - // do it now + CronTrigger cronTrigger = new CronTrigger( remoteRepo.getSchedulingDefinition()); taskScheduler.schedule( new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), - new Date() ); + cronTrigger ); } - else + catch ( IllegalArgumentException e ) { - log.info( "schedule download remote index for repository {} with cron expression {}", - remoteRepo.getId(), remoteRepo.getSchedulingDefinition()); - try - { - CronTrigger cronTrigger = new CronTrigger( remoteRepo.getSchedulingDefinition()); - taskScheduler.schedule( - new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), - cronTrigger ); - } - catch ( IllegalArgumentException e ) - { - log.warn( "Unable to schedule remote index download: {}", e.getLocalizedMessage() ); - } - - if ( rif.isDownloadRemoteIndexOnStartup() ) - { - log.info( - "remote repository {} configured with downloadRemoteIndexOnStartup schedule now a download", - remoteRepo.getId() ); - taskScheduler.schedule( - new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), - new Date() ); - } + log.warn( "Unable to schedule remote index download: {}", e.getLocalizedMessage() ); } + if ( rif.isDownloadRemoteIndexOnStartup() ) + { + log.info( + "remote repository {} configured with downloadRemoteIndexOnStartup schedule now a download", + remoteRepo.getId() ); + taskScheduler.schedule( + new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), + new Date() ); + } } - catch ( RepositoryAdminException e ) - { - log.error( e.getMessage(), e ); - throw new DownloadRemoteIndexException( e.getMessage(), e ); - } + } public TaskScheduler getTaskScheduler() diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTask.java index f141f43a5..3f794019e 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTask.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTask.java @@ -18,9 +18,9 @@ package org.apache.archiva.scheduler.indexing.maven; * under the License. */ -import org.apache.archiva.admin.model.beans.NetworkProxy; -import org.apache.archiva.proxy.common.WagonFactory; -import org.apache.archiva.proxy.common.WagonFactoryRequest; +import org.apache.archiva.proxy.maven.WagonFactory; +import org.apache.archiva.proxy.maven.WagonFactoryRequest; +import org.apache.archiva.proxy.model.NetworkProxy; import org.apache.archiva.repository.PasswordCredentials; import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RepositoryException; diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTaskRequest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTaskRequest.java index 732bc7ed8..784709345 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTaskRequest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing-maven2/src/main/java/org/apache/archiva/scheduler/indexing/maven/DownloadRemoteIndexTaskRequest.java @@ -18,8 +18,8 @@ package org.apache.archiva.scheduler.indexing.maven; * under the License. */ -import org.apache.archiva.admin.model.beans.NetworkProxy; -import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.archiva.proxy.maven.WagonFactory; +import org.apache.archiva.proxy.model.NetworkProxy; import org.apache.archiva.repository.RemoteRepository; import org.apache.maven.index.packer.IndexPacker; import org.apache.maven.index.updater.IndexUpdater; |