From d1a54e99e844c136f3d91b99351fe4f290d6fdcf Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 26 Sep 2011 16:07:16 +0000 Subject: [PATCH] [MRM-1524] downloading (optionnaly) remote index to display remote artifacts in search results git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1175928 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-configuration/pom.xml | 2 +- .../src/main/mdo/configuration.mdo | 55 ++- .../model/{ => beans}/AbstractRepository.java | 30 +- .../admin/model/beans/ManagedRepository.java | 32 +- .../admin/model/beans/RemoteRepository.java | 38 +- .../repository/RepositoryCommonValidator.java | 2 +- .../remote/DefaultRemoteRepositoryAdmin.java | 15 +- .../utils/RepositoryComparator.java | 2 +- .../scanner/ArchivaAdministrationStub.java | 13 + .../archiva-scheduler-indexing/pom.xml | 81 +++- .../indexing/ArchivaIndexingTaskExecutor.java | 18 - .../DefaultDownloadRemoteIndexScheduler.java | 245 ++++++++++++ .../DownloadRemoteIndexException.java | 33 ++ .../DownloadRemoteIndexScheduler.java | 29 ++ .../indexing/DownloadRemoteIndexTask.java | 373 ++++++++++++++++++ .../DownloadRemoteIndexTaskRequest.java | 115 ++++++ .../resources/META-INF/spring-context.xml | 19 +- .../nexus-maven-repository-index.gz | Bin 0 -> 95880 bytes .../nexus-maven-repository-index.properties | 36 ++ .../nexus-maven-repository-index.zip | Bin 0 -> 201643 bytes .../indexing/DownloadRemoteIndexTaskTest.java | 165 ++++++++ .../META-INF/redback/redback-core.xml | 228 +++++++++++ .../src/test/resources/log4j.xml | 44 +++ .../src/test/resources/spring-context.xml | 62 +++ ...ArchivaRepositoryScanningTaskExecutor.java | 2 +- .../mock/MockArchivaAdministration.java | 13 + .../archiva-rest-services/pom.xml | 1 + .../archiva-web/archiva-webapp/pom.xml | 6 +- .../proxy/ProxyConnectorsAction.java | 2 +- .../EditRemoteRepositoryAction.java | 43 ++ .../jsp/admin/editRemoteRepository.jsp | 6 + .../admin/include/remoteRepositoryForm.jspf | 8 +- pom.xml | 5 + 33 files changed, 1639 insertions(+), 84 deletions(-) rename archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/{ => beans}/AbstractRepository.java (78%) create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexException.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexScheduler.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskRequest.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/index-updates/nexus-maven-repository-index.gz create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/index-updates/nexus-maven-repository-index.properties create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/index-updates/nexus-maven-repository-index.zip create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskTest.java create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/META-INF/redback/redback-core.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/log4j.xml create mode 100644 archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/resources/spring-context.xml diff --git a/archiva-modules/archiva-base/archiva-configuration/pom.xml b/archiva-modules/archiva-base/archiva-configuration/pom.xml index 28c722a03..3cc60f806 100644 --- a/archiva-modules/archiva-base/archiva-configuration/pom.xml +++ b/archiva-modules/archiva-base/archiva-configuration/pom.xml @@ -138,7 +138,7 @@ - 1.3.0 + 1.4.0 src/main/mdo/configuration.mdo diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 97c295f1c..a56c14920 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -403,6 +403,24 @@ default + + refreshCronExpression + 1.0.0+ + String + + When to run the refresh task. + Default is every hour + + 0 0 * * * ? + + + indexDir + 1.0.0+ + String + + The directory for the indexes of this repository. + + @@ -474,7 +492,24 @@ Timeout in seconds for connections to this repository 60 - + + + downloadRemoteIndex + 1.4.0+ + boolean + + Activate download of remote index if remoteIndexUrl is set too. + + false + + + remoteIndexUrl + 1.4.0+ + String + + Remote Index Url : if not starting with http will be relative to the remote repository url. + + @@ -519,24 +554,6 @@ True if this repository should be scanned and processed. true - - indexDir - 1.0.0+ - String - - The directory for the indexes of this repository. - - - - refreshCronExpression - 1.0.0+ - String - - When to run the refresh task. - Default is every hour - - 0 0 * * * ? - retentionCount 1.0.0+ diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/AbstractRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java similarity index 78% rename from archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/AbstractRepository.java rename to archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java index 053068454..4f7ab3656 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/AbstractRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/AbstractRepository.java @@ -1,4 +1,4 @@ -package org.apache.archiva.admin.model; +package org.apache.archiva.admin.model.beans; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -34,6 +34,13 @@ public class AbstractRepository private String layout = "default"; + /** + * default model value + */ + private String cronExpression = "0 0 * * * ?"; + + private String indexDirectory; + public AbstractRepository() { // no op @@ -76,6 +83,25 @@ public class AbstractRepository this.layout = layout; } + public String getCronExpression() + { + return cronExpression; + } + + public void setCronExpression( String cronExpression ) + { + this.cronExpression = cronExpression; + } + + public String getIndexDirectory() + { + return indexDirectory; + } + + public void setIndexDirectory( String indexDirectory ) + { + this.indexDirectory = indexDirectory; + } public int hashCode() { @@ -110,6 +136,8 @@ public class AbstractRepository sb.append( "{id='" ).append( id ).append( '\'' ); sb.append( ", name='" ).append( name ).append( '\'' ); sb.append( ", layout='" ).append( layout ).append( '\'' ); + sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' ); + sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java index 8e4dbcb75..a399660c4 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ManagedRepository.java @@ -19,8 +19,6 @@ package org.apache.archiva.admin.model.beans; * under the License. */ -import org.apache.archiva.admin.model.AbstractRepository; - import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; @@ -42,11 +40,6 @@ public class ManagedRepository private boolean blockRedeployments = false; - /** - * default model value - */ - private String cronExpression = "0 0 * * * ?"; - /** * not need when creating the repo : only available when reading @@ -55,7 +48,6 @@ public class ManagedRepository private boolean scanned = false; - private String indexDirectory; /** * default model value @@ -89,8 +81,8 @@ public class ManagedRepository this.snapshots = snapshots; this.releases = releases; this.blockRedeployments = blockRedeployments; - this.cronExpression = cronExpression; - this.indexDirectory = indexDir; + this.setCronExpression( cronExpression ); + this.setIndexDirectory( indexDir ); this.scanned = scanned; this.daysOlder = daysOlder; this.retentionCount = retentionCount; @@ -144,15 +136,6 @@ public class ManagedRepository this.blockRedeployments = blockRedeployments; } - public String getCronExpression() - { - return cronExpression; - } - - public void setCronExpression( String cronExpression ) - { - this.cronExpression = cronExpression; - } public ManagedRepository getStagingRepository() { @@ -175,15 +158,7 @@ public class ManagedRepository this.scanned = scanned; } - public String getIndexDirectory() - { - return indexDirectory; - } - public void setIndexDirectory( String indexDirectory ) - { - this.indexDirectory = indexDirectory; - } public int getDaysOlder() { @@ -239,15 +214,14 @@ public class ManagedRepository public String toString() { final StringBuilder sb = new StringBuilder(); + sb.append( super.toString() ); sb.append( "ManagedRepository" ); sb.append( "{location='" ).append( location ).append( '\'' ); sb.append( ", snapshots=" ).append( snapshots ); sb.append( ", releases=" ).append( releases ); sb.append( ", blockRedeployments=" ).append( blockRedeployments ); - sb.append( ", cronExpression='" ).append( cronExpression ).append( '\'' ); sb.append( ", stagingRepository=" ).append( stagingRepository ); sb.append( ", scanned=" ).append( scanned ); - sb.append( ", indexDirectory='" ).append( indexDirectory ).append( '\'' ); sb.append( ", daysOlder=" ).append( daysOlder ); sb.append( ", retentionCount=" ).append( retentionCount ); sb.append( ", deleteReleasedSnapshots=" ).append( deleteReleasedSnapshots ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java index 916ddd1d9..b8a789692 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RemoteRepository.java @@ -19,8 +19,6 @@ package org.apache.archiva.admin.model.beans; * under the License. */ -import org.apache.archiva.admin.model.AbstractRepository; - import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; @@ -42,6 +40,17 @@ public class RemoteRepository private int timeout = 60; + /** + * Activate download of remote index if remoteIndexUrl is set too. + */ + private boolean downloadRemoteIndex = false; + + /** + * Remote Index Url : if not starting with http will be relative to the remote repository url. + */ + private String remoteIndexUrl = ".index"; + + public RemoteRepository() { // no op @@ -103,17 +112,40 @@ public class RemoteRepository this.timeout = timeout; } + public boolean isDownloadRemoteIndex() + { + return downloadRemoteIndex; + } + + public void setDownloadRemoteIndex( boolean downloadRemoteIndex ) + { + this.downloadRemoteIndex = downloadRemoteIndex; + } + + public String getRemoteIndexUrl() + { + return remoteIndexUrl; + } + + public void setRemoteIndexUrl( String remoteIndexUrl ) + { + this.remoteIndexUrl = remoteIndexUrl; + } + + @Override public String toString() { final StringBuilder sb = new StringBuilder(); + sb.append( super.toString() ); sb.append( "RemoteRepository" ); sb.append( "{url='" ).append( url ).append( '\'' ); sb.append( ", userName='" ).append( userName ).append( '\'' ); sb.append( ", password='" ).append( password ).append( '\'' ); sb.append( ", timeout=" ).append( timeout ); + sb.append( ", downloadRemoteIndex=" ).append( downloadRemoteIndex ); + sb.append( ", remoteIndexUrl='" ).append( remoteIndexUrl ).append( '\'' ); sb.append( '}' ); - sb.append( super.toString() ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java index 23e9cb3b0..ee5668e03 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/RepositoryCommonValidator.java @@ -18,7 +18,7 @@ package org.apache.archiva.admin.repository; * under the License. */ -import org.apache.archiva.admin.model.AbstractRepository; +import org.apache.archiva.admin.model.beans.AbstractRepository; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.commons.lang.StringUtils; import org.apache.commons.validator.GenericValidator; diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java index 1912cade0..294e3cb90 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java @@ -24,10 +24,10 @@ import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; -import org.apache.commons.lang.StringUtils; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ProxyConnectorConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.commons.lang.StringUtils; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -52,11 +52,16 @@ public class DefaultRemoteRepositoryAdmin List remoteRepositories = new ArrayList(); for ( RemoteRepositoryConfiguration repositoryConfiguration : getArchivaConfiguration().getConfiguration().getRemoteRepositories() ) { - remoteRepositories.add( + RemoteRepository remoteRepository = new RemoteRepository( repositoryConfiguration.getId(), repositoryConfiguration.getName(), repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(), repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(), - repositoryConfiguration.getTimeout() ) ); + repositoryConfiguration.getTimeout() ); + remoteRepository.setDownloadRemoteIndex( repositoryConfiguration.isDownloadRemoteIndex() ); + remoteRepository.setRemoteIndexUrl( repositoryConfiguration.getRemoteIndexUrl() ); + remoteRepository.setCronExpression( repositoryConfiguration.getRefreshCronExpression() ); + remoteRepository.setIndexDirectory( repositoryConfiguration.getIndexDir() ); + remoteRepositories.add( remoteRepository ); } return remoteRepositories; } @@ -186,6 +191,10 @@ public class DefaultRemoteRepositoryAdmin remoteRepositoryConfiguration.setUsername( remoteRepository.getUserName() ); remoteRepositoryConfiguration.setLayout( remoteRepository.getLayout() ); remoteRepositoryConfiguration.setName( remoteRepository.getName() ); + remoteRepositoryConfiguration.setDownloadRemoteIndex( remoteRepository.isDownloadRemoteIndex() ); + remoteRepositoryConfiguration.setRemoteIndexUrl( remoteRepository.getRemoteIndexUrl() ); + remoteRepositoryConfiguration.setRefreshCronExpression( remoteRepository.getCronExpression() ); + remoteRepositoryConfiguration.setIndexDir( remoteRepository.getIndexDirectory() ); return remoteRepositoryConfiguration; } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java index c65c2308d..975f4520f 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java @@ -18,7 +18,7 @@ package org.apache.archiva.admin.repository.utils; * under the License. */ -import org.apache.archiva.admin.model.AbstractRepository; +import org.apache.archiva.admin.model.beans.AbstractRepository; import java.util.Comparator; diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java index a778d2452..671a48598 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java +++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java @@ -24,6 +24,7 @@ import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.FileType; import org.apache.archiva.admin.model.beans.LegacyArtifactPath; import org.apache.archiva.admin.model.beans.OrganisationInformation; +import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.configuration.ArchivaConfiguration; import org.springframework.stereotype.Service; @@ -163,4 +164,16 @@ public class ArchivaAdministrationStub { } + + public UiConfiguration getUiConfiguration() + throws RepositoryAdminException + { + return null; + } + + public void updateUiConfiguration( UiConfiguration uiConfiguration ) + throws RepositoryAdminException + { + //To change body of implemented methods use File | Settings | File Templates. + } } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml index 6bd9b7804..6fb27601e 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/pom.xml @@ -27,6 +27,11 @@ archiva-scheduler-indexing Archiva Scheduler :: Indexing + + + 7.4.5.v20110725 + + org.apache.archiva @@ -48,6 +53,10 @@ com.google.guava guava + + org.apache.commons + commons-compress + javax.inject javax.inject @@ -56,15 +65,85 @@ org.apache.archiva archiva-plexus-bridge + + org.apache.archiva + archiva-proxy-common + + + org.springframework + spring-context + org.slf4j slf4j-api + + org.eclipse.jetty + jetty-server + ${jettyVersion} + test + + + org.eclipse.jetty + jetty-plus + ${jettyVersion} + test + + org.slf4j - slf4j-simple + slf4j-log4j12 + test + + + + org.apache.archiva + archiva-repository-admin-default + test + + + + org.apache.archiva + metadata-store-file + test + + + + org.codehaus.redback + redback-rbac-cached + test + ${redback.version} + + + + org.apache.derby + derby + test + + + + org.apache.maven.wagon + wagon-http test + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.outputDirectory} + ${basedir}/target/appserver-base + ${project.build.outputDirectory} + + + + + + + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java index c465526ae..02302d7d0 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/ArchivaIndexingTaskExecutor.java @@ -255,24 +255,6 @@ public class ArchivaIndexingTaskExecutor throw new TaskExecutionException( "Error occurred while executing indexing task '" + indexingTask + "'", e ); } - finally - { - /* - olamy don't close it anymore as it nullify IndexSearcher - if ( context != null ) - { - try - { - context.close( false ); - } - catch ( IOException e ) - { - log.error( "Error occurred while closing context: " + e.getMessage() ); - throw new TaskExecutionException( "Error occurred while closing context: " + e.getMessage() ); - } - } - */ - } } public void setIndexPacker( IndexPacker indexPacker ) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java new file mode 100644 index 000000000..a3445034e --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DefaultDownloadRemoteIndexScheduler.java @@ -0,0 +1,245 @@ +package org.apache.archiva.scheduler.indexing; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.beans.NetworkProxy; +import org.apache.archiva.admin.model.beans.ProxyConnector; +import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; +import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; +import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; +import org.apache.archiva.common.ArchivaException; +import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; +import org.apache.archiva.configuration.ArchivaConfiguration; +import org.apache.archiva.configuration.ConfigurationEvent; +import org.apache.archiva.configuration.ConfigurationListener; +import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException; +import org.apache.maven.index.updater.IndexUpdater; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.scheduling.TaskScheduler; +import org.springframework.scheduling.support.CronTrigger; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import javax.inject.Inject; +import javax.inject.Named; +import java.io.File; +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +/** + * @author Olivier Lamy + * @since 1.4 + */ +@Service( "downloadRemoteIndexScheduler#default" ) +public class DefaultDownloadRemoteIndexScheduler + implements ConfigurationListener, DownloadRemoteIndexScheduler +{ + + private Logger log = LoggerFactory.getLogger( getClass() ); + + @Inject + @Named( value = "taskScheduler#indexDownloadRemote" ) + private TaskScheduler taskScheduler; + + @Inject + private ArchivaConfiguration archivaConfiguration; + + @Inject + private WagonFactory wagonFactory; + + @Inject + private RemoteRepositoryAdmin remoteRepositoryAdmin; + + @Inject + private ProxyConnectorAdmin proxyConnectorAdmin; + + @Inject + private NetworkProxyAdmin networkProxyAdmin; + + @Inject + private PlexusSisuBridge plexusSisuBridge; + + @Inject + private MavenIndexerUtils mavenIndexerUtils; + + private NexusIndexer nexusIndexer; + + private IndexUpdater indexUpdater; + + // store ids about currently running remote download : updated in DownloadRemoteIndexTask + private List runningRemoteDownloadIds = new CopyOnWriteArrayList(); + + @PostConstruct + public void startup() + throws ArchivaException, RepositoryAdminException, PlexusSisuBridgeException, IOException, + UnsupportedExistingLuceneIndexException, DownloadRemoteIndexException + { + archivaConfiguration.addListener( this ); + // TODO add indexContexts even if null + + // FIXME get this from ArchivaAdministration + String appServerBase = System.getProperty( "appserver.base" ); + + nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); + + indexUpdater = plexusSisuBridge.lookup( IndexUpdater.class ); + + for ( RemoteRepository remoteRepository : remoteRepositoryAdmin.getRemoteRepositories() ) + { + String contextKey = "remote-" + remoteRepository.getId(); + if ( nexusIndexer.getIndexingContexts().get( contextKey ) != null ) + { + continue; + } + // create path + File repoDir = new File( appServerBase, "data/remotes/" + remoteRepository.getId() ); + if ( !repoDir.exists() ) + { + repoDir.mkdirs(); + } + File indexDirectory = new File( repoDir, ".index" ); + if ( !indexDirectory.exists() ) + { + indexDirectory.mkdirs(); + } + nexusIndexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory, + remoteRepository.getUrl(), calculateIndexRemoteUrl( remoteRepository ), + mavenIndexerUtils.getAllIndexCreators() ); + // TODO record jobs from configuration + if ( remoteRepository.isDownloadRemoteIndex() && StringUtils.isNotEmpty( + remoteRepository.getCronExpression() ) ) + { + boolean fullDownload = indexDirectory.list().length == 0; + scheduleDownloadRemote( remoteRepository.getId(), false, fullDownload ); + } + } + + + } + + public void configurationEvent( ConfigurationEvent event ) + { + // TODO remove jobs and add again + } + + + public void scheduleDownloadRemote( String repositoryId, boolean now, boolean fullDownload ) + throws DownloadRemoteIndexException + { + try + { + RemoteRepository remoteRepository = remoteRepositoryAdmin.getRemoteRepository( repositoryId ); + if ( remoteRepository == null ) + { + log.warn( "ignore scheduleDownloadRemote for repo with id {} as not exists", repositoryId ); + return; + } + String networkProxyId = null; + for ( ProxyConnector proxyConnector : proxyConnectorAdmin.getProxyConnectors() ) + { + if ( StringUtils.equals( proxyConnector.getTargetRepoId(), repositoryId ) ) + { + networkProxyId = proxyConnector.getProxyId(); + break; + } + } + + // FIXME add a field networkProxy at the remoteRepositories level : only use for remote index download + + NetworkProxy networkProxy = null; + if ( networkProxyId != null ) + { + for ( NetworkProxy np : networkProxyAdmin.getNetworkProxies() ) + { + if ( StringUtils.equals( np.getId(), networkProxyId ) ) + { + networkProxy = np; + break; + } + } + } + + //archivaConfiguration.getConfiguration().getProxyConnectorAsMap().get( "" ).get( 0 ). + //archivaConfiguration.getConfiguration().getNetworkProxiesAsMap() + + DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest = + new DownloadRemoteIndexTaskRequest().setRemoteRepository( remoteRepository ).setNetworkProxy( + networkProxy ).setFullDownload( fullDownload ).setWagonFactory( wagonFactory ).setNexusIndexer( + nexusIndexer ).setIndexUpdater( indexUpdater ); + + if ( now ) + { + // do it in async + taskScheduler.schedule( + new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), + new Date() ); + } + else + { + + taskScheduler.schedule( + new DownloadRemoteIndexTask( downloadRemoteIndexTaskRequest, this.runningRemoteDownloadIds ), + new CronTrigger( remoteRepository.getCronExpression() ) ); + } + + } + catch ( RepositoryAdminException e ) + { + log.error( e.getMessage(), e ); + throw new DownloadRemoteIndexException( e.getMessage(), e ); + } + } + + protected String calculateIndexRemoteUrl( RemoteRepository remoteRepository ) + { + if ( StringUtils.startsWith( remoteRepository.getRemoteIndexUrl(), "http" ) ) + { + String baseUrl = remoteRepository.getRemoteIndexUrl(); + return baseUrl.endsWith( "/" ) ? StringUtils.substringBeforeLast( baseUrl, "/" ) : baseUrl; + } + String baseUrl = StringUtils.endsWith( remoteRepository.getUrl(), "/" ) ? StringUtils.substringBeforeLast( + remoteRepository.getUrl(), "/" ) : remoteRepository.getUrl(); + + baseUrl = StringUtils.isEmpty( remoteRepository.getRemoteIndexUrl() ) + ? baseUrl + "/.index" + : baseUrl + "/" + remoteRepository.getRemoteIndexUrl(); + return baseUrl; + + } + + public TaskScheduler getTaskScheduler() + { + return taskScheduler; + } + + public void setTaskScheduler( TaskScheduler taskScheduler ) + { + this.taskScheduler = taskScheduler; + } +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexException.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexException.java new file mode 100644 index 000000000..f1f82eff0 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexException.java @@ -0,0 +1,33 @@ +package org.apache.archiva.scheduler.indexing; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @author Olivier Lamy + * @since 1.4 + */ +public class DownloadRemoteIndexException + extends Exception +{ + public DownloadRemoteIndexException( String message, Throwable exception ) + { + super( message, exception ); + } +} + diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexScheduler.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexScheduler.java new file mode 100644 index 000000000..bdb1ab27f --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexScheduler.java @@ -0,0 +1,29 @@ +package org.apache.archiva.scheduler.indexing; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * @author Olivier Lamy + * @since 1.4 + */ +public interface DownloadRemoteIndexScheduler +{ + void scheduleDownloadRemote( String repositoryId, boolean now, boolean fullDownload ) + throws DownloadRemoteIndexException; +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java new file mode 100644 index 000000000..9b9e7fd1c --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTask.java @@ -0,0 +1,373 @@ +package org.apache.archiva.scheduler.indexing; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.admin.model.beans.NetworkProxy; +import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.archiva.proxy.common.WagonFactoryException; +import org.apache.commons.compress.compressors.CompressorException; +import org.apache.commons.io.FileUtils; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexingContext; +import org.apache.maven.index.updater.IndexUpdateRequest; +import org.apache.maven.index.updater.IndexUpdater; +import org.apache.maven.index.updater.ResourceFetcher; +import org.apache.maven.wagon.ConnectionException; +import org.apache.maven.wagon.ResourceDoesNotExistException; +import org.apache.maven.wagon.TransferFailedException; +import org.apache.maven.wagon.Wagon; +import org.apache.maven.wagon.authentication.AuthenticationException; +import org.apache.maven.wagon.authentication.AuthenticationInfo; +import org.apache.maven.wagon.authorization.AuthorizationException; +import org.apache.maven.wagon.events.TransferEvent; +import org.apache.maven.wagon.events.TransferListener; +import org.apache.maven.wagon.proxy.ProxyInfo; +import org.apache.maven.wagon.repository.Repository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.List; + +/** + * @author Olivier Lamy + * @since 1.4 + */ +public class DownloadRemoteIndexTask + implements Runnable +{ + private Logger log = LoggerFactory.getLogger( getClass() ); + + private RemoteRepository remoteRepository; + + private NexusIndexer nexusIndexer; + + private WagonFactory wagonFactory; + + private NetworkProxy networkProxy; + + private boolean fullDownload; + + private List runningRemoteDownloadIds; + + private IndexUpdater indexUpdater; + + public DownloadRemoteIndexTask( DownloadRemoteIndexTaskRequest downloadRemoteIndexTaskRequest, + List runningRemoteDownloadIds ) + { + this.remoteRepository = downloadRemoteIndexTaskRequest.getRemoteRepository(); + this.nexusIndexer = downloadRemoteIndexTaskRequest.getNexusIndexer(); + this.wagonFactory = downloadRemoteIndexTaskRequest.getWagonFactory(); + this.networkProxy = downloadRemoteIndexTaskRequest.getNetworkProxy(); + this.fullDownload = downloadRemoteIndexTaskRequest.isFullDownload(); + this.runningRemoteDownloadIds = runningRemoteDownloadIds; + this.indexUpdater = downloadRemoteIndexTaskRequest.getIndexUpdater(); + } + + public void run() + { + + // so short lock : not sure we need it + synchronized ( this.runningRemoteDownloadIds ) + { + if ( this.runningRemoteDownloadIds.contains( this.remoteRepository.getId() ) ) + { + // skip it as it's running + log.info( "skip download index remote for repo {} it's already running", + this.remoteRepository.getId() ); + return; + } + log.info( "start download remote index for remote repository " + this.remoteRepository.getId() ); + this.runningRemoteDownloadIds.add( this.remoteRepository.getId() ); + } + IndexingContext indexingContext = + nexusIndexer.getIndexingContexts().get( "remote-" + remoteRepository.getId() ); + + // TODO check if null ? normally not as created by DefaultDownloadRemoteIndexScheduler#startup + + // create a temp directory to download files + final File tempIndexDirectory = new File( indexingContext.getIndexDirectoryFile().getParent(), ".tmpIndex" ); + try + { + if ( tempIndexDirectory.exists() ) + { + FileUtils.deleteDirectory( tempIndexDirectory ); + } + tempIndexDirectory.mkdirs(); + String baseIndexUrl = indexingContext.getIndexUpdateUrl(); + + final Wagon wagon = wagonFactory.getWagon( new URL( this.remoteRepository.getUrl() ).getProtocol() ); + // TODO transferListener + wagon.addTransferListener( new DownloadListener() ); + ProxyInfo proxyInfo = null; + if ( this.networkProxy != null ) + { + proxyInfo = new ProxyInfo(); + proxyInfo.setHost( this.networkProxy.getHost() ); + proxyInfo.setPort( this.networkProxy.getPort() ); + proxyInfo.setUserName( this.networkProxy.getUsername() ); + proxyInfo.setPassword( this.networkProxy.getPassword() ); + } + AuthenticationInfo authenticationInfo = null; + if ( this.remoteRepository.getUserName() != null ) + { + authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setUserName( this.remoteRepository.getUserName() ); + authenticationInfo.setPassword( this.remoteRepository.getPassword() ); + } + wagon.connect( new Repository( this.remoteRepository.getId(), baseIndexUrl ), authenticationInfo, + proxyInfo ); + + File indexDirectory = indexingContext.getIndexDirectoryFile(); + if ( !indexDirectory.exists() ) + { + indexDirectory.mkdirs(); + } + + /* + File[] indexFiles = indexDirectory.listFiles( new FileFilter() + { + public boolean accept( File file ) + { + return !file.isDirectory(); + } + } ); + + List indexFileNames = new ArrayList( indexFiles == null ? 0 : indexFiles.length ); + + for ( File f : indexFiles == null ? new File[0] : indexFiles ) + { + indexFileNames.add( f.getName() ); + } + */ + + //List files = wagon.getFileList( "" ); + + // take care about time stamp : no need to rebuild index + // TODO incremental honor fullDownload true !! + // FIXME dont fail all if one file fail ? + /* + for ( String file : files ) + { + if ( !indexFileNames.contains( file ) && StringUtils.endsWith( file, ".gz" ) ) + { + downloadFile( wagon, file, tempIndexDirectory ); + File compressIndexUpdate = new File( tempIndexDirectory, file ); + mergeCompressIndex( indexingContext, compressIndexUpdate, wagon ); + } + }*/ + ResourceFetcher resourceFetcher = new ResourceFetcher() + { + public void connect( String id, String url ) + throws IOException + { + //no op + } + + public void disconnect() + throws IOException + { + // no op + } + + public InputStream retrieve( String name ) + throws IOException, FileNotFoundException + { + try + { + log.debug( "resourceFetcher#retrieve, name:{}", name ); + //TODO check those files are deleted !! + File file = new File( tempIndexDirectory, name ); + if ( file.exists() ) + { + file.delete(); + } + //file.deleteOnExit(); + wagon.get( name, file ); + return new FileInputStream( file ); + } + catch ( AuthorizationException e ) + { + throw new IOException( e.getMessage(), e ); + } + catch ( TransferFailedException e ) + { + throw new IOException( e.getMessage(), e ); + } + catch ( ResourceDoesNotExistException e ) + { + throw new FileNotFoundException( e.getMessage() ); + } + } + }; + + IndexUpdateRequest request = new IndexUpdateRequest( indexingContext, resourceFetcher ); + + this.indexUpdater.fetchAndUpdateIndex( request ); + + + } + catch ( MalformedURLException e ) + { + log.error( e.getMessage(), e ); + throw new RuntimeException( e.getMessage(), e ); + } + catch ( WagonFactoryException e ) + { + log.error( e.getMessage(), e ); + throw new RuntimeException( e.getMessage(), e ); + } + catch ( ConnectionException e ) + { + log.error( e.getMessage(), e ); + throw new RuntimeException( e.getMessage(), e ); + } + catch ( AuthenticationException e ) + { + log.error( e.getMessage(), e ); + throw new RuntimeException( e.getMessage(), e ); + } + catch ( IOException e ) + { + log.error( e.getMessage(), e ); + throw new RuntimeException( e.getMessage(), e ); + } + finally + { + //deleteDirectoryQuiet( tempIndexDirectory ); + this.runningRemoteDownloadIds.remove( this.remoteRepository.getId() ); + } + log.info( "end download remote index for remote repository " + this.remoteRepository.getId() ); + } + + private void deleteDirectoryQuiet( File f ) + { + try + { + FileUtils.deleteDirectory( f ); + } + catch ( IOException e ) + { + log.warn( "skip error delete " + f + ": " + e.getMessage() ); + } + } + + protected void mergeCompressIndex( IndexingContext context, final File compressedIndexUpdate, final Wagon wagon ) + throws IOException, CompressorException + { + + /* + + final File tmpUncompressDirectory = new File( compressedIndexUpdate.getParent(), + StringUtils.substringBeforeLast( compressedIndexUpdate.getName(), + "." ) ); + tmpUncompressDirectory.deleteOnExit(); + final FileOutputStream fos = + new FileOutputStream( new File( tmpUncompressDirectory, compressedIndexUpdate.getName() ) ); + try + { + if ( tmpUncompressDirectory.exists() ) + { + tmpUncompressDirectory.delete(); + } + tmpUncompressDirectory.mkdirs(); + + // gunzip the file to a directory and merge + + // gunzip + final InputStream in = new FileInputStream( compressedIndexUpdate ); + CompressorInputStream cis = + new CompressorStreamFactory().createCompressorInputStream( CompressorStreamFactory.GZIP, in ); + IOUtils.copy( cis, fos ); + in.close(); + fos.flush(); + fos.close(); + // merge + + } + finally + { + IOUtils.closeQuietly( fos ); + //deleteDirectoryQuiet( tmpUncompressDirectory ); + //FileUtils.deleteQuietly( tmpUncompressDirectory ); + } + */ + } + + protected void downloadFile( Wagon wagon, String file, File tempIndexDirectory ) + { + try + { + wagon.get( file, new File( tempIndexDirectory, file ) ); + } + catch ( Exception e ) + { + log.warn( "skip fail to download " + file + ": " + e.getMessage() ); + } + } + + + public static class DownloadListener + implements TransferListener + { + private Logger log = LoggerFactory.getLogger( getClass() ); + + public void transferInitiated( TransferEvent transferEvent ) + { + log.debug( "initiate transfer of {}", transferEvent.getResource().getName() ); + } + + public void transferStarted( TransferEvent transferEvent ) + { + log.debug( "start transfer of {}", transferEvent.getResource().getName() ); + } + + public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) + { + log.debug( "transfer of {} : {}/{}", + Arrays.asList( transferEvent.getResource().getName(), buffer.length, length ).toArray() ); + } + + public void transferCompleted( TransferEvent transferEvent ) + { + log.info( "end of transfer file " + transferEvent.getResource().getName() ); + } + + public void transferError( TransferEvent transferEvent ) + { + log.info( "error of transfer file {}: {}", Arrays.asList( transferEvent.getResource().getName(), + transferEvent.getException().getMessage() ).toArray( + new Object[2] ), transferEvent.getException() ); + } + + public void debug( String message ) + { + log.debug( "transfer debug {}", message ); + } + } + +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskRequest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskRequest.java new file mode 100644 index 000000000..536091036 --- /dev/null +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/java/org/apache/archiva/scheduler/indexing/DownloadRemoteIndexTaskRequest.java @@ -0,0 +1,115 @@ +package org.apache.archiva.scheduler.indexing; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.admin.model.beans.NetworkProxy; +import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.proxy.common.WagonFactory; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.updater.IndexUpdater; + +/** + * @author Olivier Lamy + * @since 1.4 + */ +public class DownloadRemoteIndexTaskRequest +{ + private RemoteRepository remoteRepository; + + private NexusIndexer nexusIndexer; + + private WagonFactory wagonFactory; + + private NetworkProxy networkProxy; + + private boolean fullDownload; + + private IndexUpdater indexUpdater; + + public DownloadRemoteIndexTaskRequest() + { + // no op + } + + public RemoteRepository getRemoteRepository() + { + return remoteRepository; + } + + public DownloadRemoteIndexTaskRequest setRemoteRepository( RemoteRepository remoteRepository ) + { + this.remoteRepository = remoteRepository; + return this; + } + + public NexusIndexer getNexusIndexer() + { + return nexusIndexer; + } + + public DownloadRemoteIndexTaskRequest setNexusIndexer( NexusIndexer nexusIndexer ) + { + this.nexusIndexer = nexusIndexer; + return this; + } + + public WagonFactory getWagonFactory() + { + return wagonFactory; + } + + public DownloadRemoteIndexTaskRequest setWagonFactory( WagonFactory wagonFactory ) + { + this.wagonFactory = wagonFactory; + return this; + } + + public NetworkProxy getNetworkProxy() + { + return networkProxy; + } + + public DownloadRemoteIndexTaskRequest setNetworkProxy( NetworkProxy networkProxy ) + { + this.networkProxy = networkProxy; + return this; + } + + public boolean isFullDownload() + { + return fullDownload; + } + + public DownloadRemoteIndexTaskRequest setFullDownload( boolean fullDownload ) + { + this.fullDownload = fullDownload; + return this; + } + + public IndexUpdater getIndexUpdater() + { + return indexUpdater; + } + + public DownloadRemoteIndexTaskRequest setIndexUpdater( IndexUpdater indexUpdater ) + { + this.indexUpdater = indexUpdater; + return this; + } +} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml index 514ebba08..a462ca4d8 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/main/resources/META-INF/spring-context.xml @@ -20,25 +20,38 @@ + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/task + http://www.springframework.org/schema/task/spring-task-3.0.xsd" + default-lazy-init="false"> - org.sonatype.nexus.index.DefaultNexusIndexer + + org.apache.maven.index.DefaultNexusIndexer + + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/index-updates/nexus-maven-repository-index.gz b/archiva-modules/archiva-scheduler/archiva-scheduler-indexing/src/test/index-updates/nexus-maven-repository-index.gz new file mode 100644 index 0000000000000000000000000000000000000000..1bf73c9dc3b397df5d958f3e037e5f5431860a2a GIT binary patch literal 95880 zcmV)EK)}BriwFP!000000PMX>lVnMjCKNUGY8qx5>7j>irhCe&yQ{mZyCPiQkD3{V z$jHcwsLIF;(jzlV5Ekgu-73t@yv@ubBT5oP5J3=O#THhxoE3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