mirror of https://github.com/apache/archiva.git
[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:
parent
27ad7cd108
commit
f6d87c18b4
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,4 +199,8 @@ public class TestMetadataRepository
|
|||
{
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
public List<ArtifactMetadata> getArtifacts(String repositoryId){
|
||||
return artifacts;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,4 +75,6 @@ public interface MetadataRepository
|
|||
* @param repositoryId the repository to delete
|
||||
*/
|
||||
void deleteRepository( String repositoryId );
|
||||
|
||||
List<ArtifactMetadata> getArtifacts(String repositoryId);
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue