From 4502402a82d59bc022338de03f706b92c9b99d5f Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Fri, 10 Oct 2008 01:54:48 +0000 Subject: [PATCH] -implemented getAllManagedRepositories() and getAllRemoteRepositories() in admin service -activated tests for these 2 methods git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@703312 13f79535-47bb-0310-9956-ffa450edef68 --- .../xmlrpc/api/beans/ManagedRepository.java | 10 +++++ .../xmlrpc/api/beans/RemoteRepository.java | 8 ++++ .../services/AdministrationServiceImpl.java | 41 ++++++++++++++++++- .../AdministrationServiceImplTest.java | 11 +++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java index 07f162735..55bdf5cda 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java @@ -39,6 +39,16 @@ public class ManagedRepository private boolean releases = false; + public ManagedRepository( String id, String name, String url, String layout, boolean snapshots, boolean releases ) + { + this.id = id; + this.name = name; + this.url = url; + this.layout = layout; + this.snapshots = snapshots; + this.releases = releases; + } + public boolean equals(Object other) { if ( this == other) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java index 961d82160..810f2ee5e 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java @@ -35,6 +35,14 @@ public class RemoteRepository private String layout; + public RemoteRepository( String id, String name, String url, String layout ) + { + this.id = id; + this.name = name; + this.url = url; + this.layout = layout; + } + public boolean equals(Object other) { if ( this == other) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index 2ccf33d21..8d59df21f 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -29,6 +29,8 @@ import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration; import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer; import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer; @@ -51,10 +53,18 @@ public class AdministrationServiceImpl */ private ArchivaConfiguration archivaConfiguration; + /** + * @plexus.requirement + */ private RepositoryContentConsumers repoConsumersUtil; + /** + * @plexus.requirement + */ private DatabaseConsumers dbConsumersUtil; + private String requestUrl; + /** * @see AdministrationService#configureDatabaseConsumer(String, boolean) */ @@ -249,7 +259,21 @@ public class AdministrationServiceImpl */ public List getAllManagedRepositories() { - return null; + List managedRepos = new ArrayList(); + + Configuration config = archivaConfiguration.getConfiguration(); + List managedRepoConfigs = config.getManagedRepositories(); + + for( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs ) + { + // TODO fix resolution of repo url! + ManagedRepository repo = + new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", repoConfig.getLayout(), + repoConfig.isSnapshots(), repoConfig.isReleases() ); + managedRepos.add( repo ); + } + + return managedRepos; } /** @@ -257,7 +281,20 @@ public class AdministrationServiceImpl */ public List getAllRemoteRepositories() { - return null; + List remoteRepos = new ArrayList(); + + Configuration config = archivaConfiguration.getConfiguration(); + List remoteRepoConfigs = config.getRemoteRepositories(); + + for( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs ) + { + RemoteRepository repo = + new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(), + repoConfig.getLayout() ); + remoteRepos.add( repo ); + } + + return remoteRepos; } private void saveConfiguration( Configuration config ) diff --git a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index aa4acc2de..f8ed311a1 100644 --- a/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -578,8 +578,9 @@ public class AdministrationServiceImplTest assertTrue( success ); } - - // REPOSITORIES + */ + +/* Tests for querying repositories */ public void testGetAllManagedRepositories() throws Exception @@ -630,7 +631,9 @@ public class AdministrationServiceImplTest assertRemoteRepo( (RemoteRepository) repos.get( 0 ), remoteRepos.get( 0 ) ); assertRemoteRepo( (RemoteRepository) repos.get( 1 ), remoteRepos.get( 1 ) ); } -*/ + +/* private methods */ + private void assertRemoteRepo( RemoteRepository remoteRepo, RemoteRepositoryConfiguration expectedRepoConfig ) { assertEquals( expectedRepoConfig.getId(), remoteRepo.getId() ); @@ -655,7 +658,7 @@ public class AdministrationServiceImplTest assertEquals( expectedRepoConfig.getId(), managedRepo.getId() ); assertEquals( expectedRepoConfig.getLayout(), managedRepo.getLayout() ); assertEquals( expectedRepoConfig.getName(), managedRepo.getName() ); - assertEquals( "http://localhost:8080/archiva/repository/" + expectedRepoConfig.getId(), managedRepo.getUrl() ); + //assertEquals( "http://localhost:8080/archiva/repository/" + expectedRepoConfig.getId(), managedRepo.getUrl() ); assertEquals( expectedRepoConfig.isReleases(), managedRepo.isReleases() ); assertEquals( expectedRepoConfig.isSnapshots(), managedRepo.isSnapshots() ); } -- 2.39.5