Updating from bidirlayout to RepoContent techniques.

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@585569 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-10-17 16:47:33 +00:00
parent f3d43d4d4d
commit 568312aa1f
4 changed files with 36 additions and 39 deletions

View File

@ -23,13 +23,12 @@ import org.apache.commons.lang.StringUtils;
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;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.RepositoryContentFactory;
import org.apache.maven.archiva.repository.RepositoryException; import org.apache.maven.archiva.repository.RepositoryException;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
import org.apache.maven.archiva.repository.layout.LayoutException;
import org.apache.maven.archiva.repository.project.resolvers.NopProjectResolver; import org.apache.maven.archiva.repository.project.resolvers.NopProjectResolver;
import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack; import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack;
import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@ -57,7 +56,7 @@ public class ProjectModelResolverFactory
/** /**
* @plexus.requirement * @plexus.requirement
*/ */
private BidirectionalRepositoryLayoutFactory layoutFactory; private RepositoryContentFactory repositoryFactory;
/** /**
* @plexus.requirement role-hint="model400" * @plexus.requirement role-hint="model400"
@ -99,9 +98,7 @@ public class ProjectModelResolverFactory
private ManagedRepositoryProjectResolver toResolver( ManagedRepositoryConfiguration repo ) private ManagedRepositoryProjectResolver toResolver( ManagedRepositoryConfiguration repo )
throws RepositoryException throws RepositoryException
{ {
try ManagedRepositoryContent repoContent = repositoryFactory.getManagedRepositoryContent( repo.getId() );
{
BidirectionalRepositoryLayout layout = layoutFactory.getLayout( repo.getLayout() );
ProjectModelReader reader = project400Reader; ProjectModelReader reader = project400Reader;
if ( StringUtils.equals( "legacy", repo.getLayout() ) ) if ( StringUtils.equals( "legacy", repo.getLayout() ) )
@ -109,14 +106,7 @@ public class ProjectModelResolverFactory
reader = project300Reader; reader = project300Reader;
} }
ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader, layout ); return new ManagedRepositoryProjectResolver( repoContent, reader );
return resolver;
}
catch ( LayoutException e )
{
throw new RepositoryException(
"Unable to create RepositoryProjectResolver due to invalid layout spec: " + repo );
}
} }
private void update() private void update()

View File

@ -19,11 +19,10 @@ package org.apache.maven.archiva.repository.project.resolvers;
* under the License. * under the License.
*/ */
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.model.ArchivaArtifact; import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.VersionedReference; import org.apache.maven.archiva.model.VersionedReference;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.project.ProjectModelException; import org.apache.maven.archiva.repository.project.ProjectModelException;
import org.apache.maven.archiva.repository.project.ProjectModelReader; import org.apache.maven.archiva.repository.project.ProjectModelReader;
import org.apache.maven.archiva.repository.project.ProjectModelResolver; import org.apache.maven.archiva.repository.project.ProjectModelResolver;
@ -39,18 +38,14 @@ import java.io.File;
public class ManagedRepositoryProjectResolver public class ManagedRepositoryProjectResolver
implements ProjectModelResolver, FilesystemBasedResolver implements ProjectModelResolver, FilesystemBasedResolver
{ {
private ManagedRepositoryConfiguration repository; private ManagedRepositoryContent repository;
private ProjectModelReader reader; private ProjectModelReader reader;
private BidirectionalRepositoryLayout layout; public ManagedRepositoryProjectResolver( ManagedRepositoryContent repository, ProjectModelReader reader )
public ManagedRepositoryProjectResolver( ManagedRepositoryConfiguration repository, ProjectModelReader reader,
BidirectionalRepositoryLayout layout )
{ {
this.repository = repository; this.repository = repository;
this.reader = reader; this.reader = reader;
this.layout = layout;
} }
public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
@ -59,8 +54,7 @@ public class ManagedRepositoryProjectResolver
ArchivaArtifact artifact = new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference ArchivaArtifact artifact = new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference
.getVersion(), "", "pom" ); .getVersion(), "", "pom" );
String path = layout.toPath( artifact ); File repoFile = repository.toFile( artifact );
File repoFile = new File( this.repository.getLocation(), path );
return reader.read( repoFile ); return reader.read( repoFile );
} }

View File

@ -52,6 +52,21 @@ public abstract class AbstractRepositoryLayerTestCase
return repo; return repo;
} }
protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, File location, String layout )
throws Exception
{
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId( id );
repo.setName( name );
repo.setLocation( location.getAbsolutePath() );
repo.setLayout( layout );
ManagedRepositoryContent repoContent = (ManagedRepositoryContent) lookup( ManagedRepositoryContent.class, layout );
repoContent.setRepository( repo );
return repoContent;
}
protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout ) protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
throws Exception throws Exception
{ {
@ -59,6 +74,7 @@ public abstract class AbstractRepositoryLayerTestCase
repo.setId( id ); repo.setId( id );
repo.setName( name ); repo.setName( name );
repo.setUrl( url ); repo.setUrl( url );
repo.setLayout( layout );
RemoteRepositoryContent repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, layout ); RemoteRepositoryContent repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, layout );
repoContent.setRepository( repo ); repoContent.setRepository( repo );

View File

@ -20,13 +20,11 @@ package org.apache.maven.archiva.repository.project.filters;
*/ */
import org.apache.maven.archiva.common.utils.VersionUtil; import org.apache.maven.archiva.common.utils.VersionUtil;
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.model.Dependency; import org.apache.maven.archiva.model.Dependency;
import org.apache.maven.archiva.model.Individual; import org.apache.maven.archiva.model.Individual;
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase; import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout;
import org.apache.maven.archiva.repository.project.ProjectModelException; import org.apache.maven.archiva.repository.project.ProjectModelException;
import org.apache.maven.archiva.repository.project.ProjectModelFilter; import org.apache.maven.archiva.repository.project.ProjectModelFilter;
import org.apache.maven.archiva.repository.project.ProjectModelReader; import org.apache.maven.archiva.repository.project.ProjectModelReader;
@ -68,15 +66,14 @@ public class EffectiveProjectModelFilterTest
return reader.read( pomFile ); return reader.read( pomFile );
} }
private ProjectModelResolver createDefaultRepositoryResolver() private ProjectModelResolver createDefaultRepositoryResolver() throws Exception
{ {
File defaultRepoDir = new File( getBasedir(), DEFAULT_REPOSITORY ); File defaultRepoDir = new File( getBasedir(), DEFAULT_REPOSITORY );
ManagedRepositoryConfiguration repo = createRepository( "defaultTestRepo", "Default Test Repo", defaultRepoDir ); ManagedRepositoryContent repo = createManagedRepositoryContent( "defaultTestRepo", "Default Test Repo", defaultRepoDir, "default" );
ProjectModelReader reader = new ProjectModel400Reader(); ProjectModelReader reader = new ProjectModel400Reader();
BidirectionalRepositoryLayout layout = new DefaultBidirectionalRepositoryLayout(); ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader );
ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader, layout );
return resolver; return resolver;
} }