[MRM-980] Add getArtifacts() method to be able to retrieve all artifacts in a repository

Submitted by: Patti Arachchige Eshan Sudharaka


git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-MRM-980@961576 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2010-07-08 05:53:27 +00:00
parent 27ad7cd108
commit f6d87c18b4
7 changed files with 63 additions and 4 deletions

View File

@ -159,4 +159,8 @@ public class TestMetadataRepository
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public List<ArtifactMetadata> getArtifacts(String repositoryId){
return null;
}
}

View File

@ -199,4 +199,8 @@ public class TestMetadataRepository
{
return artifacts;
}
public List<ArtifactMetadata> getArtifacts(String repositoryId){
return artifacts;
}
}

View File

@ -159,4 +159,7 @@ public class TestMetadataRepository
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public List<ArtifactMetadata> getArtifacts(String repositoryId){
return null;
}
}

View File

@ -75,4 +75,6 @@ public interface MetadataRepository
* @param repositoryId the repository to delete
*/
void deleteRepository( String repositoryId );
List<ArtifactMetadata> getArtifacts(String repositoryId);
}

View File

@ -484,6 +484,17 @@ public abstract class AbstractMetadataRepositoryTest
Date upper = new Date( artifact.getWhenGathered().getTime() - 10000 );
assertTrue( repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper ).isEmpty() );
}
public void testGetArtifactsByRepoId()
{
repository.updateNamespace( TEST_REPO_ID, TEST_NAMESPACE );
repository.updateProject( TEST_REPO_ID, createProject() );
ArtifactMetadata artifact = createArtifact();
repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
assertFalse( repository.getArtifacts(TEST_REPO_ID).isEmpty());
}
public void testGetNamespacesWithSparseDepth()

View File

@ -114,4 +114,7 @@ public class TestMetadataRepository
{
//To change body of implemented methods use File | Settings | File Templates.
}
public List<ArtifactMetadata> getArtifacts(String repositoryId){
return null;
}
}

View File

@ -1075,4 +1075,36 @@ public class FileMetadataRepository
return artifact1.getWhenGathered().compareTo( artifact2.getWhenGathered() );
}
}
public List<ArtifactMetadata> getArtifacts( String repoId )
{
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>();
for ( String ns : getRootNamespaces( repoId ) )
{
getArtifacts( artifacts, repoId, ns );
}
return artifacts;
}
private void getArtifacts( List<ArtifactMetadata> artifacts, String repoId, String ns )
{
for ( String namespace : getNamespaces( repoId, ns ) )
{
getArtifacts( artifacts, repoId, ns + "." + namespace );
}
for ( String project : getProjects( repoId, ns ) )
{
for ( String version : getProjectVersions( repoId, ns, project ) )
{
for ( ArtifactMetadata artifact : getArtifacts( repoId, ns, project, version ) )
{
artifacts.add( artifact );
}
}
}
}
}