import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.ConfigurationNames;
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.layout.BidirectionalRepositoryLayout;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayoutFactory;
-import org.apache.maven.archiva.repository.layout.LayoutException;
+import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
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.ManagedRepositoryProjectResolver;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
* @plexus.requirement
*/
private ArchivaConfiguration archivaConfiguration;
-
+
/**
* @plexus.requirement
*/
- private BidirectionalRepositoryLayoutFactory layoutFactory;
+ private RepositoryContentFactory repositoryFactory;
/**
* @plexus.requirement role-hint="model400"
* @plexus.requirement role-hint="model300"
*/
private ProjectModelReader project300Reader;
-
+
private ProjectModelResolverStack currentResolverStack = new ProjectModelResolverStack();
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
private ManagedRepositoryProjectResolver toResolver( ManagedRepositoryConfiguration repo )
throws RepositoryException
{
- try
- {
- BidirectionalRepositoryLayout layout = layoutFactory.getLayout( repo.getLayout() );
- ProjectModelReader reader = project400Reader;
+ ManagedRepositoryContent repoContent = repositoryFactory.getManagedRepositoryContent( repo.getId() );
+ ProjectModelReader reader = project400Reader;
- if ( StringUtils.equals( "legacy", repo.getLayout() ) )
- {
- reader = project300Reader;
- }
-
- ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader, layout );
- return resolver;
- }
- catch ( LayoutException e )
+ if ( StringUtils.equals( "legacy", repo.getLayout() ) )
{
- throw new RepositoryException(
- "Unable to create RepositoryProjectResolver due to invalid layout spec: " + repo );
+ reader = project300Reader;
}
+
+ return new ManagedRepositoryProjectResolver( repoContent, reader );
}
private void update()
* under the License.
*/
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.model.ArchivaArtifact;
import org.apache.maven.archiva.model.ArchivaProjectModel;
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.ProjectModelReader;
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
public class ManagedRepositoryProjectResolver
implements ProjectModelResolver, FilesystemBasedResolver
{
- private ManagedRepositoryConfiguration repository;
+ private ManagedRepositoryContent repository;
private ProjectModelReader reader;
- private BidirectionalRepositoryLayout layout;
-
- public ManagedRepositoryProjectResolver( ManagedRepositoryConfiguration repository, ProjectModelReader reader,
- BidirectionalRepositoryLayout layout )
+ public ManagedRepositoryProjectResolver( ManagedRepositoryContent repository, ProjectModelReader reader )
{
this.repository = repository;
this.reader = reader;
- this.layout = layout;
}
public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
ArchivaArtifact artifact = new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference
.getVersion(), "", "pom" );
- String path = layout.toPath( artifact );
- File repoFile = new File( this.repository.getLocation(), path );
+ File repoFile = repository.toFile( artifact );
return reader.read( repoFile );
}
repo.setUrl( url );
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 )
throws Exception
repo.setId( id );
repo.setName( name );
repo.setUrl( url );
+ repo.setLayout( layout );
RemoteRepositoryContent repoContent = (RemoteRepositoryContent) lookup( RemoteRepositoryContent.class, layout );
repoContent.setRepository( repo );
*/
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.Dependency;
import org.apache.maven.archiva.model.Individual;
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
-import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout;
-import org.apache.maven.archiva.repository.layout.DefaultBidirectionalRepositoryLayout;
+import org.apache.maven.archiva.repository.ManagedRepositoryContent;
import org.apache.maven.archiva.repository.project.ProjectModelException;
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
import org.apache.maven.archiva.repository.project.ProjectModelReader;
return reader.read( pomFile );
}
- private ProjectModelResolver createDefaultRepositoryResolver()
+ private ProjectModelResolver createDefaultRepositoryResolver() throws Exception
{
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();
- BidirectionalRepositoryLayout layout = new DefaultBidirectionalRepositoryLayout();
- ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader, layout );
+ ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader );
return resolver;
}