From 4325788c50c326d95dbcfc4ab3dff0771104bb01 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 15 Sep 2011 14:00:51 +0000 Subject: [PATCH] [MRM-1509] change xmlrpc to use new repository administration management api git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1171102 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-xmlrpc-services/pom.xml | 5 + .../services/AdministrationServiceImpl.java | 153 +++++++----------- .../AdministrationServiceImplTest.java | 84 +++++----- 3 files changed, 112 insertions(+), 130 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml index 8a5ccc703..bcc977693 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/pom.xml @@ -102,6 +102,11 @@ archiva-repository-admin-default test + + org.apache.archiva + archiva-configuration + runtime + diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index b7b0004d7..aa66d2a70 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -21,7 +21,11 @@ package org.apache.archiva.web.xmlrpc.services; import org.apache.archiva.admin.model.AuditInformation; import org.apache.archiva.admin.model.RepositoryAdminException; +import org.apache.archiva.admin.model.admin.ArchivaAdministration; +import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; +import org.apache.archiva.admin.model.proxyconnector.ProxyConnector; +import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; @@ -42,12 +46,6 @@ import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository; import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.Configuration; -import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; -import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; -import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.model.VersionedReference; @@ -56,7 +54,6 @@ import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.RepositoryContentFactory; import org.apache.maven.archiva.repository.RepositoryException; import org.apache.maven.archiva.repository.RepositoryNotFoundException; -import org.codehaus.plexus.registry.RegistryException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,8 +75,6 @@ public class AdministrationServiceImpl { protected Logger log = LoggerFactory.getLogger( getClass() ); - private ArchivaConfiguration archivaConfiguration; - private RepositoryContentConsumers repoConsumersUtil; private RepositoryContentFactory repoFactory; @@ -102,13 +97,20 @@ public class AdministrationServiceImpl private RemoteRepositoryAdmin remoteRepositoryAdmin; + private ArchivaAdministration archivaAdministration; + + private ProxyConnectorAdmin proxyConnectorAdmin; + + private RepositoryGroupAdmin repositoryGroupAdmin; + private static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$"; private static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$"; private static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&=\\\\]+$"; - public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, + public AdministrationServiceImpl( ArchivaAdministration archivaAdministration, + RepositoryContentConsumers repoConsumersUtil, RepositoryContentFactory repoFactory, RepositorySessionFactory repositorySessionFactory, RepositoryArchivaTaskScheduler repositoryTaskScheduler, @@ -116,9 +118,10 @@ public class AdministrationServiceImpl RepositoryStatisticsManager repositoryStatisticsManager, RepositoryMerger repositoryMerger, AuditListener auditListener, ManagedRepositoryAdmin managedRepositoryAdmin, - RemoteRepositoryAdmin remoteRepositoryAdmin ) + RemoteRepositoryAdmin remoteRepositoryAdmin, + ProxyConnectorAdmin proxyConnectorAdmin, + RepositoryGroupAdmin repositoryGroupAdmin ) { - this.archivaConfiguration = archivaConfig; this.repoConsumersUtil = repoConsumersUtil; this.repoFactory = repoFactory; this.repositoryTaskScheduler = repositoryTaskScheduler; @@ -129,6 +132,9 @@ public class AdministrationServiceImpl this.auditListener = auditListener; this.managedRepositoryAdmin = managedRepositoryAdmin; this.remoteRepositoryAdmin = remoteRepositoryAdmin; + this.archivaAdministration = archivaAdministration; + this.proxyConnectorAdmin = proxyConnectorAdmin; + this.repositoryGroupAdmin = repositoryGroupAdmin; } /** @@ -171,21 +177,30 @@ public class AdministrationServiceImpl throw new Exception( "Invalid repository consumer." ); } - Configuration config = archivaConfiguration.getConfiguration(); - RepositoryScanningConfiguration repoScanningConfig = config.getRepositoryScanning(); - if ( isKnownContentConsumer ) { - repoScanningConfig.addKnownContentConsumer( consumerId ); + if ( enable ) + { + archivaAdministration.addKnownContentConsumer( consumerId, getAuditInformation() ); + } + else + { + archivaAdministration.removeKnownContentConsumer( consumerId, getAuditInformation() ); + } + } else { - repoScanningConfig.addInvalidContentConsumer( consumerId ); + if ( enable ) + { + archivaAdministration.addInvalidContentConsumer( consumerId, getAuditInformation() ); + } + else + { + archivaAdministration.removeInvalidContentConsumer( consumerId, getAuditInformation() ); + } } - config.setRepositoryScanning( repoScanningConfig ); - saveConfiguration( config ); - return true; } @@ -197,8 +212,8 @@ public class AdministrationServiceImpl { // TODO: remove duplication with web - Configuration config = archivaConfiguration.getConfiguration(); - ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId ); + org.apache.archiva.admin.model.managed.ManagedRepository repoConfig = + managedRepositoryAdmin.getManagedRepository( repoId ); if ( repoConfig == null ) { @@ -266,8 +281,7 @@ public class AdministrationServiceImpl public Boolean executeRepositoryScanner( String repoId ) throws Exception { - Configuration config = archivaConfiguration.getConfiguration(); - if ( config.findManagedRepositoryById( repoId ) == null ) + if ( managedRepositoryAdmin.getManagedRepository( repoId ) == null ) { throw new Exception( "Repository does not exist." ); } @@ -344,23 +358,6 @@ public class AdministrationServiceImpl return remoteRepos; } - private void saveConfiguration( Configuration config ) - throws Exception - { - try - { - archivaConfiguration.save( config ); - } - catch ( RegistryException e ) - { - throw new Exception( "Error occurred in the registry." ); - } - catch ( IndeterminateConfigurationException e ) - { - throw new Exception( "Error occurred while saving the configuration." ); - } - } - public Boolean addManagedRepository( String repoId, String layout, String name, String location, boolean blockRedeployments, boolean releasesIncluded, boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression, @@ -370,10 +367,10 @@ public class AdministrationServiceImpl org.apache.archiva.admin.model.managed.ManagedRepository repository = new org.apache.archiva.admin.model.managed.ManagedRepository( repoId, name, location, layout, - snapshotsIncluded, releasesIncluded, - blockRedeployments, cronExpression, null, - false, daysOlder, retentionCount, - deleteReleasedSnapshots ); + snapshotsIncluded, releasesIncluded, + blockRedeployments, cronExpression, null, + false, daysOlder, retentionCount, + deleteReleasedSnapshots ); return managedRepositoryAdmin.addManagedRepository( repository, stageRepoNeeded, getAuditInformation() ); } @@ -381,9 +378,9 @@ public class AdministrationServiceImpl public Boolean deleteManagedRepository( String repoId ) throws Exception { - Configuration config = archivaConfiguration.getConfiguration(); - ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repoId ); + org.apache.archiva.admin.model.managed.ManagedRepository repository = + managedRepositoryAdmin.getManagedRepository( repoId ); if ( repository == null ) { @@ -402,16 +399,7 @@ public class AdministrationServiceImpl { repositorySession.close(); } - config.removeManagedRepository( repository ); - - try - { - saveConfiguration( config ); - } - catch ( Exception e ) - { - throw new Exception( "Error saving configuration for delete action" + e.getMessage() ); - } + managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation(), false ); File dir = new File( repository.getLocation() ); if ( !FileUtils.deleteQuietly( dir ) ) @@ -419,16 +407,16 @@ public class AdministrationServiceImpl throw new IOException( "Cannot delete repository " + dir ); } - List proxyConnectors = config.getProxyConnectors(); - for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors ) + List proxyConnectors = proxyConnectorAdmin.getProxyConnectors(); + for ( ProxyConnector proxyConnector : proxyConnectors ) { if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) ) { - archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector ); + proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation() ); } } - Map> repoToGroupMap = archivaConfiguration.getConfiguration().getRepositoryToGroupMap(); + Map> repoToGroupMap = repositoryGroupAdmin.getRepositoryToGroupMap(); if ( repoToGroupMap != null ) { if ( repoToGroupMap.containsKey( repository.getId() ) ) @@ -436,8 +424,8 @@ public class AdministrationServiceImpl List repoGroups = repoToGroupMap.get( repository.getId() ); for ( String repoGroup : repoGroups ) { - archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( - repository.getId() ); + repositoryGroupAdmin.deleteRepositoryFromGroup( repoGroup, repository.getId(), + getAuditInformation() ); } } } @@ -448,9 +436,9 @@ public class AdministrationServiceImpl public Boolean deleteManagedRepositoryContent( String repoId ) throws Exception { - Configuration config = archivaConfiguration.getConfiguration(); - ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repoId ); + org.apache.archiva.admin.model.managed.ManagedRepository repository = + managedRepositoryAdmin.getManagedRepository( repoId ); if ( repository == null ) { @@ -491,8 +479,8 @@ public class AdministrationServiceImpl public ManagedRepository getManagedRepository( String repoId ) throws Exception { - Configuration config = archivaConfiguration.getConfiguration(); - ManagedRepositoryConfiguration managedRepository = config.findManagedRepositoryById( repoId ); + org.apache.archiva.admin.model.managed.ManagedRepository managedRepository = + managedRepositoryAdmin.getManagedRepository( repoId ); if ( managedRepository == null ) { throw new Exception( "A repository with that id does not exist" ); @@ -508,11 +496,10 @@ public class AdministrationServiceImpl throws Exception { String stagingId = repoId + STAGE; - ManagedRepositoryConfiguration repoConfig; - ManagedRepositoryConfiguration stagingConfig; + org.apache.archiva.admin.model.managed.ManagedRepository repoConfig; + org.apache.archiva.admin.model.managed.ManagedRepository stagingConfig; - Configuration config = archivaConfiguration.getConfiguration(); - repoConfig = config.findManagedRepositoryById( repoId ); + repoConfig = managedRepositoryAdmin.getManagedRepository( repoId ); log.debug( "Retrieved repository configuration for repo '" + repoId + "'" ); @@ -522,7 +509,7 @@ public class AdministrationServiceImpl MetadataRepository metadataRepository = repositorySession.getRepository(); if ( repoConfig != null ) { - stagingConfig = config.findManagedRepositoryById( stagingId ); + stagingConfig = managedRepositoryAdmin.getManagedRepository( stagingId ); if ( stagingConfig != null ) { @@ -631,7 +618,7 @@ public class AdministrationServiceImpl } // todo: setting userid of audit event - private AuditEvent createAuditEvent( ManagedRepositoryConfiguration repoConfig ) + private AuditEvent createAuditEvent( org.apache.archiva.admin.model.managed.ManagedRepository repoConfig ) { AuditEvent event = new AuditEvent(); @@ -664,26 +651,6 @@ public class AdministrationServiceImpl repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots ); } - private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository ) - { - ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration(); - stagingRepository.setId( repository.getId() + "-stage" ); - stagingRepository.setLayout( repository.getLayout() ); - stagingRepository.setName( repository.getName() + "-stage" ); - stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() ); - stagingRepository.setDaysOlder( repository.getDaysOlder() ); - stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() ); - stagingRepository.setIndexDir( repository.getIndexDir() ); - String path = repository.getLocation(); - int lastIndex = path.lastIndexOf( '/' ); - stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() ); - stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() ); - stagingRepository.setReleases( repository.isReleases() ); - stagingRepository.setRetentionCount( repository.getRetentionCount() ); - stagingRepository.setScanned( repository.isScanned() ); - stagingRepository.setSnapshots( repository.isSnapshots() ); - return stagingRepository; - } // FIXME find a way to get user id and adress private AuditInformation getAuditInformation() diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index cfedde318..b57b01214 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -22,7 +22,10 @@ package org.apache.archiva.web.xmlrpc.services; import junit.framework.TestCase; import net.sf.beanlib.provider.replicator.BeanReplicator; import org.apache.archiva.admin.repository.RepositoryCommonValidator; +import org.apache.archiva.admin.repository.admin.DefaultArchivaAdministration; +import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin; import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin; +import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin; import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; @@ -65,7 +68,6 @@ import org.easymock.classextension.MockClassControl; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -162,7 +164,11 @@ public class AdministrationServiceImplTest private DefaultRemoteRepositoryAdmin remoteRepositoryAdmin; - private ApplicationContext applicationContext; + private DefaultArchivaAdministration archivaAdministration; + + private DefaultProxyConnectorAdmin proxyConnectorAdmin; + + private DefaultRepositoryGroupAdmin repositoryGroupAdmin; @Before public void setUp() @@ -243,11 +249,23 @@ public class AdministrationServiceImplTest remoteRepositoryAdmin.setRepositoryCommonValidator( repositoryCommonValidator ); - service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, + archivaAdministration = new DefaultArchivaAdministration(); + archivaAdministration.setArchivaConfiguration( archivaConfig ); + archivaAdministration.setRegistry( registry ); + + proxyConnectorAdmin = new DefaultProxyConnectorAdmin(); + proxyConnectorAdmin.setArchivaConfiguration( archivaConfig ); + proxyConnectorAdmin.setRegistry( registry ); + + repositoryGroupAdmin = new DefaultRepositoryGroupAdmin(); + repositoryGroupAdmin.setArchivaConfiguration( archivaConfig ); + repositoryGroupAdmin.setRegistry( registry ); + + service = new AdministrationServiceImpl( archivaAdministration, repoConsumersUtil, repositoryFactory, repositorySessionFactory, repositoryTaskScheduler, Collections.singletonList( listener ), repositoryStatisticsManager, repositoryMerger, auditListener, managedRepositoryAdmin, - remoteRepositoryAdmin ); + remoteRepositoryAdmin, proxyConnectorAdmin, repositoryGroupAdmin ); } /* Tests for repository consumers */ @@ -288,11 +306,7 @@ public class AdministrationServiceImplTest recordRepoConsumers(); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); - - config.setRepositoryScanning( repoScanning ); - configControl.setMatcher( MockControl.ALWAYS_MATCHER ); - configControl.setVoidCallable(); + configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 5 ); archivaConfig.save( config ); archivaConfigControl.setVoidCallable(); @@ -331,11 +345,7 @@ public class AdministrationServiceImplTest recordRepoConsumers(); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); - - config.setRepositoryScanning( repoScanning ); - configControl.setMatcher( MockControl.ALWAYS_MATCHER ); - configControl.setVoidCallable(); + configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 4 ); archivaConfig.save( config ); archivaConfigControl.setVoidCallable(); @@ -397,7 +407,7 @@ public class AdministrationServiceImplTest ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 ); ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, @@ -450,7 +460,7 @@ public class AdministrationServiceImplTest ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 ); ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent(); repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, @@ -511,7 +521,7 @@ public class AdministrationServiceImplTest ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 ); ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, @@ -560,7 +570,7 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "non-existing-repo" ), null ); + configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList() ); archivaConfigControl.replay(); configControl.replay(); @@ -585,8 +595,8 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), - createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( + createManagedRepo( "internal", "default", "Internal Repository", true, false ) ), 1, 5 ); RepositoryTask task = new RepositoryTask(); @@ -621,8 +631,9 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), - createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( + createManagedRepo( "internal", "default", "Internal Repository", true, false ) ), 1, 5 ); repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), true ); @@ -651,7 +662,7 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null ); + configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 ); archivaConfigControl.replay(); configControl.replay(); @@ -729,7 +740,7 @@ public class AdministrationServiceImplTest public void testDeleteInvalidRepositoryContent() { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "invalid" ), null ); + configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 ); archivaConfigControl.replay(); configControl.replay(); @@ -754,8 +765,8 @@ public class AdministrationServiceImplTest ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); assertTrue( new File( managedRepo.getLocation(), "org" ).exists() ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 3 ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 ); metadataRepository.removeRepository( "internal" ); archivaConfigControl.replay(); @@ -779,7 +790,7 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "invalid" ), null ); + configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 2 ); archivaConfigControl.replay(); configControl.replay(); @@ -801,10 +812,11 @@ public class AdministrationServiceImplTest public void testMergeWithNoStagingRepository() throws Exception { - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), - createManagedRepo( "repo", "default", "repo", true, false ) ); - configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), null ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 ); + + configControl.expectAndReturn( config.getManagedRepositories(), + Arrays.asList( createManagedRepo( "repo", "default", "repo", true, false ) ), 1, + 4 ); archivaConfigControl.replay(); configControl.replay(); @@ -841,9 +853,8 @@ public class AdministrationServiceImplTest RepositoryTask task = new RepositoryTask(); task.setScanAll( true ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "merge" ), merge ); - configControl.expectAndReturn( config.findManagedRepositoryById( "merge-stage" ), staging ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( merge, staging ), 1, 5 ); metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources ); repositoryMergerControl.expectAndDefaultReturn( @@ -910,9 +921,8 @@ public class AdministrationServiceImplTest repo.setLocation( "target/test-repository/one" ); ManagedRepositoryConfiguration staging = createStagingRepo( repo ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), repo ); - configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), staging ); + configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( repo, staging ), 1, 5 ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 ); metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources ); repositoryMergerControl.expectAndDefaultReturn(