diff options
author | Brett Porter <brett@apache.org> | 2010-12-22 08:31:56 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2010-12-22 08:31:56 +0000 |
commit | c63e2a3f776db2d2bc1aff70834e2ad905e86042 (patch) | |
tree | 622337eeaa5f1310c1819ce138a3494fc4a69215 /archiva-modules/plugins | |
parent | f9cd1037d1170cbdc93d6596d2b948f9164bf911 (diff) | |
download | archiva-c63e2a3f776db2d2bc1aff70834e2ad905e86042.tar.gz archiva-c63e2a3f776db2d2bc1aff70834e2ad905e86042.zip |
[MRM-1327] refactor the repository API to make each concern clearer. Storage, resolver and metadata repository are separate interfaces. Rename methods on the resolver and the storage to be clearer of their intent
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1051788 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
7 files changed, 198 insertions, 193 deletions
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java index 107d616ed..54007ab35 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java @@ -425,8 +425,8 @@ public class DefaultDependencyTreeBuilder Collection<String> projectVersions; try { - projectVersions = metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), - artifact.getArtifactId() ); + projectVersions = metadataResolver.resolveProjectVersions( repoId, artifact.getGroupId(), + artifact.getArtifactId() ); } catch ( MetadataResolutionException e ) { diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 66a41c02a..1abe5a700 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -24,14 +24,12 @@ import org.apache.archiva.checksum.ChecksummedFile; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.MetadataResolutionException; -import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.Filter; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; -import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.reports.RepositoryProblemFacet; import org.apache.maven.archiva.common.utils.VersionUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; @@ -63,10 +61,10 @@ import java.util.Date; import java.util.List; /** - * @plexus.component role="org.apache.archiva.metadata.repository.storage.StorageMetadataResolver" role-hint="maven2" + * @plexus.component role="org.apache.archiva.metadata.repository.storage.RepositoryStorage" role-hint="maven2" */ -public class Maven2RepositoryMetadataResolver - implements StorageMetadataResolver +public class Maven2RepositoryStorage + implements RepositoryStorage { /** * @plexus.requirement @@ -88,12 +86,10 @@ public class Maven2RepositoryMetadataResolver */ private MetadataRepository metadataRepository; - private final static Logger log = LoggerFactory.getLogger( Maven2RepositoryMetadataResolver.class ); + private final static Logger log = LoggerFactory.getLogger( Maven2RepositoryStorage.class ); private static final String METADATA_FILENAME = "maven-metadata.xml"; - private static final Filter<String> ALL = new AllFilter<String>(); - private static final String PROBLEM_MISSING_POM = "missing-pom"; private static final String PROBLEM_INVALID_POM = "invalid-pom"; @@ -103,14 +99,14 @@ public class Maven2RepositoryMetadataResolver private static final List<String> POTENTIAL_PROBLEMS = Arrays.asList( PROBLEM_INVALID_POM, PROBLEM_MISSING_POM, PROBLEM_MISLOCATED_POM ); - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + public ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId ) { // TODO: could natively implement the "shared model" concept from the browse action to avoid needing it there? return null; } - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException { // Remove problems associated with this version, since we'll be re-adding any that still exist @@ -372,26 +368,7 @@ public class Maven2RepositoryMetadataResolver return ci; } - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - { - // TODO: useful, but not implemented yet, not called from DefaultMetadataResolver - throw new UnsupportedOperationException(); - } - - public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) - { - // Can't be determined on a Maven 2 repository - throw new UnsupportedOperationException(); - } - - public Collection<String> getRootNamespaces( String repoId ) - { - return getRootNamespaces( repoId, ALL ); - } - - public Collection<String> getRootNamespaces( String repoId, Filter<String> filter ) + public Collection<String> listRootNamespaces( String repoId, Filter<String> filter ) { File dir = getRepositoryBasedir( repoId ); @@ -422,12 +399,7 @@ public class Maven2RepositoryMetadataResolver return new File( repositoryConfiguration.getLocation() ); } - public Collection<String> getNamespaces( String repoId, String namespace ) - { - return getNamespaces( repoId, namespace, ALL ); - } - - public Collection<String> getNamespaces( String repoId, String namespace, Filter<String> filter ) + public Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); @@ -448,12 +420,7 @@ public class Maven2RepositoryMetadataResolver return namespaces; } - public Collection<String> getProjects( String repoId, String namespace ) - { - return getProjects( repoId, namespace, ALL ); - } - - public Collection<String> getProjects( String repoId, String namespace, Filter<String> filter ) + public Collection<String> listProjects( String repoId, String namespace, Filter<String> filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); @@ -474,19 +441,8 @@ public class Maven2RepositoryMetadataResolver return projects; } - public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) - { - return getProjectVersions( repoId, namespace, projectId, ALL ); - } - - public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) - { - return getArtifacts( repoId, namespace, projectId, projectVersion, ALL ); - } - - public Collection<String> getProjectVersions( String repoId, String namespace, String projectId, - Filter<String> filter ) + public Collection<String> listProjectVersions( String repoId, String namespace, String projectId, + Filter<String> filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId ); @@ -494,8 +450,8 @@ public class Maven2RepositoryMetadataResolver return getSortedFiles( dir, filter ); } - public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, - String projectVersion, Filter<String> filter ) + public Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId, + String projectVersion, Filter<String> filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion ); @@ -514,7 +470,7 @@ public class Maven2RepositoryMetadataResolver return artifacts; } - public ArtifactMetadata getArtifactForPath( String repoId, String path ) + public ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path ) { ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path ); @@ -653,11 +609,6 @@ public class Maven2RepositoryMetadataResolver return metadata; } - public void setConfiguration( ArchivaConfiguration configuration ) - { - this.archivaConfiguration = configuration; - } - private static class DirectoryFilter implements FilenameFilter { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 932152b68..9d26b53c1 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -19,6 +19,12 @@ package org.apache.archiva.metadata.repository; * under the License. */ +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.MetadataFacet; +import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -26,14 +32,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.MetadataFacet; -import org.apache.archiva.metadata.model.ProjectMetadata; -import org.apache.archiva.metadata.model.ProjectVersionMetadata; -import org.apache.archiva.metadata.model.ProjectVersionReference; - public class TestMetadataRepository - extends TestMetadataResolver implements MetadataRepository { private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>(); @@ -49,7 +48,8 @@ public class TestMetadataRepository //To change body of implemented methods use File | Settings | File Templates. } - public void updateProjectVersion( String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata ) + public void updateProjectVersion( String repoId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) { //To change body of implemented methods use File | Settings | File Templates. } @@ -105,16 +105,76 @@ public class TestMetadataRepository return null; //To change body of implemented methods use File | Settings | File Templates. } - public void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) + public void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) { //To change body of implemented methods use File | Settings | File Templates. } - public void deleteRepository( String repoId ) + public void removeRepository( String repoId ) { //To change body of implemented methods use File | Settings | File Templates. } - public List<ArtifactMetadata> getArtifacts(String repositoryId){ + + public List<ArtifactMetadata> getArtifacts( String repositoryId ) + { return null; } + + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<String> getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<String> getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<String> getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } }
\ No newline at end of file diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java index bb26ecba6..8ef9d7913 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataResolver.java @@ -19,61 +19,49 @@ package org.apache.archiva.metadata.repository; * under the License. */ -import java.util.Collection; - import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; +import java.util.Collection; + public class TestMetadataResolver implements MetadataResolver { - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection<ProjectVersionReference> resolveProjectReferences( String repoId, String namespace, + String projectId, String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<String> getRootNamespaces( String repoId ) + public Collection<String> resolveRootNamespaces( String repoId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<String> getNamespaces( String repoId, String namespace ) + public Collection<String> resolveNamespaces( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<String> getProjects( String repoId, String namespace ) + public Collection<String> resolveProjects( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) + public Collection<String> resolveProjectVersions( String repoId, String namespace, String projectId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection<ArtifactMetadata> resolveArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java index 5a0babea0..230cf03ba 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolverTest.java @@ -27,8 +27,10 @@ import org.apache.archiva.metadata.model.MailingList; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.filter.AllFilter; import org.apache.archiva.metadata.repository.filter.ExcludesFilter; -import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver; +import org.apache.archiva.metadata.repository.filter.Filter; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.archiva.reports.RepositoryProblemFacet; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; @@ -45,7 +47,9 @@ import java.util.List; public class Maven2RepositoryMetadataResolverTest extends PlexusInSpringTestCase { - private Maven2RepositoryMetadataResolver resolver; + private static final Filter<String> ALL = new AllFilter<String>(); + + private Maven2RepositoryStorage resolver; private static final String TEST_REPO_ID = "test"; @@ -74,7 +78,7 @@ public class Maven2RepositoryMetadataResolverTest c.addManagedRepository( testRepo ); configuration.save( c ); - resolver = (Maven2RepositoryMetadataResolver) lookup( StorageMetadataResolver.class, "maven2" ); + resolver = (Maven2RepositoryStorage) lookup( RepositoryStorage.class, "maven2" ); metadataRepository = (MetadataRepository) lookup( MetadataRepository.class ); metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ); } @@ -82,8 +86,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadata() throws Exception { - ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", - "archiva-common", "1.2.1" ); + ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.archiva", + "archiva-common", "1.2.1" ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "jar", facet.getPackaging() ); assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() ); @@ -136,8 +140,9 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadata() throws Exception { - Collection<ArtifactMetadata> springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", - "plexus-spring", "1.2" ); + Collection<ArtifactMetadata> springArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, + "org.codehaus.plexus", + "plexus-spring", "1.2", ALL ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -177,8 +182,9 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadataSnapshots() throws Exception { - Collection<ArtifactMetadata> testArtifacts = resolver.getArtifacts( TEST_REPO_ID, "com.example.test", - "test-artifact", "1.0-SNAPSHOT" ); + Collection<ArtifactMetadata> testArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, "com.example.test", + "test-artifact", "1.0-SNAPSHOT", + ALL ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( testArtifacts ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -259,8 +265,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadataForTimestampedSnapshot() throws Exception { - ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", - "5-SNAPSHOT" ); + ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache", "apache", + "5-SNAPSHOT" ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); assertEquals( "pom", facet.getPackaging() ); assertEquals( "http://www.apache.org/", metadata.getUrl() ); @@ -296,24 +302,24 @@ public class Maven2RepositoryMetadataResolverTest public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "missing-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "malformed-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata() throws Exception { - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata", - "1.0-SNAPSHOT" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", + "incomplete-metadata", "1.0-SNAPSHOT" ); assertNull( metadata ); } @@ -324,7 +330,7 @@ public class Maven2RepositoryMetadataResolverTest try { - resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); + resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "invalid-pom", "1.0" ); fail( "Should have received an exception due to invalid POM" ); } catch ( MetadataResolutionException e ) @@ -345,7 +351,7 @@ public class Maven2RepositoryMetadataResolverTest try { - resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); + resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "mislocated-pom", "1.0" ); fail( "Should have received an exception due to mislocated POM" ); } catch ( MetadataResolutionException e ) @@ -364,7 +370,8 @@ public class Maven2RepositoryMetadataResolverTest { assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); - FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-pom", "1.0" ); + FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test", "missing-pom", + "1.0" ); assertNull( metadata ); assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); @@ -377,84 +384,87 @@ public class Maven2RepositoryMetadataResolverTest public void testGetRootNamespaces() { - assertEquals( Arrays.asList( "com", "org" ), resolver.getRootNamespaces( TEST_REPO_ID ) ); + assertEquals( Arrays.asList( "com", "org" ), resolver.listRootNamespaces( TEST_REPO_ID, ALL ) ); } public void testGetNamespaces() { - assertEquals( Arrays.asList( "example" ), resolver.getNamespaces( TEST_REPO_ID, "com" ) ); - assertEquals( Arrays.asList( "test" ), resolver.getNamespaces( TEST_REPO_ID, "com.example" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "com.example.test" ) ); - - assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.getNamespaces( TEST_REPO_ID, "org" ) ); - assertEquals( Arrays.asList( "archiva", "maven" ), resolver.getNamespaces( TEST_REPO_ID, "org.apache" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ); - assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.plugins" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.shared" ) ); - - assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) ); + assertEquals( Arrays.asList( "example" ), resolver.listNamespaces( TEST_REPO_ID, "com", ALL ) ); + assertEquals( Arrays.asList( "test" ), resolver.listNamespaces( TEST_REPO_ID, "com.example", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "com.example.test", + ALL ) ); + + assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.listNamespaces( TEST_REPO_ID, "org", ALL ) ); + assertEquals( Arrays.asList( "archiva", "maven" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.archiva", + ALL ) ); + assertEquals( Arrays.asList( "plugins", "shared" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven", + ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, + "org.apache.maven.plugins", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven.shared", + ALL ) ); + + assertEquals( Arrays.asList( "plexus" ), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus.plexus", + ALL ) ); } public void testGetProjects() { - assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com.example" ) ); + assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "com", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "com.example", ALL ) ); assertEquals( Arrays.asList( "incomplete-metadata", "invalid-pom", "malformed-metadata", "mislocated-pom", - "missing-metadata", "test-artifact" ), resolver.getProjects( TEST_REPO_ID, - "com.example.test" ) ); + "missing-metadata", "test-artifact" ), resolver.listProjects( TEST_REPO_ID, + "com.example.test", + ALL ) ); - assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org" ) ); - assertEquals( Arrays.asList( "apache" ), resolver.getProjects( TEST_REPO_ID, "org.apache" ) ); + assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org", ALL ) ); + assertEquals( Arrays.asList( "apache" ), resolver.listProjects( TEST_REPO_ID, "org.apache", ALL ) ); assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ), - resolver.getProjects( TEST_REPO_ID, "org.apache.archiva" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) ); - assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, - "org.apache.maven.plugins" ) ); - assertEquals( Arrays.asList( "maven-downloader" ), resolver.getProjects( TEST_REPO_ID, - "org.apache.maven.shared" ) ); + resolver.listProjects( TEST_REPO_ID, "org.apache.archiva", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven", ALL ) ); + assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven.plugins", + ALL ) ); + assertEquals( Arrays.asList( "maven-downloader" ), resolver.listProjects( TEST_REPO_ID, + "org.apache.maven.shared", ALL ) ); } public void testGetProjectVersions() { - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "incomplete-metadata" ) ); - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "malformed-metadata" ) ); - assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "missing-metadata" ) ); - assertEquals( Arrays.asList( "1.0" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", - "invalid-pom" ) ); - - assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache", - "apache" ) ); - - assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-base" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-common" ) ); - assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-modules" ) ); - assertEquals( Arrays.asList( "3" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", - "archiva-parent" ) ); - - assertEquals( Collections.<String>emptyList(), resolver.getProjectVersions( TEST_REPO_ID, - "org.apache.maven.shared", - "maven-downloader" ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "incomplete-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "malformed-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "missing-metadata", ALL ) ); + assertEquals( Arrays.asList( "1.0" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test", + "invalid-pom", ALL ) ); + + assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache", + "apache", ALL ) ); + + assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.listProjectVersions( TEST_REPO_ID, + "org.apache.archiva", "archiva", + ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-base", ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-common", ALL ) ); + assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-modules", ALL ) ); + assertEquals( Arrays.asList( "3" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva", + "archiva-parent", ALL ) ); + + assertEquals( Collections.<String>emptyList(), resolver.listProjectVersions( TEST_REPO_ID, + "org.apache.maven.shared", + "maven-downloader", ALL ) ); } public void testGetArtifacts() { - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2" ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ); assertEquals( 3, artifacts.size() ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -474,10 +484,8 @@ public class Maven2RepositoryMetadataResolverTest { ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList( "plexus-spring-1.2.pom" ) ); - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2", filter ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) ); assertEquals( 2, artifacts.size() ); Collections.sort( artifacts, new Comparator<ArtifactMetadata>() { @@ -493,10 +501,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactsTimestampedSnapshots() { - List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, - "com.example.test", - "missing-metadata", - "1.0-SNAPSHOT" ) ); + List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata( + TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", ALL ) ); assertEquals( 1, artifacts.size() ); ArtifactMetadata artifact = artifacts.get( 0 ); diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index 58c0aa3c4..76cdd2c7d 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -565,7 +565,7 @@ public class FileMetadataRepository return artifacts; } - public void deleteArtifact( String repoId, String namespace, String project, String version, String id ) + public void removeArtifact( String repoId, String namespace, String project, String version, String id ) { File directory = new File( getDirectory( repoId ), namespace + "/" + project + "/" + version ); @@ -600,7 +600,7 @@ public class FileMetadataRepository } } - public void deleteRepository( String repoId ) + public void removeRepository( String repoId ) { try { diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java index cd21eeb3e..013bfbab9 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java @@ -589,7 +589,7 @@ public class JcrMetadataRepository return artifacts; } - public void deleteArtifact( String repositoryId, String namespace, String projectId, String projectVersion, + public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion, String id ) throws MetadataRepositoryException { @@ -608,7 +608,7 @@ public class JcrMetadataRepository } } - public void deleteRepository( String repositoryId ) + public void removeRepository( String repositoryId ) throws MetadataRepositoryException { try |