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;
*/
private ArchivaConfiguration archivaConfiguration;
+ /**
+ * @plexus.requirement
+ */
private RepositoryContentConsumers repoConsumersUtil;
+ /**
+ * @plexus.requirement
+ */
private DatabaseConsumers dbConsumersUtil;
+ private String requestUrl;
+
/**
* @see AdministrationService#configureDatabaseConsumer(String, boolean)
*/
*/
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;
}
/**
*/
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 )
assertTrue( success );
}
-
- // REPOSITORIES
+ */
+
+/* Tests for querying repositories */
public void testGetAllManagedRepositories()
throws Exception
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() );
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() );
}