diff options
author | Martin Stockhammer <martin_s@apache.org> | 2017-11-01 15:34:34 +0100 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2017-11-01 15:34:34 +0100 |
commit | 763991b3d9f3ca8d04a782d08492b9647953597a (patch) | |
tree | 3783b13aebb2e4039a2cc80f21bc145b3a363937 | |
parent | 4bcf4c0cd05220156cbba00be5408985f182805c (diff) | |
download | archiva-763991b3d9f3ca8d04a782d08492b9647953597a.tar.gz archiva-763991b3d9f3ca8d04a782d08492b9647953597a.zip |
Adapting maven repository provider to new repository api
Using the new repository interfaces where necessary.
19 files changed, 241 insertions, 107 deletions
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java index 31e8c674e..359c7ebc1 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/Maven2RepositoryStorage.java @@ -724,7 +724,7 @@ public class Maven2RepositoryStorage @Override - public String getFilePath( String requestPath, ManagedRepository managedRepository ) + public String getFilePath( String requestPath, org.apache.archiva.repository.ManagedRepository managedRepository ) { // managedRepository can be null // extract artifact reference from url diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java index 1fb858d91..298aa5d18 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java @@ -19,7 +19,7 @@ package org.apache.archiva.repository.content.maven2; * under the License. */ -import org.apache.archiva.admin.model.beans.ManagedRepository; +import org.apache.archiva.common.utils.PathUtil; import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.metadata.repository.storage.maven2.DefaultArtifactMappingProvider; import org.apache.archiva.model.ArchivaArtifact; @@ -37,6 +37,7 @@ import org.springframework.stereotype.Service; import javax.inject.Inject; import javax.inject.Named; import java.io.IOException; +import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -50,7 +51,7 @@ import java.util.stream.Stream; /** * ManagedDefaultRepositoryContent */ -@Service ("managedRepositoryContent#default") +@Service ("managedRepositoryContent#maven") @Scope ("prototype") public class ManagedDefaultRepositoryContent extends AbstractDefaultRepositoryContent @@ -60,7 +61,7 @@ public class ManagedDefaultRepositoryContent @Named ( "fileTypes" ) private FileTypes filetypes; - private ManagedRepository repository; + private org.apache.archiva.repository.ManagedRepository repository; public ManagedDefaultRepositoryContent() { @@ -171,7 +172,7 @@ public class ManagedDefaultRepositoryContent throws ContentNotFoundException { Path artifactFile = toFile( reference ); - Path repoBase = Paths.get(repository.getLocation()).toAbsolutePath(); + Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = artifactFile.getParent().toAbsolutePath(); if ( !Files.exists(repoDir)) @@ -215,11 +216,21 @@ public class ManagedDefaultRepositoryContent @Override public String getRepoRoot() { - return repository.getLocation(); + return convertUriToPath( repository.getLocation() ); + } + + private String convertUriToPath( URI uri ) { + if (uri.getScheme()==null) { + return Paths.get(uri.getPath()).toString(); + } else if ("file".equals(uri.getScheme())) { + return Paths.get(uri).toString(); + } else { + return uri.toString(); + } } @Override - public ManagedRepository getRepository() + public org.apache.archiva.repository.ManagedRepository getRepository() { return repository; } @@ -244,7 +255,7 @@ public class ManagedDefaultRepositoryContent path = path.substring( 0, idx ); } - Path repoDir = Paths.get( repository.getLocation(), path ); + Path repoDir = PathUtil.getPathFromUri( repository.getLocation() ).resolve( path ); if ( !Files.exists(repoDir) ) { @@ -297,7 +308,7 @@ public class ManagedDefaultRepositoryContent path = path.substring( 0, idx ); } - Path repoBase = Paths.get(repository.getLocation()); + Path repoBase = PathUtil.getPathFromUri(repository.getLocation()); Path repoDir = repoBase.resolve( path ); if ( !Files.exists(repoDir) ) @@ -370,7 +381,7 @@ public class ManagedDefaultRepositoryContent } @Override - public void setRepository( ManagedRepository repository ) + public void setRepository( org.apache.archiva.repository.ManagedRepository repository ) { this.repository = repository; } @@ -385,9 +396,10 @@ public class ManagedDefaultRepositoryContent public ArtifactReference toArtifactReference( String path ) throws LayoutException { - if ( ( path != null ) && path.startsWith( repository.getLocation() ) && repository.getLocation().length() > 0 ) + String repoPath = convertUriToPath( repository.getLocation() ); + if ( ( path != null ) && path.startsWith( repoPath ) && repoPath.length() > 0 ) { - return super.toArtifactReference( path.substring( repository.getLocation().length() + 1 ) ); + return super.toArtifactReference( path.substring( repoPath.length() + 1 ) ); } return super.toArtifactReference( path ); @@ -407,13 +419,13 @@ public class ManagedDefaultRepositoryContent @Override public Path toFile( ArtifactReference reference ) { - return Paths.get( repository.getLocation(), toPath( reference ) ); + return PathUtil.getPathFromUri( repository.getLocation()).resolve( toPath( reference ) ); } @Override public Path toFile( ArchivaArtifact reference ) { - return Paths.get( repository.getLocation(), toPath( reference ) ); + return PathUtil.getPathFromUri( repository.getLocation()).resolve( toPath( reference ) ); } /** @@ -436,7 +448,7 @@ public class ManagedDefaultRepositoryContent path = path.substring( 0, idx ); } - Path repoBase = Paths.get(repository.getLocation()).toAbsolutePath(); + Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = repoBase.resolve( path ); if ( !Files.exists(repoDir) ) diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java index 9bf565b72..2942c2348 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/maven2/RemoteDefaultRepositoryContent.java @@ -19,9 +19,9 @@ package org.apache.archiva.repository.content.maven2; * under the License. */ -import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.RepositoryURL; +import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.layout.LayoutException; import org.springframework.context.annotation.Scope; @@ -29,10 +29,8 @@ import org.springframework.stereotype.Service; /** * RemoteDefaultRepositoryContent - * - * */ -@Service( "remoteRepositoryContent#default" ) +@Service( "remoteRepositoryContent#maven" ) @Scope( "prototype" ) public class RemoteDefaultRepositoryContent extends AbstractDefaultRepositoryContent @@ -41,21 +39,29 @@ public class RemoteDefaultRepositoryContent private RemoteRepository repository; @Override - public String getId() + public String getId( ) { - return repository.getId(); + return repository.getId( ); } @Override - public RemoteRepository getRepository() + public RemoteRepository getRepository( ) { return repository; } @Override - public RepositoryURL getURL() + public RepositoryURL getURL( ) { - return new RepositoryURL( repository.getUrl() ); + try + { + return new RepositoryURL( repository.getLocation( ).toString( ) ); + } + catch ( Exception e ) + { + log.error( "Could not convert location url {}", repository.getLocation( ) ); + return new RepositoryURL( "" ); + } } @Override @@ -74,9 +80,10 @@ public class RemoteDefaultRepositoryContent public ArtifactReference toArtifactReference( String path ) throws LayoutException { - if ( ( path != null ) && path.startsWith( repository.getUrl() ) ) + + if ( ( path != null ) && repository.getLocation()!=null && path.startsWith( repository.getLocation().toString() ) ) { - return super.toArtifactReference( path.substring( repository.getUrl().length() ) ); + return super.toArtifactReference( path.substring( repository.getLocation().toString().length( ) ) ); } return super.toArtifactReference( path ); @@ -85,7 +92,7 @@ public class RemoteDefaultRepositoryContent @Override public RepositoryURL toURL( ArtifactReference reference ) { - String url = repository.getUrl() + toPath( reference ); + String url = repository.getLocation( ) + toPath( reference ); return new RepositoryURL( url ); } } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java index f9b169808..aaad382ed 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java @@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven2; * under the License. */ +import org.apache.archiva.common.utils.PathUtil; import org.apache.archiva.repository.AbstractManagedRepository; import org.apache.archiva.repository.ReleaseScheme; import org.apache.archiva.repository.RepositoryCapabilities; @@ -29,7 +30,14 @@ import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.RepositoryFeature; import org.apache.archiva.repository.features.StagingRepositoryFeature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.Collections; import java.util.HashSet; import java.util.Locale; @@ -40,6 +48,9 @@ import java.util.Set; */ public class MavenManagedRepository extends AbstractManagedRepository { + + private static final Logger log = LoggerFactory.getLogger( MavenManagedRepository.class ); + public static final String DEFAULT_LAYOUT = "default"; public static final String LEGACY_LAYOUT = "legacy"; private ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature( ); @@ -106,4 +117,21 @@ public class MavenManagedRepository extends AbstractManagedRepository { return indexCreationFeature.hasIndex(); } + + @Override + public void setLocation( URI location ) + { + super.setLocation( location ); + Path newLoc = PathUtil.getPathFromUri( location ); + if (!Files.exists( newLoc )) { + try + { + Files.createDirectories( newLoc ); + } + catch ( IOException e ) + { + log.error("Could not create directory {}",location, e); + } + } + } } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java index 224177d74..8c7a8cf1e 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java @@ -7,11 +7,9 @@ import org.apache.archiva.repository.RepositoryCapabilities; import org.apache.archiva.repository.RepositoryType; import org.apache.archiva.repository.StandardCapabilities; import org.apache.archiva.repository.UnsupportedFeatureException; -import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.RemoteIndexFeature; import org.apache.archiva.repository.features.RepositoryFeature; -import org.apache.archiva.repository.features.StagingRepositoryFeature; import java.util.Locale; diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java index b1e763a4c..6bdd0b8b0 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java @@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven2; * under the License. */ +import org.apache.archiva.common.utils.PathUtil; import org.apache.archiva.configuration.AbstractRepositoryConfiguration; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; @@ -94,6 +95,9 @@ public class MavenRepositoryProvider implements RepositoryProvider private URI getURIFromString( String uriStr) throws RepositoryException { URI uri; try { + if (StringUtils.isEmpty( uriStr )) { + return new URI(""); + } if (uriStr.startsWith("/")) { // only absolute paths are prepended with file scheme uri = new URI("file://"+uriStr); @@ -117,6 +121,7 @@ public class MavenRepositoryProvider implements RepositoryProvider throw new RepositoryException( "The config entry "+uriStr+" cannot be converted to URI." ); } } + log.debug("Setting location uri: {}", uri); return uri; } @@ -140,8 +145,9 @@ public class MavenRepositoryProvider implements RepositoryProvider throw new RepositoryException( "The location entry is not a valid uri: "+cfg.getLocation() ); } setBaseConfig( repo, cfg ); - Path repoDir = Paths.get(repo.getAbsoluteLocation()); + Path repoDir = PathUtil.getPathFromUri(repo.getAbsoluteLocation()); if (!Files.exists(repoDir)) { + log.debug("Creating repo directory {}", repoDir); try { Files.createDirectories( repoDir ); @@ -168,18 +174,40 @@ public class MavenRepositoryProvider implements RepositoryProvider IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ).get( ); indexCreationFeature.setSkipPackedIndexCreation( cfg.isSkipPackedIndexCreation() ); indexCreationFeature.setIndexPath( getURIFromString( cfg.getIndexDir() ) ); + Path indexPath; + if (indexCreationFeature.getIndexPath().getScheme()==null) { + indexPath = Paths.get(indexCreationFeature.getIndexPath().getPath()); + } else { + indexPath = Paths.get(indexCreationFeature.getIndexPath()); + } + Path absoluteIndexPath; + if (indexPath.isAbsolute()) { + absoluteIndexPath = indexPath; + } else { + absoluteIndexPath = PathUtil.getPathFromUri( repo.getLocation()).resolve(indexCreationFeature.getIndexPath().getPath()); + } + try + { + Files.createDirectories( absoluteIndexPath ); + } + catch ( IOException e ) + { + log.error("Could not create index directory {}", absoluteIndexPath); + throw new RepositoryException( "Could not create index directory "+absoluteIndexPath ); + } ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ).get(); artifactCleanupFeature.setDeleteReleasedSnapshots( cfg.isDeleteReleasedSnapshots() ); artifactCleanupFeature.setRetentionCount( cfg.getRetentionCount() ); - artifactCleanupFeature.setRetentionTime( Period.ofDays( cfg.getRetentionTime() ) ); + artifactCleanupFeature.setRetentionPeriod( Period.ofDays( cfg.getRetentionPeriod() ) ); } @Override public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration baseConfiguration ) throws RepositoryException { + log.debug("Creating staging instance for {}", baseConfiguration.getId()); return createManagedInstance( getStageRepoConfig( baseConfiguration ) ); } @@ -192,6 +220,16 @@ public class MavenRepositoryProvider implements RepositoryProvider return repo; } + private String convertUriToPath(URI uri) { + if (uri.getScheme()==null) { + return uri.getPath(); + } else if ("file".equals(uri.getScheme())) { + return Paths.get(uri).toString(); + } else { + return uri.toString(); + } + } + @Override public void updateRemoteInstance( EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg ) throws RepositoryException { @@ -228,7 +266,7 @@ public class MavenRepositoryProvider implements RepositoryProvider } repo.setExtraHeaders( cfg.getExtraHeaders() ); repo.setExtraParameters( cfg.getExtraParameters() ); - PasswordCredentials credentials = new PasswordCredentials(); + PasswordCredentials credentials = new PasswordCredentials("", new char[0]); if (cfg.getPassword()!=null && cfg.getUsername()!=null) { credentials.setPassword( cfg.getPassword( ).toCharArray( ) ); @@ -273,7 +311,7 @@ public class MavenRepositoryProvider implements RepositoryProvider cfg.setRefreshCronExpression( remoteRepository.getSchedulingDefinition() ); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature( IndexCreationFeature.class ).get(); - cfg.setIndexDir( indexCreationFeature.getIndexPath().toString()); + cfg.setIndexDir( convertUriToPath( indexCreationFeature.getIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature( RemoteIndexFeature.class ).get(); cfg.setRemoteIndexUrl( remoteIndexFeature.getIndexUri().toString() ); @@ -301,22 +339,20 @@ public class MavenRepositoryProvider implements RepositoryProvider cfg.setId( managedRepository.getId() ); cfg.setName( managedRepository.getName() ); cfg.setDescription( managedRepository.getDescription() ); - cfg.setLocation( managedRepository.getLocation().toString() ); + cfg.setLocation( convertUriToPath( managedRepository.getLocation() ) ); cfg.setLayout( managedRepository.getLayout() ); cfg.setRefreshCronExpression( managedRepository.getSchedulingDefinition() ); cfg.setScanned( managedRepository.isScanned() ); cfg.setBlockRedeployments( managedRepository.blocksRedeployments() ); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature( StagingRepositoryFeature.class ).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); - - IndexCreationFeature indexCreationFeature = managedRepository.getFeature( IndexCreationFeature.class ).get(); - cfg.setIndexDir( indexCreationFeature.getIndexPath().toString()); + cfg.setIndexDir(convertUriToPath( indexCreationFeature.getIndexPath() )); cfg.setSkipPackedIndexCreation( indexCreationFeature.isSkipPackedIndexCreation() ); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature( ArtifactCleanupFeature.class ).get(); cfg.setRetentionCount( artifactCleanupFeature.getRetentionCount()); - cfg.setRetentionTime( artifactCleanupFeature.getRetentionTime().getDays() ); + cfg.setRetentionPeriod( artifactCleanupFeature.getRetentionPeriod().getDays() ); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE )) { @@ -340,8 +376,9 @@ public class MavenRepositoryProvider implements RepositoryProvider stagingRepository.setLayout( repository.getLayout() ); stagingRepository.setName( repository.getName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX ); stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() ); - stagingRepository.setRetentionTime( repository.getRetentionTime() ); + stagingRepository.setRetentionPeriod( repository.getRetentionPeriod() ); stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() ); + stagingRepository.setStageRepoNeeded( false ); String path = repository.getLocation(); int lastIndex = path.replace( '\\', '/' ).lastIndexOf( '/' ); @@ -349,16 +386,28 @@ public class MavenRepositoryProvider implements RepositoryProvider if ( StringUtils.isNotBlank( repository.getIndexDir() ) ) { - Path indexDir = Paths.get( repository.getIndexDir() ); - // in case of absolute dir do not use the same - if ( indexDir.isAbsolute() ) + Path indexDir = null; + try { - stagingRepository.setIndexDir( stagingRepository.getLocation() + "/.index" ); + indexDir = Paths.get( new URI(repository.getIndexDir().startsWith( "file://" ) ? repository.getIndexDir() : "file://"+repository.getIndexDir()) ); + if ( indexDir.isAbsolute() ) + { + Path newDir = Paths.get(new URI(stagingRepository.getLocation().startsWith( "file://" ) ? stagingRepository.getLocation() : "file://"+stagingRepository.getLocation())).resolve(".index"); + log.debug("Changing index directory {} -> {}", indexDir, newDir); + stagingRepository.setIndexDir( newDir.toString() ); + } + else + { + log.debug("Keeping index directory {}", repository.getIndexDir()); + stagingRepository.setIndexDir( repository.getIndexDir() ); + } } - else + catch ( URISyntaxException e ) { - stagingRepository.setIndexDir( repository.getIndexDir() ); + log.error("Could not parse index path as uri {}", repository.getIndexDir()); + stagingRepository.setIndexDir( "" ); } + // in case of absolute dir do not use the same } stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() ); stagingRepository.setReleases( repository.isReleases() ); @@ -372,7 +421,10 @@ public class MavenRepositoryProvider implements RepositoryProvider } private void setBaseConfig( EditableRepository repo, AbstractRepositoryConfiguration cfg) throws RepositoryException { - final String baseUriStr = archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().getRepositoryBaseDirectory(); + String baseUriStr = archivaConfiguration.getConfiguration().getArchivaRuntimeConfiguration().getRepositoryBaseDirectory(); + if (baseUriStr==null) { + baseUriStr = Paths.get(System.getProperty( "appserver.base" )).resolve("repositories").normalize().toString(); + } try { URI baseUri = new URI(baseUriStr); @@ -383,9 +435,9 @@ public class MavenRepositoryProvider implements RepositoryProvider log.error("Could not set base URI {}: {}", baseUriStr, e.getMessage(), e); throw new RepositoryException( "Could not set base URI "+ baseUriStr); } + repo.setName( repo.getPrimaryLocale(), cfg.getName() ); repo.setDescription( repo.getPrimaryLocale(), cfg.getDescription() ); repo.setLayout( cfg.getLayout() ); - } public ArchivaConfiguration getArchivaConfiguration( ) diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/MockRepoAdmin.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/MockRepoAdmin.java index a0b7e6a15..450cee5ac 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/MockRepoAdmin.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/MockRepoAdmin.java @@ -42,6 +42,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; /** @@ -64,7 +65,7 @@ public class MockRepoAdmin for ( RemoteRepositoryConfiguration repositoryConfiguration : archivaConfiguration.getConfiguration().getRemoteRepositories() ) { RemoteRepository remoteRepository = - new RemoteRepository( repositoryConfiguration.getId(), repositoryConfiguration.getName(), + new RemoteRepository( Locale.getDefault(), repositoryConfiguration.getId(), repositoryConfiguration.getName(), repositoryConfiguration.getUrl(), repositoryConfiguration.getLayout(), repositoryConfiguration.getUsername(), repositoryConfiguration.getPassword(), repositoryConfiguration.getTimeout() ); @@ -153,11 +154,11 @@ public class MockRepoAdmin { if ( StringUtils.equals( repositoryId, repoConfig.getId() ) ) { - return new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), + return new ManagedRepository( Locale.getDefault(), repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(), repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(), repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(), repoConfig.getIndexDir(), repoConfig.isScanned(), - repoConfig.getRetentionTime(), repoConfig.getRetentionCount(), + repoConfig.getRetentionPeriod(), repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), false ); } } @@ -196,6 +197,12 @@ public class MockRepoAdmin } @Override + public IndexingContext createIndexContext( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryAdminException + { + return null; + } + + @Override public List<ProxyConnector> getProxyConnectors() throws RepositoryAdminException { diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java index 20562995c..ce931e30d 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/configuration/TestConfiguration.java @@ -4,6 +4,9 @@ import org.apache.archiva.redback.components.registry.RegistryException; import org.apache.archiva.redback.components.registry.RegistryListener; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Locale; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -77,4 +80,16 @@ public class TestConfiguration { // no op } + + @Override + public Locale getDefaultLocale( ) + { + return Locale.getDefault(); + } + + @Override + public List<Locale.LanguageRange> getLanguagePriorities( ) + { + return Locale.LanguageRange.parse("en,fr,de"); + } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java index f8773c6f8..86749a224 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/ManagedDefaultRepositoryContentTest.java @@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.FileType; @@ -27,8 +26,10 @@ import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; +import org.apache.archiva.repository.EditableManagedRepository; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.junit.Before; import org.junit.Test; @@ -36,7 +37,11 @@ import javax.inject.Inject; import javax.inject.Named; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Set; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -64,7 +69,7 @@ public class ManagedDefaultRepositoryContentTest { Path repoDir = Paths.get( "src/test/repositories/default-repository" ); - ManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir ); + MavenManagedRepository repository = createRepository( "testRepo", "Unit Test Repo", repoDir ); FileType fileType = archivaConfiguration.getConfiguration().getRepositoryScanning().getFileTypes().get( 0 ); fileType.addPattern( "**/*.xml" ); @@ -176,7 +181,7 @@ public class ManagedDefaultRepositoryContentTest // Use the test metadata-repository, which is already setup for // These kind of version tests. Path repoDir = Paths.get( "src/test/repositories/metadata-repository" ); - repoContent.getRepository().setLocation( repoDir.toAbsolutePath().toString() ); + (( EditableManagedRepository)repoContent.getRepository()).setLocation( repoDir.toAbsolutePath().toUri() ); // Request the versions. Set<String> testedVersionSet = repoContent.getVersions( reference ); @@ -201,7 +206,7 @@ public class ManagedDefaultRepositoryContentTest // Use the test metadata-repository, which is already setup for // These kind of version tests. Path repoDir = Paths.get( "src/test/repositories/metadata-repository" ); - repoContent.getRepository().setLocation( repoDir.toAbsolutePath().toString() ); + ((EditableManagedRepository)repoContent.getRepository()).setLocation( repoDir.toAbsolutePath().toUri() ); // Request the versions. Set<String> testedVersionSet = repoContent.getVersions( reference ); diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java index 2145ebc02..da3f4095f 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/RemoteDefaultRepositoryContentTest.java @@ -19,8 +19,8 @@ package org.apache.archiva.metadata.repository.storage.maven2; * under the License. */ -import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.layout.LayoutException; import org.junit.Before; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/conf/MockConfiguration.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/conf/MockConfiguration.java index 51479bbbd..d41cff046 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/conf/MockConfiguration.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/storage/maven2/conf/MockConfiguration.java @@ -29,6 +29,8 @@ import org.easymock.IMocksControl; import org.springframework.stereotype.Service; import java.util.HashSet; +import java.util.List; +import java.util.Locale; import java.util.Set; import static org.easymock.EasyMock.createNiceControl; @@ -121,4 +123,16 @@ public class MockConfiguration { // no op } + + @Override + public Locale getDefaultLocale( ) + { + return Locale.getDefault(); + } + + @Override + public List<Locale.LanguageRange> getLanguagePriorities( ) + { + return Locale.LanguageRange.parse( "en,fr,de" ); + } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java index 02bbf0c31..1a6cf7cf9 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java @@ -21,6 +21,8 @@ package org.apache.archiva.repository; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.admin.model.beans.RemoteRepository; +import org.apache.archiva.repository.maven2.MavenManagedRepository; +import org.apache.archiva.repository.maven2.MavenRemoteRepository; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.Rule; import org.junit.rules.TestName; @@ -29,7 +31,10 @@ import org.springframework.context.ApplicationContext; import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.Path; +import java.util.Locale; /** * AbstractRepositoryLayerTestCase @@ -46,21 +51,17 @@ public abstract class AbstractRepositoryLayerTestCase @Inject protected ApplicationContext applicationContext; - protected ManagedRepository createRepository( String id, String name, Path location ) + protected MavenManagedRepository createRepository( String id, String name, Path location ) { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.toAbsolutePath().toString() ); + MavenManagedRepository repo = new MavenManagedRepository( id, name); + repo.setLocation( location.toAbsolutePath().toUri() ); return repo; } - protected RemoteRepository createRemoteRepository( String id, String name, String url ) + protected MavenRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); + MavenRemoteRepository repo = new MavenRemoteRepository(id, name); + repo.setLocation( new URI( url ) ); return repo; } @@ -68,10 +69,8 @@ public abstract class AbstractRepositoryLayerTestCase String layout ) throws Exception { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.toAbsolutePath().toString() ); + MavenManagedRepository repo = new MavenManagedRepository( id, name ); + repo.setLocation( location.toAbsolutePath().toUri() ); repo.setLayout( layout ); ManagedRepositoryContent repoContent = @@ -84,10 +83,8 @@ public abstract class AbstractRepositoryLayerTestCase protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout ) throws Exception { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); + MavenRemoteRepository repo = new MavenRemoteRepository(id, name); + repo.setLocation( new URI( url ) ); repo.setLayout( layout ); RemoteRepositoryContent repoContent = diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java index ee56ed28e..17068d642 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/maven2/RepositoryRequestTest.java @@ -19,12 +19,12 @@ package org.apache.archiva.repository.content.maven2; * under the License. */ -import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.common.utils.FileUtils; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.commons.lang.StringUtils; import org.junit.Before; @@ -514,10 +514,8 @@ public class RepositoryRequestTest String layout ) throws Exception { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.toAbsolutePath().toString() ); + MavenManagedRepository repo = new MavenManagedRepository( id, name); + repo.setLocation( location.toAbsolutePath().toUri() ); repo.setLayout( layout ); ManagedRepositoryContent repoContent = diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java index a43c39852..54810ce94 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java @@ -20,17 +20,10 @@ package org.apache.archiva.repository.maven2; */ import org.apache.archiva.common.utils.FileUtils; -import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.ArchivaRuntimeConfiguration; -import org.apache.archiva.configuration.Configuration; -import org.apache.archiva.configuration.ConfigurationListener; -import org.apache.archiva.configuration.DefaultArchivaConfiguration; -import org.apache.archiva.configuration.IndeterminateConfigurationException; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.metadata.repository.storage.maven2.conf.MockConfiguration; -import org.apache.archiva.redback.components.registry.RegistryException; -import org.apache.archiva.redback.components.registry.RegistryListener; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.PasswordCredentials; import org.apache.archiva.repository.ReleaseScheme; @@ -41,23 +34,16 @@ import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.RemoteIndexFeature; import org.apache.archiva.repository.features.StagingRepositoryFeature; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.sonatype.aether.util.layout.RepositoryLayout; -import org.springframework.test.context.ContextConfiguration; -import javax.inject.Inject; -import javax.inject.Named; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; import java.time.Duration; import java.time.Period; import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalUnit; import java.util.HashMap; import java.util.Map; @@ -106,7 +92,7 @@ public class MavenRepositoryProviderTest repo.setId("testm001"); repo.setName("Managed Test Repo 001"); repo.setDescription( "This is a managed test" ); - repo.setRetentionTime( 37 ); + repo.setRetentionPeriod( 37 ); repoLocation = Files.createTempDirectory( "test-repo-001"); repo.setLocation( repoLocation.toAbsolutePath().toString() ); repo.setSnapshots( true ); @@ -139,7 +125,7 @@ public class MavenRepositoryProviderTest assertEquals("4 0 0 ? * TUE", mr.getSchedulingDefinition()); assertTrue(mr.isScanned()); ArtifactCleanupFeature artifactCleanupFeature = mr.getFeature( ArtifactCleanupFeature.class ).get(); - assertEquals( Period.ofDays( 37), artifactCleanupFeature.getRetentionTime()); + assertEquals( Period.ofDays( 37), artifactCleanupFeature.getRetentionPeriod()); assertTrue(artifactCleanupFeature.isDeleteReleasedSnapshots()); assertEquals(33, artifactCleanupFeature.getRetentionCount()); @@ -229,7 +215,7 @@ public class MavenRepositoryProviderTest public void getManagedConfiguration() throws Exception { MavenManagedRepository repo = new MavenManagedRepository( "test01", "My Test repo" ); - repo.setLocation( new URI("https://this.is/a/test") ); + repo.setLocation( new URI("file:///this.is/a/test") ); repo.setScanned( true ); repo.setDescription( repo.getPrimaryLocale(), "This is a description" ); repo.setLayout( "maven2" ); @@ -244,12 +230,12 @@ public class MavenRepositoryProviderTest indexCreationFeature.setIndexPath( new URI("test/.indexes") ); indexCreationFeature.setSkipPackedIndexCreation( true ); ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature( ArtifactCleanupFeature.class ).get(); - artifactCleanupFeature.setRetentionTime( Period.ofDays( 5 ) ); + artifactCleanupFeature.setRetentionPeriod( Period.ofDays( 5 ) ); artifactCleanupFeature.setRetentionCount( 7 ); artifactCleanupFeature.setDeleteReleasedSnapshots( true ); ManagedRepositoryConfiguration cfg = provider.getManagedConfiguration( repo ); - assertEquals("https://this.is/a/test", cfg.getLocation()); + assertEquals("/this.is/a/test", cfg.getLocation()); assertTrue(cfg.isScanned()); assertEquals( "This is a description", cfg.getDescription() ); assertEquals("maven2", cfg.getLayout()); @@ -259,7 +245,7 @@ public class MavenRepositoryProviderTest assertTrue(cfg.isStageRepoNeeded()); assertEquals("test/.indexes", cfg.getIndexDir()); assertTrue(cfg.isSkipPackedIndexCreation()); - assertEquals(5, cfg.getRetentionTime()); + assertEquals(5, cfg.getRetentionPeriod()); assertEquals(7, cfg.getRetentionCount()); assertTrue(cfg.isDeleteReleasedSnapshots()); assertTrue(cfg.isReleases()); diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java index ee52f5f65..92ea54ebf 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java @@ -21,6 +21,7 @@ package org.apache.archiva.repository.metadata; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.metadata.repository.storage.RepositoryStorage; +import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.junit.Assert; import org.junit.Test; @@ -29,6 +30,7 @@ import org.springframework.test.context.ContextConfiguration; import javax.inject.Inject; import javax.inject.Named; +import java.util.Locale; /** * @author Olivier Lamy @@ -46,17 +48,17 @@ public class Maven2RepositoryStorageTest { String href = "/repository/internal/org/apache/maven/someartifact.jar"; Assert.assertEquals( "/org/apache/maven/someartifact.jar", - repositoryStorage.getFilePath( href, new ManagedRepository() ) ); + repositoryStorage.getFilePath( href, new MavenManagedRepository( "repo01", "repo01") ) ); href = "repository/internal/org/apache/maven/someartifact.jar"; Assert.assertEquals( "/org/apache/maven/someartifact.jar", - repositoryStorage.getFilePath( href, new ManagedRepository() ) ); + repositoryStorage.getFilePath( href, new MavenManagedRepository( "repo01", "repo01" ) ) ); href = "repository/internal/org/apache/maven/"; - Assert.assertEquals( "/org/apache/maven/", repositoryStorage.getFilePath( href, new ManagedRepository() ) ); + Assert.assertEquals( "/org/apache/maven/", repositoryStorage.getFilePath( href, new MavenManagedRepository("repo01", "repo01") ) ); href = "mypath"; - Assert.assertEquals( "/", repositoryStorage.getFilePath( href, new ManagedRepository() ) ); + Assert.assertEquals( "/", repositoryStorage.getFilePath( href, new MavenManagedRepository("repo01", "repo01") ) ); } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java index a258108dd..45164862e 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/metadata/MetadataToolsTest.java @@ -33,6 +33,7 @@ import org.apache.archiva.repository.AbstractRepositoryLayerTestCase; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.layout.LayoutException; +import org.apache.archiva.repository.maven2.MavenManagedRepository; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.custommonkey.xmlunit.DetailedDiff; @@ -362,7 +363,7 @@ public class MetadataToolsTest reference.setArtifactId( artifactId ); reference.setVersion( version ); - ManagedRepository repo = + MavenManagedRepository repo = createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRootDir ); ManagedRepositoryContent repoContent = applicationContext.getBean( "managedRepositoryContent#default", ManagedRepositoryContent.class ); @@ -614,7 +615,7 @@ public class MetadataToolsTest Files.createDirectories(repoRoot); - ManagedRepository repoConfig = + MavenManagedRepository repoConfig = createRepository( "test-repo", "Test Repository: " + name.getMethodName(), repoRoot ); ManagedRepositoryContent repoContent = diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml index f4d78908d..8b00cdcdf 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-no-mock-conf.xml @@ -27,6 +27,10 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.metadata.repository.storage.maven2.conf"/> + <context:component-scan base-package="org.apache.archiva.metadata.repository.storage.maven2.conf,org.apache.archiva.repository.content.maven2"/> + + <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" /> + <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" /> + </beans>
\ No newline at end of file diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-repo-request-test.xml b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-repo-request-test.xml index b8ebc8319..1601f2ae4 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-repo-request-test.xml +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context-repo-request-test.xml @@ -27,6 +27,7 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:property-placeholder system-properties-mode="OVERRIDE"/> + <context:component-scan base-package="org.apache.archiva.repository.content.maven2" /> <bean name="archivaConfiguration#repo-request-test" class="org.apache.archiva.configuration.DefaultArchivaConfiguration"> <property name="registry" ref="registry#configured"/> </bean> @@ -34,6 +35,10 @@ <alias name="archivaConfiguration#repo-request-test" alias="archivaConfiguration#default"/> <alias name="archivaConfiguration#repo-request-test" alias="archivaConfiguration"/> + <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" /> + <alias name="remoteRepositoryContent#maven" alias="remoteRepositoryContent#default" /> + + <bean name="registry#configured" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"> <property name="properties"> <value> diff --git a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context.xml b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context.xml index ee8e343cc..5f445d75a 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context.xml +++ b/archiva-modules/plugins/maven2-repository/src/test/resources/spring-context.xml @@ -28,9 +28,12 @@ default-lazy-init="true"> <context:annotation-config/> - <context:component-scan base-package="org.apache.archiva.configuration,org.apache.archiva.metadata.repository"/> + <context:component-scan base-package="org.apache.archiva.configuration,org.apache.archiva.metadata.repository,org.apache.archiva.repository.content.maven2"/> + + <alias name="archivaConfiguration#test" alias="archivaConfiguration#default"/> <alias name="archivaConfiguration#test" alias="archivaConfiguration"/> + <alias name="managedRepositoryContent#maven" alias="managedRepositoryContent#default" /> <alias name="metadataResolver#test" alias="metadataResolver#default"/> </beans>
\ No newline at end of file |