diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index 9f06b89aa..3d367b422 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -25,7 +25,7 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata; 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.storage.StorageMetadataResolver; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.apache.maven.archiva.common.utils.VersionUtil; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ConfigurationNames; @@ -90,7 +90,7 @@ public class ArchivaMetadataCreationConsumer * * @plexus.requirement role-hint="maven2" */ - private StorageMetadataResolver storageResolver; + private RepositoryStorage repositoryStorage; private static final Logger log = LoggerFactory.getLogger( ArchivaMetadataCreationConsumer.class ); @@ -141,7 +141,7 @@ public class ArchivaMetadataCreationConsumer // the initial scan. Any request for this information will be intercepted and populated on-demand // or picked up by subsequent scans - ArtifactMetadata artifact = storageResolver.getArtifactForPath( repoId, path ); + ArtifactMetadata artifact = repositoryStorage.readArtifactMetadataFromPath( repoId, path ); ProjectMetadata project = new ProjectMetadata(); project.setNamespace( artifact.getNamespace() ); @@ -152,8 +152,8 @@ public class ArchivaMetadataCreationConsumer ProjectVersionMetadata versionMetadata = null; try { - versionMetadata = storageResolver.getProjectVersion( repoId, artifact.getNamespace(), artifact.getProject(), - projectVersion ); + versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId, artifact.getNamespace(), + artifact.getProject(), projectVersion ); } catch ( MetadataResolutionException e ) { diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 60ebf4ee7..3c9756f88 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -19,17 +19,17 @@ package org.apache.archiva.metadata.repository; * under the License. */ -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; - 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.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + public class TestMetadataRepository implements MetadataRepository { @@ -144,12 +144,12 @@ 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. } @@ -160,7 +160,8 @@ public class TestMetadataRepository return null; //To change body of implemented methods use File | Settings | File Templates. } - public List getArtifacts(String repositoryId){ + public List getArtifacts( String repositoryId ) + { return null; } } diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java index 1b2c44b73..686ea2663 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java @@ -19,15 +19,8 @@ package org.apache.archiva.rss.processor; * under the License. */ -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; - +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndFeed; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.ProjectMetadata; @@ -38,8 +31,14 @@ import org.apache.archiva.metadata.repository.MetadataResolutionException; import org.apache.archiva.rss.RssFeedGenerator; import org.codehaus.plexus.spring.PlexusInSpringTestCase; -import com.sun.syndication.feed.synd.SyndEntry; -import com.sun.syndication.feed.synd.SyndFeed; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; public class NewArtifactsRssFeedProcessorTest extends PlexusInSpringTestCase @@ -95,13 +94,14 @@ public class NewArtifactsRssFeedProcessorTest assertTrue( feed.getTitle().equals( "New Artifacts in Repository 'test-repo'" ) ); assertTrue( feed.getDescription().equals( - "New artifacts found in repository 'test-repo' during repository scan." ) ); + "New artifacts found in repository 'test-repo' during repository scan." ) ); assertTrue( feed.getLanguage().equals( "en-us" ) ); assertTrue( feed.getPublishedDate().equals( whenGathered ) ); List entries = feed.getEntries(); assertEquals( entries.size(), 1 ); - assertTrue( entries.get( 0 ).getTitle().equals( "New Artifacts in Repository 'test-repo' as of " + whenGathered ) ); + assertTrue( entries.get( 0 ).getTitle().equals( + "New Artifacts in Repository 'test-repo' as of " + whenGathered ) ); assertTrue( entries.get( 0 ).getPublishedDate().equals( whenGathered ) ); } @@ -140,12 +140,12 @@ public class NewArtifactsRssFeedProcessorTest throw new UnsupportedOperationException(); } - public void deleteArtifact( String arg0, String arg1, String arg2, String arg3, String arg4 ) + public void removeArtifact( String arg0, String arg1, String arg2, String arg3, String arg4 ) { throw new UnsupportedOperationException(); } - public void deleteRepository( String arg0 ) + public void removeRepository( String arg0 ) { throw new UnsupportedOperationException(); } @@ -287,10 +287,10 @@ public class NewArtifactsRssFeedProcessorTest { this.artifactsByDateRange = artifactsByDateRange; } - + public List getArtifacts( String repositoryId ) { - return artifactsByDateRange; + return artifactsByDateRange; } } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java index 1d5c7d456..bd7ef5155 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/BrowseAction.java @@ -78,7 +78,7 @@ public class BrowseAction Set namespacesToCollapse = new LinkedHashSet(); for ( String repoId : selectedRepos ) { - namespacesToCollapse.addAll( metadataResolver.getRootNamespaces( repoId ) ); + namespacesToCollapse.addAll( metadataResolver.resolveRootNamespaces( repoId ) ); } for ( String n : namespacesToCollapse ) @@ -97,7 +97,7 @@ public class BrowseAction Set subNamespaces = new LinkedHashSet(); for ( String repoId : repoIds ) { - subNamespaces.addAll( metadataResolver.getNamespaces( repoId, n ) ); + subNamespaces.addAll( metadataResolver.resolveNamespaces( repoId, n ) ); } if ( subNamespaces.size() != 1 ) { @@ -111,7 +111,7 @@ public class BrowseAction { for ( String repoId : repoIds ) { - Collection projects = metadataResolver.getProjects( repoId, n ); + Collection projects = metadataResolver.resolveProjects( repoId, n ); if ( projects != null && !projects.isEmpty() ) { if ( log.isDebugEnabled() ) @@ -146,9 +146,9 @@ public class BrowseAction Set namespacesToCollapse = new LinkedHashSet(); for ( String repoId : selectedRepos ) { - namespacesToCollapse.addAll( metadataResolver.getNamespaces( repoId, groupId ) ); + namespacesToCollapse.addAll( metadataResolver.resolveNamespaces( repoId, groupId ) ); - projects.addAll( metadataResolver.getProjects( repoId, groupId ) ); + projects.addAll( metadataResolver.resolveProjects( repoId, groupId ) ); } // TODO: this logic should be optional, particularly remembering we want to keep this code simple @@ -199,7 +199,7 @@ public class BrowseAction Set versions = new LinkedHashSet(); for ( String repoId : selectedRepos ) { - versions.addAll( metadataResolver.getProjectVersions( repoId, groupId, artifactId ) ); + versions.addAll( metadataResolver.resolveProjectVersions( repoId, groupId, artifactId ) ); } // TODO: sort by known version ordering method @@ -230,7 +230,8 @@ public class BrowseAction { try { - versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); + versionMetadata = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId, + version ); } catch ( MetadataResolutionException e ) { diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java index d389e283d..ef608fa7c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/DeleteArtifactAction.java @@ -238,7 +238,7 @@ public class DeleteArtifactAction // TODO: mismatch between artifact (snapshot) version and project (base) version here if ( artifact.getVersion().equals( version ) ) { - metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), + metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(), artifact.getProject(), artifact.getVersion(), artifact.getId() ); // TODO: move into the metadata repository proper - need to differentiate attachment of diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java index 93dae804c..f75229ec8 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java @@ -157,7 +157,7 @@ public class ShowArtifactAction // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used try { - versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); + versionMetadata = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId, version ); } catch ( MetadataResolutionException e ) { @@ -174,9 +174,9 @@ public class ShowArtifactAction List artifacts; try { - artifacts = new ArrayList( metadataResolver.getArtifacts( repoId, groupId, - artifactId, - version ) ); + artifacts = new ArrayList( metadataResolver.resolveArtifacts( repoId, groupId, + artifactId, + version ) ); } catch ( MetadataResolutionException e ) { @@ -265,7 +265,7 @@ public class ShowArtifactAction for ( String repoId : getObservableRepos() ) { // TODO: what about if we want to see this irrespective of version? - references.addAll( metadataResolver.getProjectReferences( repoId, groupId, artifactId, version ) ); + references.addAll( metadataResolver.resolveProjectReferences( repoId, groupId, artifactId, version ) ); } this.dependees = references; diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java index 92fcc959e..a4fe04d9a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java @@ -187,7 +187,7 @@ public class DeleteManagedRepositoryAction private void cleanupDatabase( String repoId ) throws MetadataRepositoryException { - metadataRepository.deleteRepository( repoId ); + metadataRepository.removeRepository( repoId ); } public ManagedRepositoryConfiguration getRepository() diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java index 164922604..2dc4a0369 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java @@ -184,12 +184,12 @@ 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. } @@ -200,7 +200,8 @@ public class TestMetadataRepository return artifacts; } - public List getArtifacts(String repositoryId){ + public List getArtifacts( String repositoryId ) + { return artifacts; } } \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java index 052ad0fc2..2e94a4068 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataResolver.java @@ -19,6 +19,11 @@ package org.apache.archiva.metadata.repository.memory; * under the License. */ +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; +import org.apache.archiva.metadata.repository.MetadataResolver; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -27,12 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -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.MetadataResolver; - public class TestMetadataResolver implements MetadataResolver { @@ -49,38 +48,24 @@ public class TestMetadataResolver private Map> versionsInProject = new HashMap>(); - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - { - ProjectMetadata metadata = new ProjectMetadata(); - metadata.setNamespace( namespace ); - metadata.setId( projectId ); - return metadata; - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) { return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); } - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - { - throw new UnsupportedOperationException(); - } - - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveProjectReferences( String repoId, String namespace, + String projectId, String projectVersion ) { return references.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); } - public Collection getRootNamespaces( String repoId ) + public Collection resolveRootNamespaces( String repoId ) { - return getNamespaces( repoId, null ); + return resolveNamespaces( repoId, null ); } - public Collection getNamespaces( String repoId, String baseNamespace ) + public Collection resolveNamespaces( String repoId, String baseNamespace ) { Set namespaces = new LinkedHashSet(); int fromIndex = baseNamespace != null ? baseNamespace.length() + 1 : 0; @@ -102,23 +87,23 @@ public class TestMetadataResolver return namespaces; } - public Collection getProjects( String repoId, String namespace ) + public Collection resolveProjects( String repoId, String namespace ) { Collection list = projectsInNamespace.get( namespace ); return list != null ? list : Collections.emptyList(); } - public Collection getProjectVersions( String repoId, String namespace, String projectId ) + public Collection resolveProjectVersions( String repoId, String namespace, String projectId ) { Collection list = versionsInProject.get( namespace + ":" + projectId ); return list != null ? list : Collections.emptyList(); } - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) { - List artifacts = - this.artifacts.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); + List artifacts = this.artifacts.get( createMapKey( repoId, namespace, projectId, + projectVersion ) ); return ( artifacts != null ? artifacts : Collections.emptyList() ); } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java index 9a68f3c55..dbe9aef7b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java @@ -95,7 +95,7 @@ public class DeleteManagedRepositoryActionTest MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); - metadataRepository.deleteRepository( REPO_ID ); + metadataRepository.removeRepository( REPO_ID ); action.setMetadataRepository( metadataRepository ); metadataRepositoryControl.replay(); @@ -178,7 +178,7 @@ public class DeleteManagedRepositoryActionTest { MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); - metadataRepository.deleteRepository( REPO_ID ); + metadataRepository.removeRepository( REPO_ID ); metadataRepositoryControl.replay(); action.setMetadataRepository( metadataRepository ); return metadataRepositoryControl; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index d5dae295c..3c9756f88 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -19,17 +19,17 @@ package org.apache.archiva.metadata.repository; * under the License. */ -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; - 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.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + public class TestMetadataRepository implements MetadataRepository { @@ -144,12 +144,12 @@ 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. } @@ -159,7 +159,9 @@ public class TestMetadataRepository { return null; //To change body of implemented methods use File | Settings | File Templates. } - public List getArtifacts(String repositoryId){ + + public List getArtifacts( String repositoryId ) + { return null; } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java index 39bfe8286..1250ec447 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java @@ -66,7 +66,7 @@ import java.util.Map; /** * AdministrationServiceImpl - * + * * @version $Id: AdministrationServiceImpl.java */ public class AdministrationServiceImpl @@ -197,15 +197,15 @@ public class AdministrationServiceImpl // delete from file system repoContent.deleteVersion( ref ); - Collection artifacts = - metadataRepository.getArtifacts( repoId, groupId, artifactId, version ); + Collection artifacts = metadataRepository.getArtifacts( repoId, groupId, artifactId, + version ); for ( ArtifactMetadata artifact : artifacts ) { // TODO: mismatch between artifact (snapshot) version and project (base) version here if ( artifact.getVersion().equals( version ) ) { - metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), + metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(), artifact.getProject(), artifact.getVersion(), artifact.getId() ); // TODO: move into the metadata repository proper - need to differentiate attachment of @@ -295,9 +295,9 @@ public class AdministrationServiceImpl 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() ); + ManagedRepository repo = new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", + repoConfig.getLayout(), repoConfig.isSnapshots(), + repoConfig.isReleases() ); managedRepos.add( repo ); } @@ -316,9 +316,8 @@ public class AdministrationServiceImpl for ( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs ) { - RemoteRepository repo = - new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(), - repoConfig.getLayout() ); + RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(), + repoConfig.getLayout() ); remoteRepos.add( repo ); } @@ -354,18 +353,18 @@ public class AdministrationServiceImpl if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) ) { - throw new Exception( "Unable to add new repository with id [" + repoId - + "], that id already exists as a managed repository." ); + throw new Exception( "Unable to add new repository with id [" + repoId + + "], that id already exists as a managed repository." ); } else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) ) { - throw new Exception( "Unable to add new repository with id [" + repoId - + "], that id already exists as a remote repository." ); + throw new Exception( "Unable to add new repository with id [" + repoId + + "], that id already exists as a remote repository." ); } else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) ) { - throw new Exception( "Unable to add new repository with id [" + repoId - + "], that id already exists as a repository group." ); + throw new Exception( "Unable to add new repository with id [" + repoId + + "], that id already exists as a repository group." ); } if ( !validator.validate( cronExpression ) ) @@ -408,7 +407,7 @@ public class AdministrationServiceImpl throw new Exception( "A repository with that id does not exist" ); } - metadataRepository.deleteRepository( repository.getId() ); + metadataRepository.removeRepository( repository.getId() ); repositoryStatisticsManager.deleteStatistics( repository.getId() ); config.removeManagedRepository( repository ); @@ -440,7 +439,8 @@ public class AdministrationServiceImpl List repoGroups = repoToGroupMap.get( repository.getId() ); for ( String repoGroup : repoGroups ) { - archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( repository.getId() ); + archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( + repository.getId() ); } } } @@ -457,10 +457,9 @@ public class AdministrationServiceImpl { throw new Exception( "A repository with that id does not exist" ); } - ManagedRepository repo = - new ManagedRepository( managedRepository.getId(), managedRepository.getName(), "URL", - managedRepository.getLayout(), managedRepository.isSnapshots(), - managedRepository.isReleases() ); + ManagedRepository repo = new ManagedRepository( managedRepository.getId(), managedRepository.getName(), "URL", + managedRepository.getLayout(), managedRepository.isSnapshots(), + managedRepository.isReleases() ); return repo; } @@ -490,16 +489,16 @@ public class AdministrationServiceImpl log.info( "Repository to be merged contains releases only.." ); if ( skipConflicts ) { - List conflicts = - repositoryMerger.getConflictingArtifacts( repoId, stagingId ); + List conflicts = repositoryMerger.getConflictingArtifacts( repoId, + stagingId ); if ( log.isDebugEnabled() ) { log.debug( "Artifacts in conflict.." ); - for( ArtifactMetadata metadata : conflicts ) + for ( ArtifactMetadata metadata : conflicts ) { log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" + - metadata.getProjectVersion() ); + metadata.getProjectVersion() ); } } @@ -519,16 +518,16 @@ public class AdministrationServiceImpl log.info( "Repository to be merged has snapshot artifacts.." ); if ( skipConflicts ) { - List conflicts = - repositoryMerger.getConflictingArtifacts( repoId, stagingId ); + List conflicts = repositoryMerger.getConflictingArtifacts( repoId, + stagingId ); if ( log.isDebugEnabled() ) { log.debug( "Artifacts in conflict.." ); - for( ArtifactMetadata metadata : conflicts ) + for ( ArtifactMetadata metadata : conflicts ) { log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" + - metadata.getProjectVersion() ); + metadata.getProjectVersion() ); } } @@ -536,19 +535,21 @@ public class AdministrationServiceImpl log.debug( "Source artifacts size :: " + sourceArtifacts.size() ); - Filter artifactsWithOutConflicts = - new IncludesFilter( sourceArtifacts ); + Filter artifactsWithOutConflicts = new IncludesFilter( + sourceArtifacts ); repositoryMerger.merge( stagingId, repoId, artifactsWithOutConflicts ); - log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" + - repoId + "'." ); + log.info( + "Staging repository '" + stagingId + "' merged successfully with managed repo '" + repoId + + "'." ); } else { repositoryMerger.merge( stagingId, repoId ); - - log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" + - repoId + "'." ); + + log.info( + "Staging repository '" + stagingId + "' merged successfully with managed repo '" + repoId + + "'." ); } } } @@ -593,8 +594,8 @@ public class AdministrationServiceImpl } if ( !file.exists() || !file.isDirectory() ) { - throw new IOException( "Unable to add repository - no write access, can not create the root directory: " - + file ); + throw new IOException( + "Unable to add repository - no write access, can not create the root directory: " + file ); } configuration.addManagedRepository( repository ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java index 6cf6fd91a..2f998f406 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java @@ -61,7 +61,7 @@ public class SearchServiceImpl this.metadataRepository = metadataRepository; } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public List quickSearch( String queryString ) throws Exception { @@ -85,9 +85,9 @@ public class SearchServiceImpl // slight behaviour change to previous implementation: instead of allocating "jar" when not // found in the database, we can rely on the metadata repository to create it on the fly. We // just allocate the default packaging if the Maven facet is not found. - FacetedMetadata model = - metadataResolver.getProjectVersion( repoId, resultHit.getGroupId(), - resultHit.getArtifactId(), version ); + FacetedMetadata model = metadataResolver.resolveProjectVersion( repoId, resultHit.getGroupId(), + resultHit.getArtifactId(), + version ); if ( model != null ) { @@ -143,7 +143,7 @@ public class SearchServiceImpl for ( String repoId : observableRepos ) { - Collection results = metadataResolver.getProjectVersions( repoId, groupId, artifactId ); + Collection results = metadataResolver.resolveProjectVersions( repoId, groupId, artifactId ); for ( final String version : results ) { @@ -176,16 +176,16 @@ public class SearchServiceImpl for ( String repoId : observableRepos ) { - ProjectVersionMetadata model = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); + ProjectVersionMetadata model = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId, + version ); if ( model != null ) { List dependencies = new ArrayList(); List modelDeps = model.getDependencies(); for ( org.apache.archiva.metadata.model.Dependency dep : modelDeps ) { - Dependency dependency = - new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(), - dep.getType(), dep.getScope() ); + Dependency dependency = new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), + dep.getClassifier(), dep.getType(), dep.getScope() ); dependencies.add( dependency ); } return dependencies; @@ -211,12 +211,12 @@ public class SearchServiceImpl for ( String repoId : observableRepos ) { - Collection refs = - metadataResolver.getProjectReferences( repoId, groupId, artifactId, version ); + Collection refs = metadataResolver.resolveProjectReferences( repoId, groupId, + artifactId, version ); for ( ProjectVersionReference ref : refs ) { - artifacts.add( - new Artifact( repoId, ref.getNamespace(), ref.getProjectId(), ref.getProjectVersion(), "" ) ); + artifacts.add( new Artifact( repoId, ref.getNamespace(), ref.getProjectId(), ref.getProjectVersion(), + "" ) ); } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java index a32361767..d4126351f 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImplTest.java @@ -19,15 +19,6 @@ package org.apache.archiva.web.xmlrpc.services; * under the License. */ -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - import org.apache.archiva.audit.AuditEvent; import org.apache.archiva.audit.AuditListener; import org.apache.archiva.metadata.model.ArtifactMetadata; @@ -63,9 +54,18 @@ import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.easymock.MockControl; import org.easymock.classextension.MockClassControl; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** * AdministrationServiceImplTest - * + * * @version $Id: AdministrationServiceImplTest.java */ public class AdministrationServiceImplTest @@ -174,10 +174,9 @@ public class AdministrationServiceImplTest auditListenerControl = MockControl.createControl( AuditListener.class ); auditListener = (AuditListener) auditListenerControl.getMock(); - service = - new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, metadataRepository, - repositoryTaskScheduler, Collections.singletonList( listener ), - repositoryStatisticsManager, repositoryMerger, auditListener ); + service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, + metadataRepository, repositoryTaskScheduler, Collections.singletonList( + listener ), repositoryStatisticsManager, repositoryMerger, auditListener ); } /* Tests for repository consumers */ @@ -338,8 +337,9 @@ public class AdministrationServiceImplTest metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), - artifact.getVersion() ), artifacts ); - metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), + artifact.getVersion() ), + artifacts ); + metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), artifact.getVersion(), artifact.getId() ); listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), @@ -394,8 +394,9 @@ public class AdministrationServiceImplTest metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), - artifact.getVersion() ), artifacts ); - metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), + artifact.getVersion() ), + artifacts ); + metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), artifact.getVersion(), artifact.getId() ); listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), @@ -474,8 +475,8 @@ public class AdministrationServiceImplTest FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) ); - ManagedRepositoryConfiguration managedRepo = - createManagedRepo( "internal", layout, "Internal Repository", true, false ); + ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", layout, "Internal Repository", true, + false ); managedRepo.setLocation( repoDir.getAbsolutePath() ); return managedRepo; } @@ -509,13 +510,16 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), - createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), createManagedRepo( "internal", + "default", + "Internal Repository", + true, + false ) ); RepositoryTask task = new RepositoryTask(); - repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), - false ); + repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( + "internal" ), false ); repositoryTaskScheduler.queueTask( task ); repositoryTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); @@ -544,11 +548,14 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), - createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); + configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), createManagedRepo( "internal", + "default", + "Internal Repository", + true, + false ) ); - repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), - true ); + repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( + "internal" ), true ); archivaConfigControl.replay(); configControl.replay(); @@ -625,7 +632,8 @@ public class AdministrationServiceImplTest List remoteRepos = new ArrayList(); remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2" ) ); - remoteRepos.add( createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", "http://dummy.com/dummy" ) ); + remoteRepos.add( createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", + "http://dummy.com/dummy" ) ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos ); @@ -673,8 +681,9 @@ public class AdministrationServiceImplTest throws Exception { archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); - configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), - createManagedRepo( "repo", "default", "repo", true, false ) ); + configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), createManagedRepo( "repo", "default", + "repo", true, + false ) ); configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), null ); archivaConfigControl.replay(); @@ -830,8 +839,8 @@ public class AdministrationServiceImplTest String stageLocation = releaseLocation + "-stage"; ManagedRepositoryConfiguration managedRepo = createManagedRepo( "repo1", "default", "repo", true, false ); - RemoteRepositoryConfiguration remoteRepo = - createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2" ); + RemoteRepositoryConfiguration remoteRepo = createRemoteRepository( "central", "Central Repository", "default", + "http://repo1.maven.org/maven2" ); List repositories = new ArrayList(); repositories.add( managedRepo.getName() ); RepositoryGroupConfiguration repoGroup = createRepoGroupConfig( "repoGroup", repositories ); @@ -861,9 +870,8 @@ public class AdministrationServiceImplTest configControl.replay(); assertFalse( new File( releaseLocation ).isDirectory() ); assertFalse( new File( stageLocation ).isDirectory() ); - boolean success = - service.addManagedRepository( repoId, layout, name, releaseLocation, true, true, false, true, - "0 15 3 * * ? *" ); + boolean success = service.addManagedRepository( repoId, layout, name, releaseLocation, true, true, false, true, + "0 15 3 * * ? *" ); assertTrue( success ); assertTrue( new File( releaseLocation ).isDirectory() ); assertTrue( new File( stageLocation ).isDirectory() ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java index 30be81bbf..7c224cf99 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java @@ -134,9 +134,10 @@ public class SearchServiceImplTest facet.setPackaging( "war" ); model.addFacet( facet ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), - model ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror", + ARCHIVA_TEST_GROUP_ID, + "archiva-webapp", "1.0" ), + model ); userReposControl.replay(); searchControl.replay(); @@ -188,15 +189,17 @@ public class SearchServiceImplTest searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), results ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, - "1.0" ), null ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), null ); ProjectVersionMetadata model = new ProjectVersionMetadata(); model.setId( "1.0" ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, - "1.0" ), model ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "public.releases", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), model ); userReposControl.replay(); searchControl.replay(); @@ -253,9 +256,10 @@ public class SearchServiceImplTest facet.setPackaging( "jar" ); model.addFacet( facet ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, - "1.0" ), model ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), model ); userReposControl.replay(); searchControl.replay(); @@ -310,8 +314,8 @@ public class SearchServiceImplTest public void testGetArtifactByChecksum() throws Exception { - userReposControl.expectAndReturn( userRepos.getObservableRepositories(), - Collections.singletonList( TEST_REPO ) ); + userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( + TEST_REPO ) ); Date whenGathered = new Date(); @@ -345,12 +349,14 @@ public class SearchServiceImplTest observableRepoIds.add( "public.releases" ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersions( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ), - Arrays.asList( "1.0", "1.1-beta-2", "1.2" ) ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersions( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ), - Arrays.asList( "1.1-beta-1", "1.1", "1.2.1-SNAPSHOT" ) ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "repo1.mirror", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID ), + Arrays.asList( "1.0", "1.1-beta-2", "1.2" ) ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "public.releases", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID ), + Arrays.asList( "1.1-beta-1", "1.1", "1.2.1-SNAPSHOT" ) ); userReposControl.replay(); metadataResolverControl.replay(); @@ -364,19 +370,16 @@ public class SearchServiceImplTest assertEquals( 6, artifacts.size() ); assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "pom" ), artifacts.get( 0 ) ); - assertEquals( - new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-1", "pom" ), - artifacts.get( 3 ) ); - assertEquals( - new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-2", "pom" ), - artifacts.get( 1 ) ); + assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-1", + "pom" ), artifacts.get( 3 ) ); + assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-2", + "pom" ), artifacts.get( 1 ) ); assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1", "pom" ), artifacts.get( 4 ) ); assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2", "pom" ), artifacts.get( 2 ) ); - assertEquals( - new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2.1-SNAPSHOT", "pom" ), - artifacts.get( 5 ) ); + assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, + "1.2.1-SNAPSHOT", "pom" ), artifacts.get( 5 ) ); } public void testGetArtifactVersionsByDateArtifactExists() @@ -415,15 +418,15 @@ public class SearchServiceImplTest model.addDependency( dependency ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), - model ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), model ); metadataResolverControl.replay(); userReposControl.replay(); - List dependencies = - searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ); + List dependencies = searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ); metadataResolverControl.verify(); userReposControl.verify(); @@ -441,9 +444,9 @@ public class SearchServiceImplTest String repoId = "repo1.mirror"; userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), - null ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), null ); userReposControl.replay(); metadataResolverControl.replay(); @@ -495,9 +498,10 @@ public class SearchServiceImplTest dependeeModels.add( dependeeModel ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectReferences( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), - dependeeModels ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( repoId, + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), dependeeModels ); metadataResolverControl.replay(); userReposControl.replay(); @@ -509,10 +513,10 @@ public class SearchServiceImplTest assertNotNull( dependees ); assertEquals( 2, dependees.size() ); - assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-one", "1.0", "" ), - dependees.get( 0 ) ); - assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-two", "1.0", "" ), - dependees.get( 1 ) ); + assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-one", "1.0", "" ), dependees.get( + 0 ) ); + assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-two", "1.0", "" ), dependees.get( + 1 ) ); } public void testGetDependeesArtifactDoesNotExist() @@ -525,12 +529,16 @@ public class SearchServiceImplTest // no longer differentiating between a project not being present and a project that is present but with // no references. If it is later determined to be needed, we will need to modify the metadata content repository userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectReferences( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, - "1.0" ), Collections.emptyList() ); - metadataResolverControl.expectAndReturn( - metadataResolver.getProjectReferences( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, - "1.0" ), Collections.emptyList() ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "repo1.mirror", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), + Collections.emptyList() ); + metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "public.releases", + ARCHIVA_TEST_GROUP_ID, + ARCHIVA_TEST_ARTIFACT_ID, + "1.0" ), + Collections.emptyList() ); userReposControl.replay(); metadataResolverControl.replay(); diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 9fd802db9..7e4e22830 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -25,7 +25,7 @@ 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.filter.ExcludesFilter; -import org.apache.archiva.metadata.repository.storage.StorageMetadataResolver; +import org.apache.archiva.metadata.repository.storage.RepositoryStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,19 +50,12 @@ public class DefaultMetadataResolver * * @plexus.requirement role-hint="maven2" */ - private StorageMetadataResolver storageResolver; + private RepositoryStorage repositoryStorage; private static final Logger log = LoggerFactory.getLogger( DefaultMetadataResolver.class ); - public ProjectMetadata getProject( String repoId, String namespace, String projectId ) - throws MetadataResolutionException - { - // TODO: intercept - return metadataRepository.getProject( repoId, namespace, projectId ); - } - - public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) + public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException { ProjectVersionMetadata metadata = metadataRepository.getProjectVersion( repoId, namespace, projectId, @@ -74,7 +67,7 @@ public class DefaultMetadataResolver // may then work here and be more efficient than always trying again) if ( metadata == null || metadata.isIncomplete() ) { - metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion ); + metadata = repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion ); if ( metadata != null ) { if ( log.isDebugEnabled() ) @@ -117,16 +110,8 @@ public class DefaultMetadataResolver return metadata; } - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - throws MetadataResolutionException - { - // TODO: intercept - return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion ); - } - - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveProjectReferences( String repoId, String namespace, + String projectId, String projectVersion ) throws MetadataResolutionException { // TODO: is this assumption correct? could a storage mech. actually know all references in a non-Maven scenario? @@ -134,11 +119,11 @@ public class DefaultMetadataResolver return metadataRepository.getProjectReferences( repoId, namespace, projectId, projectVersion ); } - public Collection getRootNamespaces( String repoId ) + public Collection resolveRootNamespaces( String repoId ) throws MetadataResolutionException { Collection namespaces = metadataRepository.getRootNamespaces( repoId ); - Collection storageNamespaces = storageResolver.getRootNamespaces( repoId, new ExcludesFilter( + Collection storageNamespaces = repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter( namespaces ) ); if ( storageNamespaces != null && !storageNamespaces.isEmpty() ) { @@ -163,15 +148,15 @@ public class DefaultMetadataResolver return namespaces; } - public Collection getNamespaces( String repoId, String namespace ) + public Collection resolveNamespaces( String repoId, String namespace ) throws MetadataResolutionException { Collection namespaces = metadataRepository.getNamespaces( repoId, namespace ); Collection exclusions = new ArrayList( namespaces ); exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) ); - Collection storageNamespaces = storageResolver.getNamespaces( repoId, namespace, - new ExcludesFilter( - exclusions ) ); + Collection storageNamespaces = repositoryStorage.listNamespaces( repoId, namespace, + new ExcludesFilter( + exclusions ) ); if ( storageNamespaces != null && !storageNamespaces.isEmpty() ) { if ( log.isDebugEnabled() ) @@ -195,14 +180,14 @@ public class DefaultMetadataResolver return namespaces; } - public Collection getProjects( String repoId, String namespace ) + public Collection resolveProjects( String repoId, String namespace ) throws MetadataResolutionException { Collection projects = metadataRepository.getProjects( repoId, namespace ); Collection exclusions = new ArrayList( projects ); exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) ); - Collection storageProjects = storageResolver.getProjects( repoId, namespace, new ExcludesFilter( - exclusions ) ); + Collection storageProjects = repositoryStorage.listProjects( repoId, namespace, + new ExcludesFilter( exclusions ) ); if ( storageProjects != null && !storageProjects.isEmpty() ) { if ( log.isDebugEnabled() ) @@ -211,7 +196,7 @@ public class DefaultMetadataResolver } for ( String projectId : storageProjects ) { - ProjectMetadata projectMetadata = storageResolver.getProject( repoId, namespace, projectId ); + ProjectMetadata projectMetadata = repositoryStorage.readProjectMetadata( repoId, namespace, projectId ); if ( projectMetadata != null ) { try @@ -230,13 +215,13 @@ public class DefaultMetadataResolver return projects; } - public Collection getProjectVersions( String repoId, String namespace, String projectId ) + public Collection resolveProjectVersions( String repoId, String namespace, String projectId ) throws MetadataResolutionException { Collection projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId ); - Collection storageProjectVersions = storageResolver.getProjectVersions( repoId, namespace, projectId, - new ExcludesFilter( - projectVersions ) ); + Collection storageProjectVersions = repositoryStorage.listProjectVersions( repoId, namespace, projectId, + new ExcludesFilter( + projectVersions ) ); if ( storageProjectVersions != null && !storageProjectVersions.isEmpty() ) { if ( log.isDebugEnabled() ) @@ -247,9 +232,10 @@ public class DefaultMetadataResolver { try { - ProjectVersionMetadata versionMetadata = storageResolver.getProjectVersion( repoId, namespace, - projectId, - projectVersion ); + ProjectVersionMetadata versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId, + namespace, + projectId, + projectVersion ); if ( versionMetadata != null ) { metadataRepository.updateProjectVersion( repoId, namespace, projectId, versionMetadata ); @@ -271,17 +257,18 @@ public class DefaultMetadataResolver return projectVersions; } - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException { Collection artifacts = metadataRepository.getArtifacts( repoId, namespace, projectId, projectVersion ); - Collection storageArtifacts = storageResolver.getArtifacts( repoId, namespace, projectId, - projectVersion, - new ExcludesFilter( - createArtifactIdList( - artifacts ) ) ); + Collection storageArtifacts = repositoryStorage.readArtifactsMetadata( repoId, namespace, + projectId, + projectVersion, + new ExcludesFilter( + createArtifactIdList( + artifacts ) ) ); if ( storageArtifacts != null && !storageArtifacts.isEmpty() ) { if ( log.isDebugEnabled() ) diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java index 130dc7300..f43fbc4fb 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java @@ -30,7 +30,6 @@ import java.util.Date; import java.util.List; public interface MetadataRepository - extends MetadataResolver { /** * Update metadata for a particular project in the metadata repository, or create it if it does not already exist. @@ -81,7 +80,7 @@ public interface MetadataRepository List getArtifactsByChecksum( String repositoryId, String checksum ) throws MetadataRepositoryException; - void deleteArtifact( String repositoryId, String namespace, String project, String version, String id ) + void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) throws MetadataRepositoryException; /** @@ -89,9 +88,49 @@ public interface MetadataRepository * * @param repositoryId the repository to delete */ - void deleteRepository( String repositoryId ) + void removeRepository( String repositoryId ) throws MetadataRepositoryException; List getArtifacts( String repositoryId ) throws MetadataRepositoryException; + + ProjectMetadata getProject( String repoId, String namespace, String projectId ) + throws MetadataResolutionException; + + ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataResolutionException; + + Collection getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) + throws MetadataResolutionException; + + /** + * Retrieve project references from the metadata repository. Note that this is not built into the content model for + * a project version as a reference may be present (due to reverse-lookup of dependencies) before the actual + * project is, and we want to avoid adding a stub model to the content repository. + * + * @param repoId the repository ID to look within + * @param namespace the namespace of the project to get references to + * @param projectId the identifier of the project to get references to + * @param projectVersion the version of the project to get references to + * @return a list of project references + */ + Collection getProjectReferences( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException; + + Collection getRootNamespaces( String repoId ) + throws MetadataResolutionException; + + Collection getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException; + + Collection getProjects( String repoId, String namespace ) + throws MetadataResolutionException; + + Collection getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException; + + Collection getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException; } diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java index 6de4ad562..4815ceb79 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataResolver.java @@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository; */ 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; @@ -28,13 +27,8 @@ import java.util.Collection; public interface MetadataResolver { - ProjectMetadata getProject( String repoId, String namespace, String projectId ) - throws MetadataResolutionException; - - ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion ) - throws MetadataResolutionException; - - Collection getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion ) + ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException; /** @@ -48,23 +42,23 @@ public interface MetadataResolver * @param projectVersion the version of the project to get references to * @return a list of project references */ - Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + Collection resolveProjectReferences( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException; - Collection getRootNamespaces( String repoId ) + Collection resolveRootNamespaces( String repoId ) throws MetadataResolutionException; - Collection getNamespaces( String repoId, String namespace ) + Collection resolveNamespaces( String repoId, String namespace ) throws MetadataResolutionException; - Collection getProjects( String repoId, String namespace ) + Collection resolveProjects( String repoId, String namespace ) throws MetadataResolutionException; - Collection getProjectVersions( String repoId, String namespace, String projectId ) + Collection resolveProjectVersions( String repoId, String namespace, String projectId ) throws MetadataResolutionException; - Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + Collection resolveArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) throws MetadataResolutionException; } diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java new file mode 100644 index 000000000..e780ec473 --- /dev/null +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/RepositoryStorage.java @@ -0,0 +1,52 @@ +package org.apache.archiva.metadata.repository.storage; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +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.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.filter.Filter; + +import java.util.Collection; + +public interface RepositoryStorage +{ + ProjectMetadata readProjectMetadata( String repoId, String namespace, String projectId ) + throws MetadataResolutionException; + + ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException; + + Collection listRootNamespaces( String repoId, Filter filter ); + + Collection listNamespaces( String repoId, String namespace, Filter filter ); + + Collection listProjects( String repoId, String namespace, Filter filter ); + + Collection listProjectVersions( String repoId, String namespace, String projectId, Filter filter ); + + Collection readArtifactsMetadata( String repoId, String namespace, String projectId, + String projectVersion, Filter filter ); + + // TODO: reconsider this API, do we want to expose storage format in the form of a path? + ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path ); +} diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java deleted file mode 100644 index 771bd4266..000000000 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/storage/StorageMetadataResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.archiva.metadata.repository.storage; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.repository.MetadataResolver; -import org.apache.archiva.metadata.repository.filter.Filter; - -import java.util.Collection; - -public interface StorageMetadataResolver - extends MetadataResolver -{ - Collection getRootNamespaces( String repoId, Filter filter ); - - Collection getNamespaces( String repoId, String namespace, Filter filter ); - - Collection getProjects( String repoId, String namespace, Filter filter ); - - Collection getProjectVersions( String repoId, String namespace, String projectId, Filter filter ); - - Collection getArtifacts( String repoId, String namespace, String projectId, String projectVersion, - Filter filter ); - - // TODO: reconsider this API, do we want to expose storage format in the form of a path? - ArtifactMetadata getArtifactForPath( String repoId, String path ); -} diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java index 643df1817..f9f13c1b4 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java @@ -873,7 +873,7 @@ public abstract class AbstractMetadataRepositoryTest assertEquals( Collections.singletonList( artifact ), new ArrayList( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) ); - repository.deleteArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() ); + repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact.getId() ); assertTrue( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ).isEmpty() ); @@ -909,7 +909,7 @@ public abstract class AbstractMetadataRepositoryTest assertEquals( expected, actual ); - repository.deleteRepository( TEST_REPO_ID ); + repository.removeRepository( TEST_REPO_ID ); assertTrue( repository.getArtifacts( TEST_REPO_ID ).isEmpty() ); assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() ); 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 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 similarity index 89% rename from archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryMetadataResolver.java rename to 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 ALL = new AllFilter(); - 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 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 getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) - { - // TODO: useful, but not implemented yet, not called from DefaultMetadataResolver - throw new UnsupportedOperationException(); - } - - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) - { - // Can't be determined on a Maven 2 repository - throw new UnsupportedOperationException(); - } - - public Collection getRootNamespaces( String repoId ) - { - return getRootNamespaces( repoId, ALL ); - } - - public Collection getRootNamespaces( String repoId, Filter filter ) + public Collection listRootNamespaces( String repoId, Filter filter ) { File dir = getRepositoryBasedir( repoId ); @@ -422,12 +399,7 @@ public class Maven2RepositoryMetadataResolver return new File( repositoryConfiguration.getLocation() ); } - public Collection getNamespaces( String repoId, String namespace ) - { - return getNamespaces( repoId, namespace, ALL ); - } - - public Collection getNamespaces( String repoId, String namespace, Filter filter ) + public Collection listNamespaces( String repoId, String namespace, Filter filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); @@ -448,12 +420,7 @@ public class Maven2RepositoryMetadataResolver return namespaces; } - public Collection getProjects( String repoId, String namespace ) - { - return getProjects( repoId, namespace, ALL ); - } - - public Collection getProjects( String repoId, String namespace, Filter filter ) + public Collection listProjects( String repoId, String namespace, Filter filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); @@ -474,19 +441,8 @@ public class Maven2RepositoryMetadataResolver return projects; } - public Collection getProjectVersions( String repoId, String namespace, String projectId ) - { - return getProjectVersions( repoId, namespace, projectId, ALL ); - } - - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) - { - return getArtifacts( repoId, namespace, projectId, projectVersion, ALL ); - } - - public Collection getProjectVersions( String repoId, String namespace, String projectId, - Filter filter ) + public Collection listProjectVersions( String repoId, String namespace, String projectId, + Filter filter ) { File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId ); @@ -494,8 +450,8 @@ public class Maven2RepositoryMetadataResolver return getSortedFiles( dir, filter ); } - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion, Filter filter ) + public Collection readArtifactsMetadata( String repoId, String namespace, String projectId, + String projectVersion, Filter 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 facets = new HashMap(); @@ -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 getArtifacts(String repositoryId){ + + public List 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 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 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 getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection 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 ) + 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 ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveProjectReferences( String repoId, String namespace, + String projectId, String projectVersion ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getArtifactVersions( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveRootNamespaces( String repoId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getProjectReferences( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection resolveNamespaces( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getRootNamespaces( String repoId ) + public Collection resolveProjects( String repoId, String namespace ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getNamespaces( String repoId, String namespace ) + public Collection resolveProjectVersions( String repoId, String namespace, String projectId ) { return null; //To change body of implemented methods use File | Settings | File Templates. } - public Collection getProjects( String repoId, String namespace ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getProjectVersions( String repoId, String namespace, String projectId ) - { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getArtifacts( String repoId, String namespace, String projectId, - String projectVersion ) + public Collection 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 ALL = new AllFilter(); + + 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 springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", - "plexus-spring", "1.2" ); + Collection springArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, + "org.codehaus.plexus", + "plexus-spring", "1.2", ALL ); List artifacts = new ArrayList( springArtifacts ); Collections.sort( artifacts, new Comparator() { @@ -177,8 +182,9 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactMetadataSnapshots() throws Exception { - Collection testArtifacts = resolver.getArtifacts( TEST_REPO_ID, "com.example.test", - "test-artifact", "1.0-SNAPSHOT" ); + Collection testArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, "com.example.test", + "test-artifact", "1.0-SNAPSHOT", + ALL ); List artifacts = new ArrayList( testArtifacts ); Collections.sort( artifacts, new Comparator() { @@ -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.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "com.example.test" ) ); + 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.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "com.example.test", + ALL ) ); - 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.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ); - assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.plugins" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, - "org.apache.maven.shared" ) ); + 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.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.emptyList(), resolver.listNamespaces( TEST_REPO_ID, + "org.apache.maven.plugins", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven.shared", + ALL ) ); - assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ); - assertEquals( Collections.emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) ); + assertEquals( Arrays.asList( "plexus" ), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus", ALL ) ); + assertEquals( Collections.emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus.plexus", + ALL ) ); } public void testGetProjects() { - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "com" ) ); - assertEquals( Collections.emptyList(), resolver.getProjects( TEST_REPO_ID, "com.example" ) ); + assertEquals( Collections.emptyList(), resolver.listProjects( TEST_REPO_ID, "com", ALL ) ); + assertEquals( Collections.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.emptyList(), resolver.getProjects( TEST_REPO_ID, "org" ) ); - assertEquals( Arrays.asList( "apache" ), resolver.getProjects( TEST_REPO_ID, "org.apache" ) ); + assertEquals( Collections.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.emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) ); - assertEquals( Collections.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.emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven", ALL ) ); + assertEquals( Collections.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( "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.getProjectVersions( TEST_REPO_ID, "org.apache", - "apache" ) ); + 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.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( 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.emptyList(), resolver.getProjectVersions( TEST_REPO_ID, - "org.apache.maven.shared", - "maven-downloader" ) ); + assertEquals( Collections.emptyList(), resolver.listProjectVersions( TEST_REPO_ID, + "org.apache.maven.shared", + "maven-downloader", ALL ) ); } public void testGetArtifacts() { - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2" ) ); + List artifacts = new ArrayList( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) ); assertEquals( 3, artifacts.size() ); Collections.sort( artifacts, new Comparator() { @@ -474,10 +484,8 @@ public class Maven2RepositoryMetadataResolverTest { ExcludesFilter filter = new ExcludesFilter( Collections.singletonList( "plexus-spring-1.2.pom" ) ); - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "org.codehaus.plexus", - "plexus-spring", - "1.2", filter ) ); + List artifacts = new ArrayList( resolver.readArtifactsMetadata( + TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) ); assertEquals( 2, artifacts.size() ); Collections.sort( artifacts, new Comparator() { @@ -493,10 +501,8 @@ public class Maven2RepositoryMetadataResolverTest public void testGetArtifactsTimestampedSnapshots() { - List artifacts = new ArrayList( resolver.getArtifacts( TEST_REPO_ID, - "com.example.test", - "missing-metadata", - "1.0-SNAPSHOT" ) ); + List artifacts = new ArrayList( 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