diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-11-01 15:38:42 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-11-01 15:38:42 +0100 |
commit | 32ff2ca265ac92be20f2941c7d4a291834e950f9 (patch) | |
tree | f135df2d76d4b2cd11cba93f34337be4102ed841 /archiva-modules/archiva-scheduler/archiva-scheduler-repository | |
parent | 9469c1b67f5a667b99b1810ddd95642164ba2ec3 (diff) | |
download | archiva-32ff2ca265ac92be20f2941c7d4a291834e950f9.tar.gz archiva-32ff2ca265ac92be20f2941c7d4a291834e950f9.zip |
Adapting the scheduler to the new repository api
Diffstat (limited to 'archiva-modules/archiva-scheduler/archiva-scheduler-repository')
6 files changed, 30 insertions, 18 deletions
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml index 881d68981..51b3a2c02 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml @@ -89,7 +89,6 @@ <dependency> <groupId>org.apache.archiva</groupId> <artifactId>archiva-repository-layer</artifactId> - <scope>test</scope> <exclusions> <exclusion> <groupId>commons-logging</groupId> diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java index 1ac363cd9..c3178eb11 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/main/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutor.java @@ -19,8 +19,8 @@ package org.apache.archiva.scheduler.repository; * under the License. */ +import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.admin.model.RepositoryAdminException; -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; @@ -28,6 +28,7 @@ import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics; import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager; +import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; import org.apache.archiva.repository.scanner.RepositoryScanStatistics; import org.apache.archiva.repository.scanner.RepositoryScanner; @@ -58,6 +59,9 @@ public class ArchivaRepositoryScanningTaskExecutor private Logger log = LoggerFactory.getLogger( ArchivaRepositoryScanningTaskExecutor.class ); @Inject + RepositoryRegistry repositoryRegistry; + + @Inject private ManagedRepositoryAdmin managedRepositoryAdmin; @Inject @@ -107,7 +111,7 @@ public class ArchivaRepositoryScanningTaskExecutor throw new TaskExecutionException( "Unable to execute RepositoryTask with blank repository Id." ); } - ManagedRepository arepo = managedRepositoryAdmin.getManagedRepository( repoId ); + ManagedRepository arepo = repositoryRegistry.getManagedRepository( repoId ); // execute consumers on resource file if set if ( task.getResourceFile() != null ) diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockManagedRepositoryAdmin.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockManagedRepositoryAdmin.java index d8dd8f38b..22aea17f8 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockManagedRepositoryAdmin.java @@ -29,6 +29,7 @@ import org.apache.maven.index.context.IndexingContext; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -52,10 +53,10 @@ public class MockManagedRepositoryAdmin { // TODO add staging repo information back too ManagedRepository repo = - new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), + new ManagedRepository( Locale.getDefault( ), repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(), repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(), - repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getRetentionTime(), + repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getRetentionPeriod(), repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), true ); managedRepos.add( repo ); @@ -126,4 +127,10 @@ public class MockManagedRepositoryAdmin { return null; } + + @Override + public IndexingContext createIndexContext( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryAdminException + { + return null; + } } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java index 18902975d..9b31305ca 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/AbstractArchivaRepositoryScanningTaskExecutorTest.java @@ -26,6 +26,8 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager; import org.apache.archiva.mock.MockRepositorySessionFactory; import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutor; +import org.apache.archiva.repository.ManagedRepository; +import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.codehaus.plexus.util.FileUtils; import org.junit.After; @@ -60,6 +62,9 @@ public abstract class AbstractArchivaRepositoryScanningTaskExecutorTest extends TestCase { @Inject + RepositoryRegistry repositoryRegistry; + + @Inject @Named( value = "taskExecutor#test-repository-scanning" ) protected TaskExecutor taskExecutor; @@ -134,8 +139,10 @@ public abstract class AbstractArchivaRepositoryScanningTaskExecutorTest repositoryConfiguration.setId( TEST_REPO_ID ); repositoryConfiguration.setName( "Test Repository" ); repositoryConfiguration.setLocation( repoDir.toAbsolutePath().toString() ); - archivaConfig.getConfiguration().getManagedRepositories().clear(); - archivaConfig.getConfiguration().addManagedRepository( repositoryConfiguration ); + for ( ManagedRepository repo : repositoryRegistry.getManagedRepositories()) { + repositoryRegistry.removeRepository( repo ); + } + repositoryRegistry.putRepository( repositoryConfiguration ); metadataRepository = mock( MetadataRepository.class ); diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java index 2de47a1c3..96376736e 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java @@ -19,14 +19,13 @@ package org.apache.archiva.scheduler.repository; * under the License. */ -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.consumers.AbstractMonitoredConsumer; import org.apache.archiva.consumers.ConsumerException; import org.apache.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContentFactory; -import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.layout.LayoutException; import org.springframework.stereotype.Service; @@ -80,14 +79,7 @@ public class TestConsumer { consumed.clear(); - try - { - this.repository = factory.getManagedRepositoryContent( repository.getId() ); - } - catch ( RepositoryException e ) - { - throw new ConsumerException( e.getMessage(), e ); - } + this.repository = repository.getContent(); } @Override diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/spring-context.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/spring-context.xml index 4f499089c..4b4b0dfa6 100755 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/resources/spring-context.xml @@ -28,7 +28,10 @@ default-lazy-init="false"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.metadata.repository"/> + <context:component-scan base-package="org.apache.archiva.metadata.repository,org.apache.archiva.repository.content.maven2"/> + + <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" /> + <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" /> <bean name="managedRepoAdmin#test" class="org.apache.archiva.mock.MockManagedRepositoryAdmin"> <property name="archivaConfiguration" ref="archivaConfiguration#test-repository-scanning"/> |