[MRM-1509] change xmlrpc to use new repository administration management api : switch for remote repositories

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1165281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-05 13:44:04 +00:00
parent 86d521a12b
commit 7961aeb46a
3 changed files with 21 additions and 8 deletions

View File

@ -73,7 +73,8 @@ public interface AdministrationService
*
* @return
*/
List<RemoteRepository> getAllRemoteRepositories();
List<RemoteRepository> getAllRemoteRepositories()
throws RepositoryAdminException;
/**
* Deletes given artifact from the specified repository.

View File

@ -22,6 +22,7 @@ package org.apache.archiva.web.xmlrpc.services;
import org.apache.archiva.admin.AuditInformation;
import org.apache.archiva.admin.repository.RepositoryAdminException;
import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.model.ArtifactMetadata;
@ -46,7 +47,6 @@ 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.RemoteRepositoryConfiguration;
import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
@ -100,6 +100,8 @@ public class AdministrationServiceImpl
private ManagedRepositoryAdmin managedRepositoryAdmin;
private RemoteRepositoryAdmin remoteRepositoryAdmin;
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)+$";
@ -113,7 +115,8 @@ public class AdministrationServiceImpl
Collection<RepositoryListener> listeners,
RepositoryStatisticsManager repositoryStatisticsManager,
RepositoryMerger repositoryMerger, AuditListener auditListener,
ManagedRepositoryAdmin managedRepositoryAdmin )
ManagedRepositoryAdmin managedRepositoryAdmin,
RemoteRepositoryAdmin remoteRepositoryAdmin )
{
this.archivaConfiguration = archivaConfig;
this.repoConsumersUtil = repoConsumersUtil;
@ -125,6 +128,7 @@ public class AdministrationServiceImpl
this.repositoryMerger = repositoryMerger;
this.auditListener = auditListener;
this.managedRepositoryAdmin = managedRepositoryAdmin;
this.remoteRepositoryAdmin = remoteRepositoryAdmin;
}
/**
@ -326,13 +330,11 @@ public class AdministrationServiceImpl
* @see AdministrationService#getAllRemoteRepositories()
*/
public List<RemoteRepository> getAllRemoteRepositories()
throws RepositoryAdminException
{
List<RemoteRepository> remoteRepos = new ArrayList<RemoteRepository>();
Configuration config = archivaConfiguration.getConfiguration();
List<RemoteRepositoryConfiguration> remoteRepoConfigs = config.getRemoteRepositories();
for ( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs )
for ( org.apache.archiva.admin.repository.remote.RemoteRepository repoConfig : remoteRepositoryAdmin.getRemoteRepositories() )
{
RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(),
repoConfig.getLayout() );

View File

@ -22,6 +22,7 @@ package org.apache.archiva.web.xmlrpc.services;
import junit.framework.TestCase;
import org.apache.archiva.admin.repository.RepositoryCommonValidator;
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
import org.apache.archiva.audit.AuditEvent;
import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.model.ArtifactMetadata;
@ -158,6 +159,8 @@ public class AdministrationServiceImplTest
private DefaultManagedRepositoryAdmin managedRepositoryAdmin;
private DefaultRemoteRepositoryAdmin remoteRepositoryAdmin;
private ApplicationContext applicationContext;
@Before
@ -233,10 +236,17 @@ public class AdministrationServiceImplTest
managedRepositoryAdmin.setRepositoryCommonValidator( repositoryCommonValidator );
remoteRepositoryAdmin = new DefaultRemoteRepositoryAdmin();
remoteRepositoryAdmin.setArchivaConfiguration( archivaConfig );
remoteRepositoryAdmin.setAuditListeners( Arrays.asList( auditListener ) );
remoteRepositoryAdmin.setRepositoryCommonValidator( repositoryCommonValidator );
service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory,
repositorySessionFactory, repositoryTaskScheduler,
Collections.singletonList( listener ), repositoryStatisticsManager,
repositoryMerger, auditListener, managedRepositoryAdmin );
repositoryMerger, auditListener, managedRepositoryAdmin,
remoteRepositoryAdmin );
}
/* Tests for repository consumers */