[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
This commit is contained in:
Olivier Lamy 2011-09-15 14:00:51 +00:00
parent d13a6a799e
commit 4325788c50
3 changed files with 112 additions and 130 deletions

View File

@ -102,6 +102,11 @@
<artifactId>archiva-repository-admin-default</artifactId> <artifactId>archiva-repository-admin-default</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>

View File

@ -21,7 +21,11 @@ package org.apache.archiva.web.xmlrpc.services;
import org.apache.archiva.admin.model.AuditInformation; import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.admin.model.RepositoryAdminException; 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.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.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener; 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.archiva.web.xmlrpc.api.beans.RemoteRepository;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; 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.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer; import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.maven.archiva.model.VersionedReference; 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.RepositoryContentFactory;
import org.apache.maven.archiva.repository.RepositoryException; import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.archiva.repository.RepositoryNotFoundException; import org.apache.maven.archiva.repository.RepositoryNotFoundException;
import org.codehaus.plexus.registry.RegistryException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -78,8 +75,6 @@ public class AdministrationServiceImpl
{ {
protected Logger log = LoggerFactory.getLogger( getClass() ); protected Logger log = LoggerFactory.getLogger( getClass() );
private ArchivaConfiguration archivaConfiguration;
private RepositoryContentConsumers repoConsumersUtil; private RepositoryContentConsumers repoConsumersUtil;
private RepositoryContentFactory repoFactory; private RepositoryContentFactory repoFactory;
@ -102,13 +97,20 @@ public class AdministrationServiceImpl
private RemoteRepositoryAdmin remoteRepositoryAdmin; 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_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_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$";
private static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&amp;=\\\\]+$"; private static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&amp;=\\\\]+$";
public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil, public AdministrationServiceImpl( ArchivaAdministration archivaAdministration,
RepositoryContentConsumers repoConsumersUtil,
RepositoryContentFactory repoFactory, RepositoryContentFactory repoFactory,
RepositorySessionFactory repositorySessionFactory, RepositorySessionFactory repositorySessionFactory,
RepositoryArchivaTaskScheduler repositoryTaskScheduler, RepositoryArchivaTaskScheduler repositoryTaskScheduler,
@ -116,9 +118,10 @@ public class AdministrationServiceImpl
RepositoryStatisticsManager repositoryStatisticsManager, RepositoryStatisticsManager repositoryStatisticsManager,
RepositoryMerger repositoryMerger, AuditListener auditListener, RepositoryMerger repositoryMerger, AuditListener auditListener,
ManagedRepositoryAdmin managedRepositoryAdmin, ManagedRepositoryAdmin managedRepositoryAdmin,
RemoteRepositoryAdmin remoteRepositoryAdmin ) RemoteRepositoryAdmin remoteRepositoryAdmin,
ProxyConnectorAdmin proxyConnectorAdmin,
RepositoryGroupAdmin repositoryGroupAdmin )
{ {
this.archivaConfiguration = archivaConfig;
this.repoConsumersUtil = repoConsumersUtil; this.repoConsumersUtil = repoConsumersUtil;
this.repoFactory = repoFactory; this.repoFactory = repoFactory;
this.repositoryTaskScheduler = repositoryTaskScheduler; this.repositoryTaskScheduler = repositoryTaskScheduler;
@ -129,6 +132,9 @@ public class AdministrationServiceImpl
this.auditListener = auditListener; this.auditListener = auditListener;
this.managedRepositoryAdmin = managedRepositoryAdmin; this.managedRepositoryAdmin = managedRepositoryAdmin;
this.remoteRepositoryAdmin = remoteRepositoryAdmin; this.remoteRepositoryAdmin = remoteRepositoryAdmin;
this.archivaAdministration = archivaAdministration;
this.proxyConnectorAdmin = proxyConnectorAdmin;
this.repositoryGroupAdmin = repositoryGroupAdmin;
} }
/** /**
@ -171,20 +177,29 @@ public class AdministrationServiceImpl
throw new Exception( "Invalid repository consumer." ); throw new Exception( "Invalid repository consumer." );
} }
Configuration config = archivaConfiguration.getConfiguration();
RepositoryScanningConfiguration repoScanningConfig = config.getRepositoryScanning();
if ( isKnownContentConsumer ) if ( isKnownContentConsumer )
{ {
repoScanningConfig.addKnownContentConsumer( consumerId ); if ( enable )
{
archivaAdministration.addKnownContentConsumer( consumerId, getAuditInformation() );
} }
else else
{ {
repoScanningConfig.addInvalidContentConsumer( consumerId ); archivaAdministration.removeKnownContentConsumer( consumerId, getAuditInformation() );
} }
config.setRepositoryScanning( repoScanningConfig ); }
saveConfiguration( config ); else
{
if ( enable )
{
archivaAdministration.addInvalidContentConsumer( consumerId, getAuditInformation() );
}
else
{
archivaAdministration.removeInvalidContentConsumer( consumerId, getAuditInformation() );
}
}
return true; return true;
} }
@ -197,8 +212,8 @@ public class AdministrationServiceImpl
{ {
// TODO: remove duplication with web // TODO: remove duplication with web
Configuration config = archivaConfiguration.getConfiguration(); org.apache.archiva.admin.model.managed.ManagedRepository repoConfig =
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId ); managedRepositoryAdmin.getManagedRepository( repoId );
if ( repoConfig == null ) if ( repoConfig == null )
{ {
@ -266,8 +281,7 @@ public class AdministrationServiceImpl
public Boolean executeRepositoryScanner( String repoId ) public Boolean executeRepositoryScanner( String repoId )
throws Exception throws Exception
{ {
Configuration config = archivaConfiguration.getConfiguration(); if ( managedRepositoryAdmin.getManagedRepository( repoId ) == null )
if ( config.findManagedRepositoryById( repoId ) == null )
{ {
throw new Exception( "Repository does not exist." ); throw new Exception( "Repository does not exist." );
} }
@ -344,23 +358,6 @@ public class AdministrationServiceImpl
return remoteRepos; 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, public Boolean addManagedRepository( String repoId, String layout, String name, String location,
boolean blockRedeployments, boolean releasesIncluded, boolean blockRedeployments, boolean releasesIncluded,
boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression, boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression,
@ -381,9 +378,9 @@ public class AdministrationServiceImpl
public Boolean deleteManagedRepository( String repoId ) public Boolean deleteManagedRepository( String repoId )
throws Exception 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 ) if ( repository == null )
{ {
@ -402,16 +399,7 @@ public class AdministrationServiceImpl
{ {
repositorySession.close(); repositorySession.close();
} }
config.removeManagedRepository( repository ); managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation(), false );
try
{
saveConfiguration( config );
}
catch ( Exception e )
{
throw new Exception( "Error saving configuration for delete action" + e.getMessage() );
}
File dir = new File( repository.getLocation() ); File dir = new File( repository.getLocation() );
if ( !FileUtils.deleteQuietly( dir ) ) if ( !FileUtils.deleteQuietly( dir ) )
@ -419,16 +407,16 @@ public class AdministrationServiceImpl
throw new IOException( "Cannot delete repository " + dir ); throw new IOException( "Cannot delete repository " + dir );
} }
List<ProxyConnectorConfiguration> proxyConnectors = config.getProxyConnectors(); List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors ) for ( ProxyConnector proxyConnector : proxyConnectors )
{ {
if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) ) if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
{ {
archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector ); proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation() );
} }
} }
Map<String, List<String>> repoToGroupMap = archivaConfiguration.getConfiguration().getRepositoryToGroupMap(); Map<String, List<String>> repoToGroupMap = repositoryGroupAdmin.getRepositoryToGroupMap();
if ( repoToGroupMap != null ) if ( repoToGroupMap != null )
{ {
if ( repoToGroupMap.containsKey( repository.getId() ) ) if ( repoToGroupMap.containsKey( repository.getId() ) )
@ -436,8 +424,8 @@ public class AdministrationServiceImpl
List<String> repoGroups = repoToGroupMap.get( repository.getId() ); List<String> repoGroups = repoToGroupMap.get( repository.getId() );
for ( String repoGroup : repoGroups ) for ( String repoGroup : repoGroups )
{ {
archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( repositoryGroupAdmin.deleteRepositoryFromGroup( repoGroup, repository.getId(),
repository.getId() ); getAuditInformation() );
} }
} }
} }
@ -448,9 +436,9 @@ public class AdministrationServiceImpl
public Boolean deleteManagedRepositoryContent( String repoId ) public Boolean deleteManagedRepositoryContent( String repoId )
throws Exception 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 ) if ( repository == null )
{ {
@ -491,8 +479,8 @@ public class AdministrationServiceImpl
public ManagedRepository getManagedRepository( String repoId ) public ManagedRepository getManagedRepository( String repoId )
throws Exception throws Exception
{ {
Configuration config = archivaConfiguration.getConfiguration(); org.apache.archiva.admin.model.managed.ManagedRepository managedRepository =
ManagedRepositoryConfiguration managedRepository = config.findManagedRepositoryById( repoId ); managedRepositoryAdmin.getManagedRepository( repoId );
if ( managedRepository == null ) if ( managedRepository == null )
{ {
throw new Exception( "A repository with that id does not exist" ); throw new Exception( "A repository with that id does not exist" );
@ -508,11 +496,10 @@ public class AdministrationServiceImpl
throws Exception throws Exception
{ {
String stagingId = repoId + STAGE; String stagingId = repoId + STAGE;
ManagedRepositoryConfiguration repoConfig; org.apache.archiva.admin.model.managed.ManagedRepository repoConfig;
ManagedRepositoryConfiguration stagingConfig; org.apache.archiva.admin.model.managed.ManagedRepository stagingConfig;
Configuration config = archivaConfiguration.getConfiguration(); repoConfig = managedRepositoryAdmin.getManagedRepository( repoId );
repoConfig = config.findManagedRepositoryById( repoId );
log.debug( "Retrieved repository configuration for repo '" + repoId + "'" ); log.debug( "Retrieved repository configuration for repo '" + repoId + "'" );
@ -522,7 +509,7 @@ public class AdministrationServiceImpl
MetadataRepository metadataRepository = repositorySession.getRepository(); MetadataRepository metadataRepository = repositorySession.getRepository();
if ( repoConfig != null ) if ( repoConfig != null )
{ {
stagingConfig = config.findManagedRepositoryById( stagingId ); stagingConfig = managedRepositoryAdmin.getManagedRepository( stagingId );
if ( stagingConfig != null ) if ( stagingConfig != null )
{ {
@ -631,7 +618,7 @@ public class AdministrationServiceImpl
} }
// todo: setting userid of audit event // 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(); AuditEvent event = new AuditEvent();
@ -664,26 +651,6 @@ public class AdministrationServiceImpl
repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots ); 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 // FIXME find a way to get user id and adress
private AuditInformation getAuditInformation() private AuditInformation getAuditInformation()

View File

@ -22,7 +22,10 @@ package org.apache.archiva.web.xmlrpc.services;
import junit.framework.TestCase; import junit.framework.TestCase;
import net.sf.beanlib.provider.replicator.BeanReplicator; import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.repository.RepositoryCommonValidator; 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.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin; import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener; import org.apache.archiva.audit.AuditListener;
@ -65,7 +68,6 @@ import org.easymock.classextension.MockClassControl;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ -162,7 +164,11 @@ public class AdministrationServiceImplTest
private DefaultRemoteRepositoryAdmin remoteRepositoryAdmin; private DefaultRemoteRepositoryAdmin remoteRepositoryAdmin;
private ApplicationContext applicationContext; private DefaultArchivaAdministration archivaAdministration;
private DefaultProxyConnectorAdmin proxyConnectorAdmin;
private DefaultRepositoryGroupAdmin repositoryGroupAdmin;
@Before @Before
public void setUp() public void setUp()
@ -243,11 +249,23 @@ public class AdministrationServiceImplTest
remoteRepositoryAdmin.setRepositoryCommonValidator( repositoryCommonValidator ); 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, repositorySessionFactory, repositoryTaskScheduler,
Collections.singletonList( listener ), repositoryStatisticsManager, Collections.singletonList( listener ), repositoryStatisticsManager,
repositoryMerger, auditListener, managedRepositoryAdmin, repositoryMerger, auditListener, managedRepositoryAdmin,
remoteRepositoryAdmin ); remoteRepositoryAdmin, proxyConnectorAdmin, repositoryGroupAdmin );
} }
/* Tests for repository consumers */ /* Tests for repository consumers */
@ -288,11 +306,7 @@ public class AdministrationServiceImplTest
recordRepoConsumers(); recordRepoConsumers();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 5 );
config.setRepositoryScanning( repoScanning );
configControl.setMatcher( MockControl.ALWAYS_MATCHER );
configControl.setVoidCallable();
archivaConfig.save( config ); archivaConfig.save( config );
archivaConfigControl.setVoidCallable(); archivaConfigControl.setVoidCallable();
@ -331,11 +345,7 @@ public class AdministrationServiceImplTest
recordRepoConsumers(); recordRepoConsumers();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning ); configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 4 );
config.setRepositoryScanning( repoScanning );
configControl.setMatcher( MockControl.ALWAYS_MATCHER );
configControl.setVoidCallable();
archivaConfig.save( config ); archivaConfig.save( config );
archivaConfigControl.setVoidCallable(); archivaConfigControl.setVoidCallable();
@ -397,7 +407,7 @@ public class AdministrationServiceImplTest
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
@ -450,7 +460,7 @@ public class AdministrationServiceImplTest
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" ); ManagedRepositoryConfiguration managedRepo = createManagedRepo( "legacy", "legacy-repo" );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent(); ManagedLegacyRepositoryContent repoContent = new ManagedLegacyRepositoryContent();
repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
@ -511,7 +521,7 @@ public class AdministrationServiceImplTest
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent(); ManagedDefaultRepositoryContent repoContent = new ManagedDefaultRepositoryContent();
repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo, repoContent.setRepository( new BeanReplicator().replicateBean( managedRepo,
@ -560,7 +570,7 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "non-existing-repo" ), null ); configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList() );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -585,8 +595,8 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList(
createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); createManagedRepo( "internal", "default", "Internal Repository", true, false ) ), 1, 5 );
RepositoryTask task = new RepositoryTask(); RepositoryTask task = new RepositoryTask();
@ -621,8 +631,9 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); 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( repositoryTaskSchedulerControl.expectAndReturn(
repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), true ); repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), true );
@ -651,7 +662,7 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null ); configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -729,7 +740,7 @@ public class AdministrationServiceImplTest
public void testDeleteInvalidRepositoryContent() public void testDeleteInvalidRepositoryContent()
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "invalid" ), null ); configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 5 );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -754,8 +765,8 @@ public class AdministrationServiceImplTest
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" ); ManagedRepositoryConfiguration managedRepo = createManagedRepo( "default", "default-repo" );
assertTrue( new File( managedRepo.getLocation(), "org" ).exists() ); assertTrue( new File( managedRepo.getLocation(), "org" ).exists() );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 3 );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), managedRepo ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( managedRepo ), 1, 5 );
metadataRepository.removeRepository( "internal" ); metadataRepository.removeRepository( "internal" );
archivaConfigControl.replay(); archivaConfigControl.replay();
@ -779,7 +790,7 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "invalid" ), null ); configControl.expectAndReturn( config.getManagedRepositories(), Collections.emptyList(), 1, 2 );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -801,10 +812,11 @@ public class AdministrationServiceImplTest
public void testMergeWithNoStagingRepository() public void testMergeWithNoStagingRepository()
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ),
createManagedRepo( "repo", "default", "repo", true, false ) ); configControl.expectAndReturn( config.getManagedRepositories(),
configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), null ); Arrays.asList( createManagedRepo( "repo", "default", "repo", true, false ) ), 1,
4 );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -841,9 +853,8 @@ public class AdministrationServiceImplTest
RepositoryTask task = new RepositoryTask(); RepositoryTask task = new RepositoryTask();
task.setScanAll( true ); task.setScanAll( true );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
configControl.expectAndReturn( config.findManagedRepositoryById( "merge" ), merge ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( merge, staging ), 1, 5 );
configControl.expectAndReturn( config.findManagedRepositoryById( "merge-stage" ), staging );
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources ); metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
repositoryMergerControl.expectAndDefaultReturn( repositoryMergerControl.expectAndDefaultReturn(
@ -910,9 +921,8 @@ public class AdministrationServiceImplTest
repo.setLocation( "target/test-repository/one" ); repo.setLocation( "target/test-repository/one" );
ManagedRepositoryConfiguration staging = createStagingRepo( repo ); ManagedRepositoryConfiguration staging = createStagingRepo( repo );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.getManagedRepositories(), Arrays.asList( repo, staging ), 1, 5 );
configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), repo ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 5 );
configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), staging );
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources ); metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( staging.getId() ), sources );
repositoryMergerControl.expectAndDefaultReturn( repositoryMergerControl.expectAndDefaultReturn(