]> source.dussan.org Git - archiva.git/commitdiff
-implemented getAllManagedRepositories() and getAllRemoteRepositories() in admin...
authorMaria Odea B. Ching <oching@apache.org>
Fri, 10 Oct 2008 01:54:48 +0000 (01:54 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 10 Oct 2008 01:54:48 +0000 (01:54 +0000)
-activated tests for these 2 methods

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@703312 13f79535-47bb-0310-9956-ffa450edef68

MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ManagedRepository.java
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/RemoteRepository.java
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java

index 07f162735fb7eec37a0dbfd052de977ec5554a8c..55bdf5cda6e1145f6262f8cc1cc58b61c756756d 100644 (file)
@@ -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)
index 961d82160020cee6c7ca92bf6198cbbe5b9b0301..810f2ee5e92308204564428eaa3e83dbe9c5ef7a 100644 (file)
@@ -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)
index 2ccf33d21902c04dced026a4368664f792014e92..8d59df21f65bd8a7d3829fb082ca497457ac9fa3 100644 (file)
@@ -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<ManagedRepository> getAllManagedRepositories()
     {
-        return null;
+        List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>();
+        
+        Configuration config = archivaConfiguration.getConfiguration();
+        List<ManagedRepositoryConfiguration> 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<RemoteRepository> getAllRemoteRepositories()
     {
-        return null;
+        List<RemoteRepository> remoteRepos = new ArrayList<RemoteRepository>();
+        
+        Configuration config = archivaConfiguration.getConfiguration();
+        List<RemoteRepositoryConfiguration> 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 )
index aa4acc2de7235050593364392d666f6006ab9190..f8ed311a1fd9d9bff27d3a038be71a6e1d22c085 100644 (file)
@@ -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() );
     }