[MRM-1327] refactor the repository API to make each concern clearer. Storage, resolver and metadata repository are separate interfaces. Rename methods on the resolver and the storage to be clearer of their intent

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1051788 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2010-12-22 08:31:56 +00:00
parent f9cd1037d1
commit c63e2a3f77
28 changed files with 567 additions and 527 deletions

View File

@ -25,7 +25,7 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataResolutionException; 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.common.utils.VersionUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames; import org.apache.maven.archiva.configuration.ConfigurationNames;
@ -90,7 +90,7 @@ public class ArchivaMetadataCreationConsumer
* *
* @plexus.requirement role-hint="maven2" * @plexus.requirement role-hint="maven2"
*/ */
private StorageMetadataResolver storageResolver; private RepositoryStorage repositoryStorage;
private static final Logger log = LoggerFactory.getLogger( ArchivaMetadataCreationConsumer.class ); 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 // the initial scan. Any request for this information will be intercepted and populated on-demand
// or picked up by subsequent scans // or picked up by subsequent scans
ArtifactMetadata artifact = storageResolver.getArtifactForPath( repoId, path ); ArtifactMetadata artifact = repositoryStorage.readArtifactMetadataFromPath( repoId, path );
ProjectMetadata project = new ProjectMetadata(); ProjectMetadata project = new ProjectMetadata();
project.setNamespace( artifact.getNamespace() ); project.setNamespace( artifact.getNamespace() );
@ -152,8 +152,8 @@ public class ArchivaMetadataCreationConsumer
ProjectVersionMetadata versionMetadata = null; ProjectVersionMetadata versionMetadata = null;
try try
{ {
versionMetadata = storageResolver.getProjectVersion( repoId, artifact.getNamespace(), artifact.getProject(), versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId, artifact.getNamespace(),
projectVersion ); artifact.getProject(), projectVersion );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {

View File

@ -19,17 +19,17 @@ package org.apache.archiva.metadata.repository;
* under the License. * 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.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference; 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 public class TestMetadataRepository
implements MetadataRepository implements MetadataRepository
{ {
@ -144,12 +144,12 @@ public class TestMetadataRepository
return null; //To change body of implemented methods use File | Settings | File Templates. 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. //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. //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. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public List<ArtifactMetadata> getArtifacts(String repositoryId){ public List<ArtifactMetadata> getArtifacts( String repositoryId )
{
return null; return null;
} }
} }

View File

@ -19,15 +19,8 @@ package org.apache.archiva.rss.processor;
* under the License. * under the License.
*/ */
import java.util.ArrayList; import com.sun.syndication.feed.synd.SyndEntry;
import java.util.Calendar; import com.sun.syndication.feed.synd.SyndFeed;
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 org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.model.ProjectMetadata; 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.apache.archiva.rss.RssFeedGenerator;
import org.codehaus.plexus.spring.PlexusInSpringTestCase; import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import com.sun.syndication.feed.synd.SyndEntry; import java.util.ArrayList;
import com.sun.syndication.feed.synd.SyndFeed; 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 public class NewArtifactsRssFeedProcessorTest
extends PlexusInSpringTestCase extends PlexusInSpringTestCase
@ -95,13 +94,14 @@ public class NewArtifactsRssFeedProcessorTest
assertTrue( feed.getTitle().equals( "New Artifacts in Repository 'test-repo'" ) ); assertTrue( feed.getTitle().equals( "New Artifacts in Repository 'test-repo'" ) );
assertTrue( feed.getDescription().equals( 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.getLanguage().equals( "en-us" ) );
assertTrue( feed.getPublishedDate().equals( whenGathered ) ); assertTrue( feed.getPublishedDate().equals( whenGathered ) );
List<SyndEntry> entries = feed.getEntries(); List<SyndEntry> entries = feed.getEntries();
assertEquals( entries.size(), 1 ); 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 ) ); assertTrue( entries.get( 0 ).getPublishedDate().equals( whenGathered ) );
} }
@ -140,12 +140,12 @@ public class NewArtifactsRssFeedProcessorTest
throw new UnsupportedOperationException(); 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(); throw new UnsupportedOperationException();
} }
public void deleteRepository( String arg0 ) public void removeRepository( String arg0 )
{ {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
@ -287,10 +287,10 @@ public class NewArtifactsRssFeedProcessorTest
{ {
this.artifactsByDateRange = artifactsByDateRange; this.artifactsByDateRange = artifactsByDateRange;
} }
public List<ArtifactMetadata> getArtifacts( String repositoryId ) public List<ArtifactMetadata> getArtifacts( String repositoryId )
{ {
return artifactsByDateRange; return artifactsByDateRange;
} }
} }
} }

View File

@ -78,7 +78,7 @@ public class BrowseAction
Set<String> namespacesToCollapse = new LinkedHashSet<String>(); Set<String> namespacesToCollapse = new LinkedHashSet<String>();
for ( String repoId : selectedRepos ) for ( String repoId : selectedRepos )
{ {
namespacesToCollapse.addAll( metadataResolver.getRootNamespaces( repoId ) ); namespacesToCollapse.addAll( metadataResolver.resolveRootNamespaces( repoId ) );
} }
for ( String n : namespacesToCollapse ) for ( String n : namespacesToCollapse )
@ -97,7 +97,7 @@ public class BrowseAction
Set<String> subNamespaces = new LinkedHashSet<String>(); Set<String> subNamespaces = new LinkedHashSet<String>();
for ( String repoId : repoIds ) for ( String repoId : repoIds )
{ {
subNamespaces.addAll( metadataResolver.getNamespaces( repoId, n ) ); subNamespaces.addAll( metadataResolver.resolveNamespaces( repoId, n ) );
} }
if ( subNamespaces.size() != 1 ) if ( subNamespaces.size() != 1 )
{ {
@ -111,7 +111,7 @@ public class BrowseAction
{ {
for ( String repoId : repoIds ) for ( String repoId : repoIds )
{ {
Collection<String> projects = metadataResolver.getProjects( repoId, n ); Collection<String> projects = metadataResolver.resolveProjects( repoId, n );
if ( projects != null && !projects.isEmpty() ) if ( projects != null && !projects.isEmpty() )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -146,9 +146,9 @@ public class BrowseAction
Set<String> namespacesToCollapse = new LinkedHashSet<String>(); Set<String> namespacesToCollapse = new LinkedHashSet<String>();
for ( String repoId : selectedRepos ) 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 // TODO: this logic should be optional, particularly remembering we want to keep this code simple
@ -199,7 +199,7 @@ public class BrowseAction
Set<String> versions = new LinkedHashSet<String>(); Set<String> versions = new LinkedHashSet<String>();
for ( String repoId : selectedRepos ) 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 // TODO: sort by known version ordering method
@ -230,7 +230,8 @@ public class BrowseAction
{ {
try try
{ {
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); versionMetadata = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId,
version );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {

View File

@ -238,7 +238,7 @@ public class DeleteArtifactAction
// TODO: mismatch between artifact (snapshot) version and project (base) version here // TODO: mismatch between artifact (snapshot) version and project (base) version here
if ( artifact.getVersion().equals( version ) ) if ( artifact.getVersion().equals( version ) )
{ {
metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(),
artifact.getProject(), artifact.getVersion(), artifact.getId() ); artifact.getProject(), artifact.getVersion(), artifact.getId() );
// TODO: move into the metadata repository proper - need to differentiate attachment of // TODO: move into the metadata repository proper - need to differentiate attachment of

View File

@ -157,7 +157,7 @@ public class ShowArtifactAction
// "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used // "just-in-time" nature of picking up the metadata (if appropriate for the repository type) is used
try try
{ {
versionMetadata = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); versionMetadata = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId, version );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {
@ -174,9 +174,9 @@ public class ShowArtifactAction
List<ArtifactMetadata> artifacts; List<ArtifactMetadata> artifacts;
try try
{ {
artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.getArtifacts( repoId, groupId, artifacts = new ArrayList<ArtifactMetadata>( metadataResolver.resolveArtifacts( repoId, groupId,
artifactId, artifactId,
version ) ); version ) );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {
@ -265,7 +265,7 @@ public class ShowArtifactAction
for ( String repoId : getObservableRepos() ) for ( String repoId : getObservableRepos() )
{ {
// TODO: what about if we want to see this irrespective of version? // 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; this.dependees = references;

View File

@ -187,7 +187,7 @@ public class DeleteManagedRepositoryAction
private void cleanupDatabase( String repoId ) private void cleanupDatabase( String repoId )
throws MetadataRepositoryException throws MetadataRepositoryException
{ {
metadataRepository.deleteRepository( repoId ); metadataRepository.removeRepository( repoId );
} }
public ManagedRepositoryConfiguration getRepository() public ManagedRepositoryConfiguration getRepository()

View File

@ -184,12 +184,12 @@ public class TestMetadataRepository
return null; //To change body of implemented methods use File | Settings | File Templates. 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. //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. //To change body of implemented methods use File | Settings | File Templates.
} }
@ -200,7 +200,8 @@ public class TestMetadataRepository
return artifacts; return artifacts;
} }
public List<ArtifactMetadata> getArtifacts(String repositoryId){ public List<ArtifactMetadata> getArtifacts( String repositoryId )
{
return artifacts; return artifacts;
} }
} }

View File

@ -19,6 +19,11 @@ package org.apache.archiva.metadata.repository.memory;
* under the License. * 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.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -27,12 +32,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; 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 public class TestMetadataResolver
implements MetadataResolver implements MetadataResolver
{ {
@ -49,38 +48,24 @@ public class TestMetadataResolver
private Map<String, Collection<String>> versionsInProject = new HashMap<String, Collection<String>>(); private Map<String, Collection<String>> versionsInProject = new HashMap<String, Collection<String>>();
public ProjectMetadata getProject( String repoId, String namespace, String projectId ) public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId,
{ String projectVersion )
ProjectMetadata metadata = new ProjectMetadata();
metadata.setNamespace( namespace );
metadata.setId( projectId );
return metadata;
}
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
{ {
return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); return projectVersions.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
} }
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, public Collection<ProjectVersionReference> resolveProjectReferences( String repoId, String namespace,
String projectVersion ) String projectId, String projectVersion )
{
throw new UnsupportedOperationException();
}
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
{ {
return references.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); return references.get( createMapKey( repoId, namespace, projectId, projectVersion ) );
} }
public Collection<String> getRootNamespaces( String repoId ) public Collection<String> resolveRootNamespaces( String repoId )
{ {
return getNamespaces( repoId, null ); return resolveNamespaces( repoId, null );
} }
public Collection<String> getNamespaces( String repoId, String baseNamespace ) public Collection<String> resolveNamespaces( String repoId, String baseNamespace )
{ {
Set<String> namespaces = new LinkedHashSet<String>(); Set<String> namespaces = new LinkedHashSet<String>();
int fromIndex = baseNamespace != null ? baseNamespace.length() + 1 : 0; int fromIndex = baseNamespace != null ? baseNamespace.length() + 1 : 0;
@ -102,23 +87,23 @@ public class TestMetadataResolver
return namespaces; return namespaces;
} }
public Collection<String> getProjects( String repoId, String namespace ) public Collection<String> resolveProjects( String repoId, String namespace )
{ {
Collection<String> list = projectsInNamespace.get( namespace ); Collection<String> list = projectsInNamespace.get( namespace );
return list != null ? list : Collections.<String>emptyList(); return list != null ? list : Collections.<String>emptyList();
} }
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) public Collection<String> resolveProjectVersions( String repoId, String namespace, String projectId )
{ {
Collection<String> list = versionsInProject.get( namespace + ":" + projectId ); Collection<String> list = versionsInProject.get( namespace + ":" + projectId );
return list != null ? list : Collections.<String>emptyList(); return list != null ? list : Collections.<String>emptyList();
} }
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, public Collection<ArtifactMetadata> resolveArtifacts( String repoId, String namespace, String projectId,
String projectVersion ) String projectVersion )
{ {
List<ArtifactMetadata> artifacts = List<ArtifactMetadata> artifacts = this.artifacts.get( createMapKey( repoId, namespace, projectId,
this.artifacts.get( createMapKey( repoId, namespace, projectId, projectVersion ) ); projectVersion ) );
return ( artifacts != null ? artifacts : Collections.<ArtifactMetadata>emptyList() ); return ( artifacts != null ? artifacts : Collections.<ArtifactMetadata>emptyList() );
} }

View File

@ -95,7 +95,7 @@ public class DeleteManagedRepositoryActionTest
MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
metadataRepository.deleteRepository( REPO_ID ); metadataRepository.removeRepository( REPO_ID );
action.setMetadataRepository( metadataRepository ); action.setMetadataRepository( metadataRepository );
metadataRepositoryControl.replay(); metadataRepositoryControl.replay();
@ -178,7 +178,7 @@ public class DeleteManagedRepositoryActionTest
{ {
MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class ); MockControl metadataRepositoryControl = MockControl.createControl( MetadataRepository.class );
MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock(); MetadataRepository metadataRepository = (MetadataRepository) metadataRepositoryControl.getMock();
metadataRepository.deleteRepository( REPO_ID ); metadataRepository.removeRepository( REPO_ID );
metadataRepositoryControl.replay(); metadataRepositoryControl.replay();
action.setMetadataRepository( metadataRepository ); action.setMetadataRepository( metadataRepository );
return metadataRepositoryControl; return metadataRepositoryControl;

View File

@ -19,17 +19,17 @@ package org.apache.archiva.metadata.repository;
* under the License. * 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.ArtifactMetadata;
import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacet;
import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference; 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 public class TestMetadataRepository
implements MetadataRepository implements MetadataRepository
{ {
@ -144,12 +144,12 @@ public class TestMetadataRepository
return null; //To change body of implemented methods use File | Settings | File Templates. 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. //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. //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. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public List<ArtifactMetadata> getArtifacts(String repositoryId){
public List<ArtifactMetadata> getArtifacts( String repositoryId )
{
return null; return null;
} }
} }

View File

@ -66,7 +66,7 @@ import java.util.Map;
/** /**
* AdministrationServiceImpl * AdministrationServiceImpl
* *
* @version $Id: AdministrationServiceImpl.java * @version $Id: AdministrationServiceImpl.java
*/ */
public class AdministrationServiceImpl public class AdministrationServiceImpl
@ -197,15 +197,15 @@ public class AdministrationServiceImpl
// delete from file system // delete from file system
repoContent.deleteVersion( ref ); repoContent.deleteVersion( ref );
Collection<ArtifactMetadata> artifacts = Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, groupId, artifactId,
metadataRepository.getArtifacts( repoId, groupId, artifactId, version ); version );
for ( ArtifactMetadata artifact : artifacts ) for ( ArtifactMetadata artifact : artifacts )
{ {
// TODO: mismatch between artifact (snapshot) version and project (base) version here // TODO: mismatch between artifact (snapshot) version and project (base) version here
if ( artifact.getVersion().equals( version ) ) if ( artifact.getVersion().equals( version ) )
{ {
metadataRepository.deleteArtifact( artifact.getRepositoryId(), artifact.getNamespace(), metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(),
artifact.getProject(), artifact.getVersion(), artifact.getId() ); artifact.getProject(), artifact.getVersion(), artifact.getId() );
// TODO: move into the metadata repository proper - need to differentiate attachment of // TODO: move into the metadata repository proper - need to differentiate attachment of
@ -295,9 +295,9 @@ public class AdministrationServiceImpl
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs ) for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
{ {
// TODO fix resolution of repo url! // TODO fix resolution of repo url!
ManagedRepository repo = ManagedRepository repo = new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL",
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", repoConfig.getLayout(), repoConfig.getLayout(), repoConfig.isSnapshots(),
repoConfig.isSnapshots(), repoConfig.isReleases() ); repoConfig.isReleases() );
managedRepos.add( repo ); managedRepos.add( repo );
} }
@ -316,9 +316,8 @@ public class AdministrationServiceImpl
for ( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs ) for ( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs )
{ {
RemoteRepository repo = RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(),
new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(), repoConfig.getLayout() );
repoConfig.getLayout() );
remoteRepos.add( repo ); remoteRepos.add( repo );
} }
@ -354,18 +353,18 @@ public class AdministrationServiceImpl
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) ) if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
{ {
throw new Exception( "Unable to add new repository with id [" + repoId throw new Exception( "Unable to add new repository with id [" + repoId +
+ "], that id already exists as a managed repository." ); "], that id already exists as a managed repository." );
} }
else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) ) else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
{ {
throw new Exception( "Unable to add new repository with id [" + repoId throw new Exception( "Unable to add new repository with id [" + repoId +
+ "], that id already exists as a remote repository." ); "], that id already exists as a remote repository." );
} }
else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) ) else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
{ {
throw new Exception( "Unable to add new repository with id [" + repoId throw new Exception( "Unable to add new repository with id [" + repoId +
+ "], that id already exists as a repository group." ); "], that id already exists as a repository group." );
} }
if ( !validator.validate( cronExpression ) ) if ( !validator.validate( cronExpression ) )
@ -408,7 +407,7 @@ public class AdministrationServiceImpl
throw new Exception( "A repository with that id does not exist" ); throw new Exception( "A repository with that id does not exist" );
} }
metadataRepository.deleteRepository( repository.getId() ); metadataRepository.removeRepository( repository.getId() );
repositoryStatisticsManager.deleteStatistics( repository.getId() ); repositoryStatisticsManager.deleteStatistics( repository.getId() );
config.removeManagedRepository( repository ); config.removeManagedRepository( repository );
@ -440,7 +439,8 @@ public class AdministrationServiceImpl
List<String> repoGroups = repoToGroupMap.get( repository.getId() ); List<String> repoGroups = repoToGroupMap.get( repository.getId() );
for ( String repoGroup : repoGroups ) 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" ); throw new Exception( "A repository with that id does not exist" );
} }
ManagedRepository repo = ManagedRepository repo = new ManagedRepository( managedRepository.getId(), managedRepository.getName(), "URL",
new ManagedRepository( managedRepository.getId(), managedRepository.getName(), "URL", managedRepository.getLayout(), managedRepository.isSnapshots(),
managedRepository.getLayout(), managedRepository.isSnapshots(), managedRepository.isReleases() );
managedRepository.isReleases() );
return repo; return repo;
} }
@ -490,16 +489,16 @@ public class AdministrationServiceImpl
log.info( "Repository to be merged contains releases only.." ); log.info( "Repository to be merged contains releases only.." );
if ( skipConflicts ) if ( skipConflicts )
{ {
List<ArtifactMetadata> conflicts = List<ArtifactMetadata> conflicts = repositoryMerger.getConflictingArtifacts( repoId,
repositoryMerger.getConflictingArtifacts( repoId, stagingId ); stagingId );
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
{ {
log.debug( "Artifacts in conflict.." ); log.debug( "Artifacts in conflict.." );
for( ArtifactMetadata metadata : conflicts ) for ( ArtifactMetadata metadata : conflicts )
{ {
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" + 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.." ); log.info( "Repository to be merged has snapshot artifacts.." );
if ( skipConflicts ) if ( skipConflicts )
{ {
List<ArtifactMetadata> conflicts = List<ArtifactMetadata> conflicts = repositoryMerger.getConflictingArtifacts( repoId,
repositoryMerger.getConflictingArtifacts( repoId, stagingId ); stagingId );
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
{ {
log.debug( "Artifacts in conflict.." ); log.debug( "Artifacts in conflict.." );
for( ArtifactMetadata metadata : conflicts ) for ( ArtifactMetadata metadata : conflicts )
{ {
log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" + log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":" +
metadata.getProjectVersion() ); metadata.getProjectVersion() );
} }
} }
@ -536,19 +535,21 @@ public class AdministrationServiceImpl
log.debug( "Source artifacts size :: " + sourceArtifacts.size() ); log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
Filter<ArtifactMetadata> artifactsWithOutConflicts = Filter<ArtifactMetadata> artifactsWithOutConflicts = new IncludesFilter<ArtifactMetadata>(
new IncludesFilter<ArtifactMetadata>( sourceArtifacts ); sourceArtifacts );
repositoryMerger.merge( stagingId, repoId, artifactsWithOutConflicts ); repositoryMerger.merge( stagingId, repoId, artifactsWithOutConflicts );
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" + log.info(
repoId + "'." ); "Staging repository '" + stagingId + "' merged successfully with managed repo '" + repoId +
"'." );
} }
else else
{ {
repositoryMerger.merge( stagingId, repoId ); repositoryMerger.merge( stagingId, repoId );
log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '" + log.info(
repoId + "'." ); "Staging repository '" + stagingId + "' merged successfully with managed repo '" + repoId +
"'." );
} }
} }
} }
@ -593,8 +594,8 @@ public class AdministrationServiceImpl
} }
if ( !file.exists() || !file.isDirectory() ) if ( !file.exists() || !file.isDirectory() )
{ {
throw new IOException( "Unable to add repository - no write access, can not create the root directory: " throw new IOException(
+ file ); "Unable to add repository - no write access, can not create the root directory: " + file );
} }
configuration.addManagedRepository( repository ); configuration.addManagedRepository( repository );

View File

@ -61,7 +61,7 @@ public class SearchServiceImpl
this.metadataRepository = metadataRepository; this.metadataRepository = metadataRepository;
} }
@SuppressWarnings("unchecked") @SuppressWarnings( "unchecked" )
public List<Artifact> quickSearch( String queryString ) public List<Artifact> quickSearch( String queryString )
throws Exception throws Exception
{ {
@ -85,9 +85,9 @@ public class SearchServiceImpl
// slight behaviour change to previous implementation: instead of allocating "jar" when not // 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 // 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. // just allocate the default packaging if the Maven facet is not found.
FacetedMetadata model = FacetedMetadata model = metadataResolver.resolveProjectVersion( repoId, resultHit.getGroupId(),
metadataResolver.getProjectVersion( repoId, resultHit.getGroupId(), resultHit.getArtifactId(),
resultHit.getArtifactId(), version ); version );
if ( model != null ) if ( model != null )
{ {
@ -143,7 +143,7 @@ public class SearchServiceImpl
for ( String repoId : observableRepos ) for ( String repoId : observableRepos )
{ {
Collection<String> results = metadataResolver.getProjectVersions( repoId, groupId, artifactId ); Collection<String> results = metadataResolver.resolveProjectVersions( repoId, groupId, artifactId );
for ( final String version : results ) for ( final String version : results )
{ {
@ -176,16 +176,16 @@ public class SearchServiceImpl
for ( String repoId : observableRepos ) for ( String repoId : observableRepos )
{ {
ProjectVersionMetadata model = metadataResolver.getProjectVersion( repoId, groupId, artifactId, version ); ProjectVersionMetadata model = metadataResolver.resolveProjectVersion( repoId, groupId, artifactId,
version );
if ( model != null ) if ( model != null )
{ {
List<Dependency> dependencies = new ArrayList<Dependency>(); List<Dependency> dependencies = new ArrayList<Dependency>();
List<org.apache.archiva.metadata.model.Dependency> modelDeps = model.getDependencies(); List<org.apache.archiva.metadata.model.Dependency> modelDeps = model.getDependencies();
for ( org.apache.archiva.metadata.model.Dependency dep : modelDeps ) for ( org.apache.archiva.metadata.model.Dependency dep : modelDeps )
{ {
Dependency dependency = Dependency dependency = new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(),
new Dependency( dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(), dep.getClassifier(), dep.getType(), dep.getScope() );
dep.getType(), dep.getScope() );
dependencies.add( dependency ); dependencies.add( dependency );
} }
return dependencies; return dependencies;
@ -211,12 +211,12 @@ public class SearchServiceImpl
for ( String repoId : observableRepos ) for ( String repoId : observableRepos )
{ {
Collection<ProjectVersionReference> refs = Collection<ProjectVersionReference> refs = metadataResolver.resolveProjectReferences( repoId, groupId,
metadataResolver.getProjectReferences( repoId, groupId, artifactId, version ); artifactId, version );
for ( ProjectVersionReference ref : refs ) for ( ProjectVersionReference ref : refs )
{ {
artifacts.add( artifacts.add( new Artifact( repoId, ref.getNamespace(), ref.getProjectId(), ref.getProjectVersion(),
new Artifact( repoId, ref.getNamespace(), ref.getProjectId(), ref.getProjectVersion(), "" ) ); "" ) );
} }
} }

View File

@ -19,15 +19,6 @@ package org.apache.archiva.web.xmlrpc.services;
* under the License. * 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.AuditEvent;
import org.apache.archiva.audit.AuditListener; import org.apache.archiva.audit.AuditListener;
import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ArtifactMetadata;
@ -63,9 +54,18 @@ import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import org.easymock.MockControl; import org.easymock.MockControl;
import org.easymock.classextension.MockClassControl; 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 * AdministrationServiceImplTest
* *
* @version $Id: AdministrationServiceImplTest.java * @version $Id: AdministrationServiceImplTest.java
*/ */
public class AdministrationServiceImplTest public class AdministrationServiceImplTest
@ -174,10 +174,9 @@ public class AdministrationServiceImplTest
auditListenerControl = MockControl.createControl( AuditListener.class ); auditListenerControl = MockControl.createControl( AuditListener.class );
auditListener = (AuditListener) auditListenerControl.getMock(); auditListener = (AuditListener) auditListenerControl.getMock();
service = service = new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory,
new AdministrationServiceImpl( archivaConfig, repoConsumersUtil, repositoryFactory, metadataRepository, metadataRepository, repositoryTaskScheduler, Collections.singletonList(
repositoryTaskScheduler, Collections.singletonList( listener ), listener ), repositoryStatisticsManager, repositoryMerger, auditListener );
repositoryStatisticsManager, repositoryMerger, auditListener );
} }
/* Tests for repository consumers */ /* Tests for repository consumers */
@ -338,8 +337,9 @@ public class AdministrationServiceImplTest
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(), metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(),
artifact.getNamespace(), artifact.getNamespace(),
artifact.getProject(), artifact.getProject(),
artifact.getVersion() ), artifacts ); artifact.getVersion() ),
metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), artifacts );
metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
artifact.getVersion(), artifact.getId() ); artifact.getVersion(), artifact.getId() );
listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
@ -394,8 +394,9 @@ public class AdministrationServiceImplTest
metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(), metadataRepositoryControl.expectAndReturn( metadataRepository.getArtifacts( repoContent.getId(),
artifact.getNamespace(), artifact.getNamespace(),
artifact.getProject(), artifact.getProject(),
artifact.getVersion() ), artifacts ); artifact.getVersion() ),
metadataRepository.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), artifacts );
metadataRepository.removeArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
artifact.getVersion(), artifact.getId() ); artifact.getVersion(), artifact.getId() );
listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(), listener.deleteArtifact( repoContent.getId(), artifact.getNamespace(), artifact.getProject(),
@ -474,8 +475,8 @@ public class AdministrationServiceImplTest
FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) ); FileUtils.copyDirectory( srcDir, repoDir, FileFilterUtils.makeSVNAware( null ) );
ManagedRepositoryConfiguration managedRepo = ManagedRepositoryConfiguration managedRepo = createManagedRepo( "internal", layout, "Internal Repository", true,
createManagedRepo( "internal", layout, "Internal Repository", true, false ); false );
managedRepo.setLocation( repoDir.getAbsolutePath() ); managedRepo.setLocation( repoDir.getAbsolutePath() );
return managedRepo; return managedRepo;
} }
@ -509,13 +510,16 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), createManagedRepo( "internal",
createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); "default",
"Internal Repository",
true,
false ) );
RepositoryTask task = new RepositoryTask(); RepositoryTask task = new RepositoryTask();
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask(
false ); "internal" ), false );
repositoryTaskScheduler.queueTask( task ); repositoryTaskScheduler.queueTask( task );
repositoryTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER ); repositoryTaskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER );
@ -544,11 +548,14 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), createManagedRepo( "internal",
createManagedRepo( "internal", "default", "Internal Repository", true, false ) ); "default",
"Internal Repository",
true,
false ) );
repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask( "internal" ), repositoryTaskSchedulerControl.expectAndReturn( repositoryTaskScheduler.isProcessingRepositoryTask(
true ); "internal" ), true );
archivaConfigControl.replay(); archivaConfigControl.replay();
configControl.replay(); configControl.replay();
@ -625,7 +632,8 @@ public class AdministrationServiceImplTest
List<RemoteRepositoryConfiguration> remoteRepos = new ArrayList<RemoteRepositoryConfiguration>(); List<RemoteRepositoryConfiguration> remoteRepos = new ArrayList<RemoteRepositoryConfiguration>();
remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default", remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default",
"http://repo1.maven.org/maven2" ) ); "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 ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos ); configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos );
@ -673,8 +681,9 @@ public class AdministrationServiceImplTest
throws Exception throws Exception
{ {
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), configControl.expectAndReturn( config.findManagedRepositoryById( "repo" ), createManagedRepo( "repo", "default",
createManagedRepo( "repo", "default", "repo", true, false ) ); "repo", true,
false ) );
configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), null ); configControl.expectAndReturn( config.findManagedRepositoryById( "repo-stage" ), null );
archivaConfigControl.replay(); archivaConfigControl.replay();
@ -830,8 +839,8 @@ public class AdministrationServiceImplTest
String stageLocation = releaseLocation + "-stage"; String stageLocation = releaseLocation + "-stage";
ManagedRepositoryConfiguration managedRepo = createManagedRepo( "repo1", "default", "repo", true, false ); ManagedRepositoryConfiguration managedRepo = createManagedRepo( "repo1", "default", "repo", true, false );
RemoteRepositoryConfiguration remoteRepo = RemoteRepositoryConfiguration remoteRepo = createRemoteRepository( "central", "Central Repository", "default",
createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2" ); "http://repo1.maven.org/maven2" );
List<String> repositories = new ArrayList<String>(); List<String> repositories = new ArrayList<String>();
repositories.add( managedRepo.getName() ); repositories.add( managedRepo.getName() );
RepositoryGroupConfiguration repoGroup = createRepoGroupConfig( "repoGroup", repositories ); RepositoryGroupConfiguration repoGroup = createRepoGroupConfig( "repoGroup", repositories );
@ -861,9 +870,8 @@ public class AdministrationServiceImplTest
configControl.replay(); configControl.replay();
assertFalse( new File( releaseLocation ).isDirectory() ); assertFalse( new File( releaseLocation ).isDirectory() );
assertFalse( new File( stageLocation ).isDirectory() ); assertFalse( new File( stageLocation ).isDirectory() );
boolean success = boolean success = service.addManagedRepository( repoId, layout, name, releaseLocation, true, true, false, true,
service.addManagedRepository( repoId, layout, name, releaseLocation, true, true, false, true, "0 15 3 * * ? *" );
"0 15 3 * * ? *" );
assertTrue( success ); assertTrue( success );
assertTrue( new File( releaseLocation ).isDirectory() ); assertTrue( new File( releaseLocation ).isDirectory() );
assertTrue( new File( stageLocation ).isDirectory() ); assertTrue( new File( stageLocation ).isDirectory() );

View File

@ -134,9 +134,10 @@ public class SearchServiceImplTest
facet.setPackaging( "war" ); facet.setPackaging( "war" );
model.addFacet( facet ); model.addFacet( facet );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, "archiva-webapp", "1.0" ), ARCHIVA_TEST_GROUP_ID,
model ); "archiva-webapp", "1.0" ),
model );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -188,15 +189,17 @@ public class SearchServiceImplTest
searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ), searchControl.expectAndDefaultReturn( search.search( "", observableRepoIds, "archiva", limits, null ),
results ); results );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, ARCHIVA_TEST_GROUP_ID,
"1.0" ), null ); ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), null );
ProjectVersionMetadata model = new ProjectVersionMetadata(); ProjectVersionMetadata model = new ProjectVersionMetadata();
model.setId( "1.0" ); model.setId( "1.0" );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "public.releases",
metadataResolver.getProjectVersion( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, ARCHIVA_TEST_GROUP_ID,
"1.0" ), model ); ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), model );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -253,9 +256,10 @@ public class SearchServiceImplTest
facet.setPackaging( "jar" ); facet.setPackaging( "jar" );
model.addFacet( facet ); model.addFacet( facet );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( "repo1.mirror",
metadataResolver.getProjectVersion( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, ARCHIVA_TEST_GROUP_ID,
"1.0" ), model ); ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), model );
userReposControl.replay(); userReposControl.replay();
searchControl.replay(); searchControl.replay();
@ -310,8 +314,8 @@ public class SearchServiceImplTest
public void testGetArtifactByChecksum() public void testGetArtifactByChecksum()
throws Exception throws Exception
{ {
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList(
Collections.singletonList( TEST_REPO ) ); TEST_REPO ) );
Date whenGathered = new Date(); Date whenGathered = new Date();
@ -345,12 +349,14 @@ public class SearchServiceImplTest
observableRepoIds.add( "public.releases" ); observableRepoIds.add( "public.releases" );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "repo1.mirror",
metadataResolver.getProjectVersions( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ), ARCHIVA_TEST_GROUP_ID,
Arrays.asList( "1.0", "1.1-beta-2", "1.2" ) ); ARCHIVA_TEST_ARTIFACT_ID ),
metadataResolverControl.expectAndReturn( Arrays.asList( "1.0", "1.1-beta-2", "1.2" ) );
metadataResolver.getProjectVersions( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID ), metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersions( "public.releases",
Arrays.asList( "1.1-beta-1", "1.1", "1.2.1-SNAPSHOT" ) ); ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID ),
Arrays.asList( "1.1-beta-1", "1.1", "1.2.1-SNAPSHOT" ) );
userReposControl.replay(); userReposControl.replay();
metadataResolverControl.replay(); metadataResolverControl.replay();
@ -364,19 +370,16 @@ public class SearchServiceImplTest
assertEquals( 6, artifacts.size() ); assertEquals( 6, artifacts.size() );
assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "pom" ), assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0", "pom" ),
artifacts.get( 0 ) ); artifacts.get( 0 ) );
assertEquals( assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-1",
new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-1", "pom" ), "pom" ), artifacts.get( 3 ) );
artifacts.get( 3 ) ); assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1-beta-2",
assertEquals( "pom" ), artifacts.get( 1 ) );
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" ), assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.1", "pom" ),
artifacts.get( 4 ) ); artifacts.get( 4 ) );
assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2", "pom" ), assertEquals( new Artifact( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2", "pom" ),
artifacts.get( 2 ) ); artifacts.get( 2 ) );
assertEquals( assertEquals( new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
new Artifact( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.2.1-SNAPSHOT", "pom" ), "1.2.1-SNAPSHOT", "pom" ), artifacts.get( 5 ) );
artifacts.get( 5 ) );
} }
public void testGetArtifactVersionsByDateArtifactExists() public void testGetArtifactVersionsByDateArtifactExists()
@ -415,15 +418,15 @@ public class SearchServiceImplTest
model.addDependency( dependency ); model.addDependency( dependency );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID,
metadataResolver.getProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), ARCHIVA_TEST_ARTIFACT_ID,
model ); "1.0" ), model );
metadataResolverControl.replay(); metadataResolverControl.replay();
userReposControl.replay(); userReposControl.replay();
List<Dependency> dependencies = List<Dependency> dependencies = searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID,
searchService.getDependencies( ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ); "1.0" );
metadataResolverControl.verify(); metadataResolverControl.verify();
userReposControl.verify(); userReposControl.verify();
@ -441,9 +444,9 @@ public class SearchServiceImplTest
String repoId = "repo1.mirror"; String repoId = "repo1.mirror";
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), Collections.singletonList( repoId ) );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID,
metadataResolver.getProjectVersion( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), ARCHIVA_TEST_ARTIFACT_ID,
null ); "1.0" ), null );
userReposControl.replay(); userReposControl.replay();
metadataResolverControl.replay(); metadataResolverControl.replay();
@ -495,9 +498,10 @@ public class SearchServiceImplTest
dependeeModels.add( dependeeModel ); dependeeModels.add( dependeeModel );
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( repoId,
metadataResolver.getProjectReferences( repoId, ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, "1.0" ), ARCHIVA_TEST_GROUP_ID,
dependeeModels ); ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ), dependeeModels );
metadataResolverControl.replay(); metadataResolverControl.replay();
userReposControl.replay(); userReposControl.replay();
@ -509,10 +513,10 @@ public class SearchServiceImplTest
assertNotNull( dependees ); assertNotNull( dependees );
assertEquals( 2, dependees.size() ); assertEquals( 2, dependees.size() );
assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-one", "1.0", "" ), assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-one", "1.0", "" ), dependees.get(
dependees.get( 0 ) ); 0 ) );
assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-two", "1.0", "" ), assertEquals( new Artifact( repoId, ARCHIVA_TEST_GROUP_ID, "archiva-dependee-two", "1.0", "" ), dependees.get(
dependees.get( 1 ) ); 1 ) );
} }
public void testGetDependeesArtifactDoesNotExist() 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 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 // no references. If it is later determined to be needed, we will need to modify the metadata content repository
userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds ); userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds );
metadataResolverControl.expectAndReturn( metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "repo1.mirror",
metadataResolver.getProjectReferences( "repo1.mirror", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, ARCHIVA_TEST_GROUP_ID,
"1.0" ), Collections.<ProjectVersionReference>emptyList() ); ARCHIVA_TEST_ARTIFACT_ID,
metadataResolverControl.expectAndReturn( "1.0" ),
metadataResolver.getProjectReferences( "public.releases", ARCHIVA_TEST_GROUP_ID, ARCHIVA_TEST_ARTIFACT_ID, Collections.<ProjectVersionReference>emptyList() );
"1.0" ), Collections.<ProjectVersionReference>emptyList() ); metadataResolverControl.expectAndReturn( metadataResolver.resolveProjectReferences( "public.releases",
ARCHIVA_TEST_GROUP_ID,
ARCHIVA_TEST_ARTIFACT_ID,
"1.0" ),
Collections.<ProjectVersionReference>emptyList() );
userReposControl.replay(); userReposControl.replay();
metadataResolverControl.replay(); metadataResolverControl.replay();

View File

@ -25,7 +25,7 @@ import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.repository.filter.ExcludesFilter; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -50,19 +50,12 @@ public class DefaultMetadataResolver
* *
* @plexus.requirement role-hint="maven2" * @plexus.requirement role-hint="maven2"
*/ */
private StorageMetadataResolver storageResolver; private RepositoryStorage repositoryStorage;
private static final Logger log = LoggerFactory.getLogger( DefaultMetadataResolver.class ); private static final Logger log = LoggerFactory.getLogger( DefaultMetadataResolver.class );
public ProjectMetadata getProject( String repoId, String namespace, String projectId ) public ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId,
throws MetadataResolutionException String projectVersion )
{
// TODO: intercept
return metadataRepository.getProject( repoId, namespace, projectId );
}
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException throws MetadataResolutionException
{ {
ProjectVersionMetadata metadata = metadataRepository.getProjectVersion( repoId, namespace, projectId, 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) // may then work here and be more efficient than always trying again)
if ( metadata == null || metadata.isIncomplete() ) if ( metadata == null || metadata.isIncomplete() )
{ {
metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion ); metadata = repositoryStorage.readProjectVersionMetadata( repoId, namespace, projectId, projectVersion );
if ( metadata != null ) if ( metadata != null )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -117,16 +110,8 @@ public class DefaultMetadataResolver
return metadata; return metadata;
} }
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, public Collection<ProjectVersionReference> resolveProjectReferences( String repoId, String namespace,
String projectVersion ) String projectId, String projectVersion )
throws MetadataResolutionException
{
// TODO: intercept
return metadataRepository.getArtifactVersions( repoId, namespace, projectId, projectVersion );
}
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException throws MetadataResolutionException
{ {
// TODO: is this assumption correct? could a storage mech. actually know all references in a non-Maven scenario? // 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 ); return metadataRepository.getProjectReferences( repoId, namespace, projectId, projectVersion );
} }
public Collection<String> getRootNamespaces( String repoId ) public Collection<String> resolveRootNamespaces( String repoId )
throws MetadataResolutionException throws MetadataResolutionException
{ {
Collection<String> namespaces = metadataRepository.getRootNamespaces( repoId ); Collection<String> namespaces = metadataRepository.getRootNamespaces( repoId );
Collection<String> storageNamespaces = storageResolver.getRootNamespaces( repoId, new ExcludesFilter<String>( Collection<String> storageNamespaces = repositoryStorage.listRootNamespaces( repoId, new ExcludesFilter<String>(
namespaces ) ); namespaces ) );
if ( storageNamespaces != null && !storageNamespaces.isEmpty() ) if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{ {
@ -163,15 +148,15 @@ public class DefaultMetadataResolver
return namespaces; return namespaces;
} }
public Collection<String> getNamespaces( String repoId, String namespace ) public Collection<String> resolveNamespaces( String repoId, String namespace )
throws MetadataResolutionException throws MetadataResolutionException
{ {
Collection<String> namespaces = metadataRepository.getNamespaces( repoId, namespace ); Collection<String> namespaces = metadataRepository.getNamespaces( repoId, namespace );
Collection<String> exclusions = new ArrayList<String>( namespaces ); Collection<String> exclusions = new ArrayList<String>( namespaces );
exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) ); exclusions.addAll( metadataRepository.getProjects( repoId, namespace ) );
Collection<String> storageNamespaces = storageResolver.getNamespaces( repoId, namespace, Collection<String> storageNamespaces = repositoryStorage.listNamespaces( repoId, namespace,
new ExcludesFilter<String>( new ExcludesFilter<String>(
exclusions ) ); exclusions ) );
if ( storageNamespaces != null && !storageNamespaces.isEmpty() ) if ( storageNamespaces != null && !storageNamespaces.isEmpty() )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -195,14 +180,14 @@ public class DefaultMetadataResolver
return namespaces; return namespaces;
} }
public Collection<String> getProjects( String repoId, String namespace ) public Collection<String> resolveProjects( String repoId, String namespace )
throws MetadataResolutionException throws MetadataResolutionException
{ {
Collection<String> projects = metadataRepository.getProjects( repoId, namespace ); Collection<String> projects = metadataRepository.getProjects( repoId, namespace );
Collection<String> exclusions = new ArrayList<String>( projects ); Collection<String> exclusions = new ArrayList<String>( projects );
exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) ); exclusions.addAll( metadataRepository.getNamespaces( repoId, namespace ) );
Collection<String> storageProjects = storageResolver.getProjects( repoId, namespace, new ExcludesFilter<String>( Collection<String> storageProjects = repositoryStorage.listProjects( repoId, namespace,
exclusions ) ); new ExcludesFilter<String>( exclusions ) );
if ( storageProjects != null && !storageProjects.isEmpty() ) if ( storageProjects != null && !storageProjects.isEmpty() )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -211,7 +196,7 @@ public class DefaultMetadataResolver
} }
for ( String projectId : storageProjects ) for ( String projectId : storageProjects )
{ {
ProjectMetadata projectMetadata = storageResolver.getProject( repoId, namespace, projectId ); ProjectMetadata projectMetadata = repositoryStorage.readProjectMetadata( repoId, namespace, projectId );
if ( projectMetadata != null ) if ( projectMetadata != null )
{ {
try try
@ -230,13 +215,13 @@ public class DefaultMetadataResolver
return projects; return projects;
} }
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) public Collection<String> resolveProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolutionException throws MetadataResolutionException
{ {
Collection<String> projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId ); Collection<String> projectVersions = metadataRepository.getProjectVersions( repoId, namespace, projectId );
Collection<String> storageProjectVersions = storageResolver.getProjectVersions( repoId, namespace, projectId, Collection<String> storageProjectVersions = repositoryStorage.listProjectVersions( repoId, namespace, projectId,
new ExcludesFilter<String>( new ExcludesFilter<String>(
projectVersions ) ); projectVersions ) );
if ( storageProjectVersions != null && !storageProjectVersions.isEmpty() ) if ( storageProjectVersions != null && !storageProjectVersions.isEmpty() )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -247,9 +232,10 @@ public class DefaultMetadataResolver
{ {
try try
{ {
ProjectVersionMetadata versionMetadata = storageResolver.getProjectVersion( repoId, namespace, ProjectVersionMetadata versionMetadata = repositoryStorage.readProjectVersionMetadata( repoId,
projectId, namespace,
projectVersion ); projectId,
projectVersion );
if ( versionMetadata != null ) if ( versionMetadata != null )
{ {
metadataRepository.updateProjectVersion( repoId, namespace, projectId, versionMetadata ); metadataRepository.updateProjectVersion( repoId, namespace, projectId, versionMetadata );
@ -271,17 +257,18 @@ public class DefaultMetadataResolver
return projectVersions; return projectVersions;
} }
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, public Collection<ArtifactMetadata> resolveArtifacts( String repoId, String namespace, String projectId,
String projectVersion ) String projectVersion )
throws MetadataResolutionException throws MetadataResolutionException
{ {
Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, namespace, projectId, Collection<ArtifactMetadata> artifacts = metadataRepository.getArtifacts( repoId, namespace, projectId,
projectVersion ); projectVersion );
Collection<ArtifactMetadata> storageArtifacts = storageResolver.getArtifacts( repoId, namespace, projectId, Collection<ArtifactMetadata> storageArtifacts = repositoryStorage.readArtifactsMetadata( repoId, namespace,
projectVersion, projectId,
new ExcludesFilter<String>( projectVersion,
createArtifactIdList( new ExcludesFilter<String>(
artifacts ) ) ); createArtifactIdList(
artifacts ) ) );
if ( storageArtifacts != null && !storageArtifacts.isEmpty() ) if ( storageArtifacts != null && !storageArtifacts.isEmpty() )
{ {
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )

View File

@ -30,7 +30,6 @@ import java.util.Date;
import java.util.List; import java.util.List;
public interface MetadataRepository public interface MetadataRepository
extends MetadataResolver
{ {
/** /**
* Update metadata for a particular project in the metadata repository, or create it if it does not already exist. * 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<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum ) List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
throws MetadataRepositoryException; 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; throws MetadataRepositoryException;
/** /**
@ -89,9 +88,49 @@ public interface MetadataRepository
* *
* @param repositoryId the repository to delete * @param repositoryId the repository to delete
*/ */
void deleteRepository( String repositoryId ) void removeRepository( String repositoryId )
throws MetadataRepositoryException; throws MetadataRepositoryException;
List<ArtifactMetadata> getArtifacts( String repositoryId ) List<ArtifactMetadata> getArtifacts( String repositoryId )
throws MetadataRepositoryException; 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<String> 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<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException;
Collection<String> getRootNamespaces( String repoId )
throws MetadataResolutionException;
Collection<String> getNamespaces( String repoId, String namespace )
throws MetadataResolutionException;
Collection<String> getProjects( String repoId, String namespace )
throws MetadataResolutionException;
Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolutionException;
Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException;
} }

View File

@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository;
*/ */
import org.apache.archiva.metadata.model.ArtifactMetadata; 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.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.model.ProjectVersionReference;
@ -28,13 +27,8 @@ import java.util.Collection;
public interface MetadataResolver public interface MetadataResolver
{ {
ProjectMetadata getProject( String repoId, String namespace, String projectId ) ProjectVersionMetadata resolveProjectVersion( String repoId, String namespace, String projectId,
throws MetadataResolutionException; String projectVersion )
ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataResolutionException;
Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataResolutionException; throws MetadataResolutionException;
/** /**
@ -48,23 +42,23 @@ public interface MetadataResolver
* @param projectVersion the version of the project to get references to * @param projectVersion the version of the project to get references to
* @return a list of project references * @return a list of project references
*/ */
Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, Collection<ProjectVersionReference> resolveProjectReferences( String repoId, String namespace, String projectId,
String projectVersion ) String projectVersion )
throws MetadataResolutionException; throws MetadataResolutionException;
Collection<String> getRootNamespaces( String repoId ) Collection<String> resolveRootNamespaces( String repoId )
throws MetadataResolutionException; throws MetadataResolutionException;
Collection<String> getNamespaces( String repoId, String namespace ) Collection<String> resolveNamespaces( String repoId, String namespace )
throws MetadataResolutionException; throws MetadataResolutionException;
Collection<String> getProjects( String repoId, String namespace ) Collection<String> resolveProjects( String repoId, String namespace )
throws MetadataResolutionException; throws MetadataResolutionException;
Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) Collection<String> resolveProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolutionException; throws MetadataResolutionException;
Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, Collection<ArtifactMetadata> resolveArtifacts( String repoId, String namespace, String projectId,
String projectVersion ) String projectVersion )
throws MetadataResolutionException; throws MetadataResolutionException;
} }

View File

@ -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<String> listRootNamespaces( String repoId, Filter<String> filter );
Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter );
Collection<String> listProjects( String repoId, String namespace, Filter<String> filter );
Collection<String> listProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter );
Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId,
String projectVersion, Filter<String> filter );
// TODO: reconsider this API, do we want to expose storage format in the form of a path?
ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path );
}

View File

@ -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<String> getRootNamespaces( String repoId, Filter<String> filter );
Collection<String> getNamespaces( String repoId, String namespace, Filter<String> filter );
Collection<String> getProjects( String repoId, String namespace, Filter<String> filter );
Collection<String> getProjectVersions( String repoId, String namespace, String projectId, Filter<String> filter );
Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, String projectVersion,
Filter<String> filter );
// TODO: reconsider this API, do we want to expose storage format in the form of a path?
ArtifactMetadata getArtifactForPath( String repoId, String path );
}

View File

@ -873,7 +873,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>( repository.getArtifacts( assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>( repository.getArtifacts(
TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) ); 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, assertTrue( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
TEST_PROJECT_VERSION ).isEmpty() ); TEST_PROJECT_VERSION ).isEmpty() );
@ -909,7 +909,7 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( expected, actual ); assertEquals( expected, actual );
repository.deleteRepository( TEST_REPO_ID ); repository.removeRepository( TEST_REPO_ID );
assertTrue( repository.getArtifacts( TEST_REPO_ID ).isEmpty() ); assertTrue( repository.getArtifacts( TEST_REPO_ID ).isEmpty() );
assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() ); assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() );

View File

@ -425,8 +425,8 @@ public class DefaultDependencyTreeBuilder
Collection<String> projectVersions; Collection<String> projectVersions;
try try
{ {
projectVersions = metadataResolver.getProjectVersions( repoId, artifact.getGroupId(), projectVersions = metadataResolver.resolveProjectVersions( repoId, artifact.getGroupId(),
artifact.getArtifactId() ); artifact.getArtifactId() );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
{ {

View File

@ -24,14 +24,12 @@ import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; 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.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataResolutionException; 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.filter.Filter;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; 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.archiva.reports.RepositoryProblemFacet;
import org.apache.maven.archiva.common.utils.VersionUtil; import org.apache.maven.archiva.common.utils.VersionUtil;
import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@ -63,10 +61,10 @@ import java.util.Date;
import java.util.List; 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 public class Maven2RepositoryStorage
implements StorageMetadataResolver implements RepositoryStorage
{ {
/** /**
* @plexus.requirement * @plexus.requirement
@ -88,12 +86,10 @@ public class Maven2RepositoryMetadataResolver
*/ */
private MetadataRepository metadataRepository; 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 String METADATA_FILENAME = "maven-metadata.xml";
private static final Filter<String> ALL = new AllFilter<String>();
private static final String PROBLEM_MISSING_POM = "missing-pom"; private static final String PROBLEM_MISSING_POM = "missing-pom";
private static final String PROBLEM_INVALID_POM = "invalid-pom"; private static final String PROBLEM_INVALID_POM = "invalid-pom";
@ -103,14 +99,14 @@ public class Maven2RepositoryMetadataResolver
private static final List<String> POTENTIAL_PROBLEMS = Arrays.asList( PROBLEM_INVALID_POM, PROBLEM_MISSING_POM, private static final List<String> POTENTIAL_PROBLEMS = Arrays.asList( PROBLEM_INVALID_POM, PROBLEM_MISSING_POM,
PROBLEM_MISLOCATED_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? // TODO: could natively implement the "shared model" concept from the browse action to avoid needing it there?
return null; return null;
} }
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, public ProjectVersionMetadata readProjectVersionMetadata( String repoId, String namespace, String projectId,
String projectVersion ) String projectVersion )
throws MetadataResolutionException throws MetadataResolutionException
{ {
// Remove problems associated with this version, since we'll be re-adding any that still exist // 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; return ci;
} }
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, public Collection<String> listRootNamespaces( String repoId, Filter<String> filter )
String projectVersion )
{
// TODO: useful, but not implemented yet, not called from DefaultMetadataResolver
throw new UnsupportedOperationException();
}
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
{
// Can't be determined on a Maven 2 repository
throw new UnsupportedOperationException();
}
public Collection<String> getRootNamespaces( String repoId )
{
return getRootNamespaces( repoId, ALL );
}
public Collection<String> getRootNamespaces( String repoId, Filter<String> filter )
{ {
File dir = getRepositoryBasedir( repoId ); File dir = getRepositoryBasedir( repoId );
@ -422,12 +399,7 @@ public class Maven2RepositoryMetadataResolver
return new File( repositoryConfiguration.getLocation() ); return new File( repositoryConfiguration.getLocation() );
} }
public Collection<String> getNamespaces( String repoId, String namespace ) public Collection<String> listNamespaces( String repoId, String namespace, Filter<String> filter )
{
return getNamespaces( repoId, namespace, ALL );
}
public Collection<String> getNamespaces( String repoId, String namespace, Filter<String> filter )
{ {
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace );
@ -448,12 +420,7 @@ public class Maven2RepositoryMetadataResolver
return namespaces; return namespaces;
} }
public Collection<String> getProjects( String repoId, String namespace ) public Collection<String> listProjects( String repoId, String namespace, Filter<String> filter )
{
return getProjects( repoId, namespace, ALL );
}
public Collection<String> getProjects( String repoId, String namespace, Filter<String> filter )
{ {
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace ); File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace );
@ -474,19 +441,8 @@ public class Maven2RepositoryMetadataResolver
return projects; return projects;
} }
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) public Collection<String> listProjectVersions( String repoId, String namespace, String projectId,
{ Filter<String> filter )
return getProjectVersions( repoId, namespace, projectId, ALL );
}
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
{
return getArtifacts( repoId, namespace, projectId, projectVersion, ALL );
}
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId,
Filter<String> filter )
{ {
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId ); File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId );
@ -494,8 +450,8 @@ public class Maven2RepositoryMetadataResolver
return getSortedFiles( dir, filter ); return getSortedFiles( dir, filter );
} }
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, public Collection<ArtifactMetadata> readArtifactsMetadata( String repoId, String namespace, String projectId,
String projectVersion, Filter<String> filter ) String projectVersion, Filter<String> filter )
{ {
File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion ); File dir = pathTranslator.toFile( getRepositoryBasedir( repoId ), namespace, projectId, projectVersion );
@ -514,7 +470,7 @@ public class Maven2RepositoryMetadataResolver
return artifacts; return artifacts;
} }
public ArtifactMetadata getArtifactForPath( String repoId, String path ) public ArtifactMetadata readArtifactMetadataFromPath( String repoId, String path )
{ {
ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path ); ArtifactMetadata metadata = pathTranslator.getArtifactForPath( repoId, path );
@ -653,11 +609,6 @@ public class Maven2RepositoryMetadataResolver
return metadata; return metadata;
} }
public void setConfiguration( ArchivaConfiguration configuration )
{
this.archivaConfiguration = configuration;
}
private static class DirectoryFilter private static class DirectoryFilter
implements FilenameFilter implements FilenameFilter
{ {

View File

@ -19,6 +19,12 @@ package org.apache.archiva.metadata.repository;
* under the License. * 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@ -26,14 +32,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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 public class TestMetadataRepository
extends TestMetadataResolver
implements MetadataRepository implements MetadataRepository
{ {
private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>(); private Map<String, MetadataFacet> facets = new HashMap<String, MetadataFacet>();
@ -49,7 +48,8 @@ public class TestMetadataRepository
//To change body of implemented methods use File | Settings | File Templates. //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. //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. 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. //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. //To change body of implemented methods use File | Settings | File Templates.
} }
public List<ArtifactMetadata> getArtifacts(String repositoryId){
public List<ArtifactMetadata> getArtifacts( String repositoryId )
{
return null; return null;
} }
public ProjectMetadata getProject( String repoId, String namespace, String projectId )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getRootNamespaces( String repoId )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getNamespaces( String repoId, String namespace )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getProjects( String repoId, String namespace )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
} }

View File

@ -19,61 +19,49 @@ package org.apache.archiva.metadata.repository;
* under the License. * under the License.
*/ */
import java.util.Collection;
import org.apache.archiva.metadata.model.ArtifactMetadata; 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.ProjectVersionMetadata;
import org.apache.archiva.metadata.model.ProjectVersionReference; import org.apache.archiva.metadata.model.ProjectVersionReference;
import java.util.Collection;
public class TestMetadataResolver public class TestMetadataResolver
implements MetadataResolver 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. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, public Collection<ProjectVersionReference> resolveProjectReferences( String repoId, String namespace,
String projectVersion ) String projectId, String projectVersion )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, public Collection<String> resolveRootNamespaces( String repoId )
String projectVersion )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, String projectId, public Collection<String> resolveNamespaces( String repoId, String namespace )
String projectVersion )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Collection<String> getRootNamespaces( String repoId ) public Collection<String> resolveProjects( String repoId, String namespace )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Collection<String> getNamespaces( String repoId, String namespace ) public Collection<String> resolveProjectVersions( String repoId, String namespace, String projectId )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }
public Collection<String> getProjects( String repoId, String namespace ) public Collection<ArtifactMetadata> resolveArtifacts( String repoId, String namespace, String projectId,
{ String projectVersion )
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
{
return null; //To change body of implemented methods use File | Settings | File Templates.
}
public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
{ {
return null; //To change body of implemented methods use File | Settings | File Templates. return null; //To change body of implemented methods use File | Settings | File Templates.
} }

View File

@ -27,8 +27,10 @@ import org.apache.archiva.metadata.model.MailingList;
import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataResolutionException; 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.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.archiva.reports.RepositoryProblemFacet;
import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.Configuration;
@ -45,7 +47,9 @@ import java.util.List;
public class Maven2RepositoryMetadataResolverTest public class Maven2RepositoryMetadataResolverTest
extends PlexusInSpringTestCase extends PlexusInSpringTestCase
{ {
private Maven2RepositoryMetadataResolver resolver; private static final Filter<String> ALL = new AllFilter<String>();
private Maven2RepositoryStorage resolver;
private static final String TEST_REPO_ID = "test"; private static final String TEST_REPO_ID = "test";
@ -74,7 +78,7 @@ public class Maven2RepositoryMetadataResolverTest
c.addManagedRepository( testRepo ); c.addManagedRepository( testRepo );
configuration.save( c ); configuration.save( c );
resolver = (Maven2RepositoryMetadataResolver) lookup( StorageMetadataResolver.class, "maven2" ); resolver = (Maven2RepositoryStorage) lookup( RepositoryStorage.class, "maven2" );
metadataRepository = (MetadataRepository) lookup( MetadataRepository.class ); metadataRepository = (MetadataRepository) lookup( MetadataRepository.class );
metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ); metadataRepository.removeMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID );
} }
@ -82,8 +86,8 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadata() public void testGetProjectVersionMetadata()
throws Exception throws Exception
{ {
ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache.archiva", ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache.archiva",
"archiva-common", "1.2.1" ); "archiva-common", "1.2.1" );
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
assertEquals( "jar", facet.getPackaging() ); assertEquals( "jar", facet.getPackaging() );
assertEquals( "http://archiva.apache.org/ref/1.2.1/archiva-base/archiva-common", metadata.getUrl() ); 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() public void testGetArtifactMetadata()
throws Exception throws Exception
{ {
Collection<ArtifactMetadata> springArtifacts = resolver.getArtifacts( TEST_REPO_ID, "org.codehaus.plexus", Collection<ArtifactMetadata> springArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID,
"plexus-spring", "1.2" ); "org.codehaus.plexus",
"plexus-spring", "1.2", ALL );
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( springArtifacts );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>() Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{ {
@ -177,8 +182,9 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetArtifactMetadataSnapshots() public void testGetArtifactMetadataSnapshots()
throws Exception throws Exception
{ {
Collection<ArtifactMetadata> testArtifacts = resolver.getArtifacts( TEST_REPO_ID, "com.example.test", Collection<ArtifactMetadata> testArtifacts = resolver.readArtifactsMetadata( TEST_REPO_ID, "com.example.test",
"test-artifact", "1.0-SNAPSHOT" ); "test-artifact", "1.0-SNAPSHOT",
ALL );
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( testArtifacts ); List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( testArtifacts );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>() Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{ {
@ -259,8 +265,8 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadataForTimestampedSnapshot() public void testGetProjectVersionMetadataForTimestampedSnapshot()
throws Exception throws Exception
{ {
ProjectVersionMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "org.apache", "apache", ProjectVersionMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "org.apache", "apache",
"5-SNAPSHOT" ); "5-SNAPSHOT" );
MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID ); MavenProjectFacet facet = (MavenProjectFacet) metadata.getFacet( MavenProjectFacet.FACET_ID );
assertEquals( "pom", facet.getPackaging() ); assertEquals( "pom", facet.getPackaging() );
assertEquals( "http://www.apache.org/", metadata.getUrl() ); assertEquals( "http://www.apache.org/", metadata.getUrl() );
@ -296,24 +302,24 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata() public void testGetProjectVersionMetadataForTimestampedSnapshotMissingMetadata()
throws Exception throws Exception
{ {
FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "missing-metadata", FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test",
"1.0-SNAPSHOT" ); "missing-metadata", "1.0-SNAPSHOT" );
assertNull( metadata ); assertNull( metadata );
} }
public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata() public void testGetProjectVersionMetadataForTimestampedSnapshotMalformedMetadata()
throws Exception throws Exception
{ {
FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "malformed-metadata", FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test",
"1.0-SNAPSHOT" ); "malformed-metadata", "1.0-SNAPSHOT" );
assertNull( metadata ); assertNull( metadata );
} }
public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata() public void testGetProjectVersionMetadataForTimestampedSnapshotIncompleteMetadata()
throws Exception throws Exception
{ {
FacetedMetadata metadata = resolver.getProjectVersion( TEST_REPO_ID, "com.example.test", "incomplete-metadata", FacetedMetadata metadata = resolver.readProjectVersionMetadata( TEST_REPO_ID, "com.example.test",
"1.0-SNAPSHOT" ); "incomplete-metadata", "1.0-SNAPSHOT" );
assertNull( metadata ); assertNull( metadata );
} }
@ -324,7 +330,7 @@ public class Maven2RepositoryMetadataResolverTest
try 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" ); fail( "Should have received an exception due to invalid POM" );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
@ -345,7 +351,7 @@ public class Maven2RepositoryMetadataResolverTest
try 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" ); fail( "Should have received an exception due to mislocated POM" );
} }
catch ( MetadataResolutionException e ) catch ( MetadataResolutionException e )
@ -364,7 +370,8 @@ public class Maven2RepositoryMetadataResolverTest
{ {
assertTrue( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); 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 ); assertNull( metadata );
assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() ); assertFalse( metadataRepository.getMetadataFacets( TEST_REPO_ID, RepositoryProblemFacet.FACET_ID ).isEmpty() );
@ -377,84 +384,87 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetRootNamespaces() 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() public void testGetNamespaces()
{ {
assertEquals( Arrays.asList( "example" ), resolver.getNamespaces( TEST_REPO_ID, "com" ) ); assertEquals( Arrays.asList( "example" ), resolver.listNamespaces( TEST_REPO_ID, "com", ALL ) );
assertEquals( Arrays.asList( "test" ), resolver.getNamespaces( TEST_REPO_ID, "com.example" ) ); assertEquals( Arrays.asList( "test" ), resolver.listNamespaces( TEST_REPO_ID, "com.example", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "com.example.test" ) ); assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "com.example.test",
ALL ) );
assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.getNamespaces( TEST_REPO_ID, "org" ) ); assertEquals( Arrays.asList( "apache", "codehaus" ), resolver.listNamespaces( TEST_REPO_ID, "org", ALL ) );
assertEquals( Arrays.asList( "archiva", "maven" ), resolver.getNamespaces( TEST_REPO_ID, "org.apache" ) ); assertEquals( Arrays.asList( "archiva", "maven" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.archiva" ) ); assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.archiva",
assertEquals( Arrays.asList( "plugins", "shared" ), resolver.getNamespaces( TEST_REPO_ID, ALL ) );
"org.apache.maven" ) ); assertEquals( Arrays.asList( "plugins", "shared" ), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven",
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, ALL ) );
"org.apache.maven.plugins" ) ); assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID,
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.apache.maven.plugins", ALL ) );
"org.apache.maven.shared" ) ); assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.apache.maven.shared",
ALL ) );
assertEquals( Arrays.asList( "plexus" ), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus" ) ); assertEquals( Arrays.asList( "plexus" ), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getNamespaces( TEST_REPO_ID, "org.codehaus.plexus" ) ); assertEquals( Collections.<String>emptyList(), resolver.listNamespaces( TEST_REPO_ID, "org.codehaus.plexus",
ALL ) );
} }
public void testGetProjects() public void testGetProjects()
{ {
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com" ) ); assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "com", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "com.example" ) ); assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "com.example", ALL ) );
assertEquals( Arrays.asList( "incomplete-metadata", "invalid-pom", "malformed-metadata", "mislocated-pom", assertEquals( Arrays.asList( "incomplete-metadata", "invalid-pom", "malformed-metadata", "mislocated-pom",
"missing-metadata", "test-artifact" ), resolver.getProjects( TEST_REPO_ID, "missing-metadata", "test-artifact" ), resolver.listProjects( TEST_REPO_ID,
"com.example.test" ) ); "com.example.test",
ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org" ) ); assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org", ALL ) );
assertEquals( Arrays.asList( "apache" ), resolver.getProjects( TEST_REPO_ID, "org.apache" ) ); assertEquals( Arrays.asList( "apache" ), resolver.listProjects( TEST_REPO_ID, "org.apache", ALL ) );
assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ), assertEquals( Arrays.asList( "archiva", "archiva-base", "archiva-common", "archiva-modules", "archiva-parent" ),
resolver.getProjects( TEST_REPO_ID, "org.apache.archiva" ) ); resolver.listProjects( TEST_REPO_ID, "org.apache.archiva", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, "org.apache.maven" ) ); assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjects( TEST_REPO_ID, assertEquals( Collections.<String>emptyList(), resolver.listProjects( TEST_REPO_ID, "org.apache.maven.plugins",
"org.apache.maven.plugins" ) ); ALL ) );
assertEquals( Arrays.asList( "maven-downloader" ), resolver.getProjects( TEST_REPO_ID, assertEquals( Arrays.asList( "maven-downloader" ), resolver.listProjects( TEST_REPO_ID,
"org.apache.maven.shared" ) ); "org.apache.maven.shared", ALL ) );
} }
public void testGetProjectVersions() public void testGetProjectVersions()
{ {
assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test",
"incomplete-metadata" ) ); "incomplete-metadata", ALL ) );
assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test",
"malformed-metadata" ) ); "malformed-metadata", ALL ) );
assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", assertEquals( Arrays.asList( "1.0-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test",
"missing-metadata" ) ); "missing-metadata", ALL ) );
assertEquals( Arrays.asList( "1.0" ), resolver.getProjectVersions( TEST_REPO_ID, "com.example.test", assertEquals( Arrays.asList( "1.0" ), resolver.listProjectVersions( TEST_REPO_ID, "com.example.test",
"invalid-pom" ) ); "invalid-pom", ALL ) );
assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache", assertEquals( Arrays.asList( "4", "5-SNAPSHOT" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache",
"apache" ) ); "apache", ALL ) );
assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", assertEquals( Arrays.asList( "1.2.1", "1.2.2" ), resolver.listProjectVersions( TEST_REPO_ID,
"archiva" ) ); "org.apache.archiva", "archiva",
assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", ALL ) );
"archiva-base" ) ); assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva",
assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-base", ALL ) );
"archiva-common" ) ); assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva",
assertEquals( Arrays.asList( "1.2.1" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-common", ALL ) );
"archiva-modules" ) ); assertEquals( Arrays.asList( "1.2.1" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva",
assertEquals( Arrays.asList( "3" ), resolver.getProjectVersions( TEST_REPO_ID, "org.apache.archiva", "archiva-modules", ALL ) );
"archiva-parent" ) ); assertEquals( Arrays.asList( "3" ), resolver.listProjectVersions( TEST_REPO_ID, "org.apache.archiva",
"archiva-parent", ALL ) );
assertEquals( Collections.<String>emptyList(), resolver.getProjectVersions( TEST_REPO_ID, assertEquals( Collections.<String>emptyList(), resolver.listProjectVersions( TEST_REPO_ID,
"org.apache.maven.shared", "org.apache.maven.shared",
"maven-downloader" ) ); "maven-downloader", ALL ) );
} }
public void testGetArtifacts() public void testGetArtifacts()
{ {
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata(
"org.codehaus.plexus", TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", ALL ) );
"plexus-spring",
"1.2" ) );
assertEquals( 3, artifacts.size() ); assertEquals( 3, artifacts.size() );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>() Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{ {
@ -474,10 +484,8 @@ public class Maven2RepositoryMetadataResolverTest
{ {
ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList( ExcludesFilter<String> filter = new ExcludesFilter<String>( Collections.singletonList(
"plexus-spring-1.2.pom" ) ); "plexus-spring-1.2.pom" ) );
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata(
"org.codehaus.plexus", TEST_REPO_ID, "org.codehaus.plexus", "plexus-spring", "1.2", filter ) );
"plexus-spring",
"1.2", filter ) );
assertEquals( 2, artifacts.size() ); assertEquals( 2, artifacts.size() );
Collections.sort( artifacts, new Comparator<ArtifactMetadata>() Collections.sort( artifacts, new Comparator<ArtifactMetadata>()
{ {
@ -493,10 +501,8 @@ public class Maven2RepositoryMetadataResolverTest
public void testGetArtifactsTimestampedSnapshots() public void testGetArtifactsTimestampedSnapshots()
{ {
List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.getArtifacts( TEST_REPO_ID, List<ArtifactMetadata> artifacts = new ArrayList<ArtifactMetadata>( resolver.readArtifactsMetadata(
"com.example.test", TEST_REPO_ID, "com.example.test", "missing-metadata", "1.0-SNAPSHOT", ALL ) );
"missing-metadata",
"1.0-SNAPSHOT" ) );
assertEquals( 1, artifacts.size() ); assertEquals( 1, artifacts.size() );
ArtifactMetadata artifact = artifacts.get( 0 ); ArtifactMetadata artifact = artifacts.get( 0 );

View File

@ -565,7 +565,7 @@ public class FileMetadataRepository
return artifacts; 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 ); 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 try
{ {

View File

@ -589,7 +589,7 @@ public class JcrMetadataRepository
return artifacts; 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 ) String id )
throws MetadataRepositoryException throws MetadataRepositoryException
{ {
@ -608,7 +608,7 @@ public class JcrMetadataRepository
} }
} }
public void deleteRepository( String repositoryId ) public void removeRepository( String repositoryId )
throws MetadataRepositoryException throws MetadataRepositoryException
{ {
try try