From: Martin Stockhammer Date: Tue, 2 Jun 2020 11:37:35 +0000 (+0200) Subject: Separating content and layout interfaces X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=da89fe394cbaa66f200872dbd1a8172483cdeeb8;p=archiva.git Separating content and layout interfaces --- diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java index bf2faa947..f1a219b14 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/main/java/SimpleArtifactConsumer.java @@ -126,7 +126,7 @@ public class SimpleArtifactConsumer { ManagedRepositoryContent repositoryContent = repository.getContent(); BaseRepositoryContentLayout layout = repositoryContent.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = repositoryContent.toArtifactReference( path ); repositorySession.getRepository().getArtifacts( repositorySession, repository.getId(), artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java index f7f9ef730..3cd973e6b 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/MetadataUpdaterConsumer.java @@ -174,7 +174,7 @@ public class MetadataUpdaterConsumer { try { - ArtifactReference artifact = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ); + ArtifactReference artifact = repository.toArtifactReference( path ); updateVersionMetadata( artifact, path ); updateProjectMetadata( artifact, path ); } diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java index 5142ed94c..069730689 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java @@ -100,7 +100,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge return; } - ArtifactReference artifactRef = repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ); + ArtifactReference artifactRef = repository.toArtifactReference( path ); if ( !VersionUtil.isSnapshot( artifactRef.getVersion( ) ) ) { diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java index e08ed3cb3..c71d757eb 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java @@ -43,7 +43,7 @@ import java.util.stream.Stream; * * */ -public interface BaseRepositoryContentLayout extends RepositoryContent, ManagedRepositoryContent, ManagedRepositoryContentLayout +public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLayout { /// ***************** New generation interface ********************** diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java index 317f19abe..fe964b945 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/base/ArtifactUtil.java @@ -55,14 +55,7 @@ public class ArtifactUtil { final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository ); final String artifactPath; - try - { - artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference ); - } - catch ( LayoutException e ) - { - throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" ); - } + artifactPath = content.toPath( artifactReference ); return Paths.get( repository.getLocation( ) ).resolve( artifactPath ); } @@ -79,14 +72,7 @@ public class ArtifactUtil { final ManagedRepositoryContent content = repositoryContentFactory.getManagedRepositoryContent( repository ); final String artifactPath; - try - { - artifactPath = content.getLayout( BaseRepositoryContentLayout.class ).toPath( artifactReference ); - } - catch ( LayoutException e ) - { - throw new RepositoryException( "Could not convert to layout BaseRepositoryContentLayout" ); - } + artifactPath = content.toPath( artifactReference ); return repository.getAsset( artifactPath ); } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/base/MetadataTools.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/base/MetadataTools.java index f7ddd36f9..a31554bb1 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/base/MetadataTools.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/base/MetadataTools.java @@ -956,7 +956,7 @@ public class MetadataTools PathUtil.getRelative( managedRepository.getRepoRoot(), path1 ) ).filter( filetypes::matchesArtifactPattern ).findFirst().orElse( null ); if (result!=null) { - return managedRepository.toArtifactReference( result ); + return managedRepository.getGenericContent().toArtifactReference( result ); } } // No artifact was found. diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java index bc4569aac..435e889e0 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java @@ -57,7 +57,7 @@ import java.util.stream.Stream; * @author Martin Stockhammer */ @Service("managedRepositoryContent#mock") -public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout +public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent { private ManagedRepository repository; diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java index 5c9b818e0..710bad50f 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java @@ -21,6 +21,7 @@ package org.apache.archiva.repository.mock; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.BaseRepositoryContentLayout; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.Repository; @@ -63,7 +64,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider } @Override - public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException { + public ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException { return new ManagedRepositoryContentMock(); } diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java index 89f516927..16a6adcf4 100644 --- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java +++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java @@ -57,7 +57,7 @@ import java.util.stream.Stream; /** * @author Martin Stockhammer */ -public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout +public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout, ManagedRepositoryContent { private static final String PATH_SEPARATOR = "/"; private static final String GROUP_SEPARATOR = "."; diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java index 15b175529..5afb561e3 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/CacheFailuresTransferTest.java @@ -64,7 +64,7 @@ public class CacheFailuresTransferTest assertNotExistsInManagedDefaultRepo( expectedFile ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Repository (usually done within archiva.xml configuration) saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" ); @@ -109,7 +109,7 @@ public class CacheFailuresTransferTest assertNotExistsInManagedDefaultRepo( expectedFile ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Repository (usually done within archiva.xml configuration) saveRemoteRepositoryConfig( "badproxied1", "Bad Proxied 1", "http://bad.machine.com/repo/", "default" ); @@ -155,7 +155,7 @@ public class CacheFailuresTransferTest setupTestableManagedRepository( path ); Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); Files.deleteIfExists( expectedFile ); assertFalse( Files.exists( expectedFile ) ); diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java index 8f3664c10..8a32ac08d 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ChecksumTransferTest.java @@ -56,7 +56,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -79,7 +79,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -106,7 +106,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -133,7 +133,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -159,7 +159,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -185,7 +185,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -211,7 +211,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -235,7 +235,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -262,7 +262,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -286,7 +286,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -313,7 +313,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -337,7 +337,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -364,7 +364,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -392,7 +392,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -419,7 +419,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile ) ); @@ -446,7 +446,7 @@ public class ChecksumTransferTest Path expectedFile = managedDefaultDir.resolve( path ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); FileUtils.deleteDirectory( expectedFile.getParent( ) ); assertFalse( Files.exists( expectedFile.getParent( ) ) ); @@ -501,7 +501,7 @@ public class ChecksumTransferTest setManagedOlderThanRemote( expectedFile, remoteFile ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.IGNORE, ReleasesPolicy.ALWAYS, @@ -529,7 +529,7 @@ public class ChecksumTransferTest setManagedOlderThanRemote( expectedFile, remoteFile ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, ChecksumPolicy.FAIL, ReleasesPolicy.ALWAYS, @@ -558,7 +558,7 @@ public class ChecksumTransferTest setManagedOlderThanRemote( expectedFile, remoteFile ); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, "proxied1", ChecksumPolicy.FIX, ReleasesPolicy.ALWAYS, diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java index 37eca4e75..baccc1717 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ErrorHandlingTest.java @@ -599,7 +599,7 @@ public class ErrorHandlingTest { BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), - layout.toArtifactReference( path ) ); + managedDefaultRepository.toArtifactReference( path ) ); fail( "Proxy should not have succeeded" ); } catch ( ProxyDownloadException e ) @@ -642,7 +642,7 @@ public class ErrorHandlingTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), - layout.toArtifactReference( path ) ); + managedDefaultRepository.toArtifactReference( path ) ); wagonMockControl.verify(); return downloadedFile; diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java index 9558a5c01..2a028ab59 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java @@ -222,7 +222,7 @@ public class HttpProxyTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); Path expectedFile = managedDefaultRepository.getRepository().getAsset( "" ).resolve( path ).getFilePath(); Files.deleteIfExists( expectedFile ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Attempt the proxy fetch. StorageAsset downloadedFile = proxyHandler.fetchFromProxies( managedDefaultRepository.getRepository(), artifact ); diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java index 84be7896e..a4025894b 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/ManagedDefaultTransferTest.java @@ -59,7 +59,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Ensure file isn't present first. assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -84,7 +84,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Ensure file isn't present first. assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -147,7 +147,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); @@ -230,7 +230,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); @@ -277,7 +277,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); @@ -311,7 +311,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); Files.setLastModifiedTime( expectedFile, FileTime.from(getPastDate().getTime(), TimeUnit.MILLISECONDS )); @@ -339,7 +339,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -373,7 +373,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -400,7 +400,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -427,7 +427,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertNotExistsInManagedDefaultRepo( expectedFile ); @@ -464,7 +464,7 @@ public class ManagedDefaultTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertNotExistsInManagedDefaultRepo( expectedFile ); diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/SnapshotTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/SnapshotTransferTest.java index 5b720a8b9..e15bbfb1d 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/SnapshotTransferTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/SnapshotTransferTest.java @@ -54,7 +54,7 @@ public class SnapshotTransferTest Path expectedFile = managedDefaultDir.resolve(path); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); Files.deleteIfExists(expectedFile); assertFalse( Files.exists(expectedFile) ); @@ -77,7 +77,7 @@ public class SnapshotTransferTest Path expectedFile = managedDefaultDir.resolve(path); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); Files.deleteIfExists(expectedFile); assertFalse( Files.exists(expectedFile) ); @@ -102,7 +102,7 @@ public class SnapshotTransferTest Path expectedFile = managedDefaultDir.resolve(path); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); Files.setLastModifiedTime( expectedFile, FileTime.from( getPastDate().getTime(), TimeUnit.MILLISECONDS )); @@ -131,7 +131,7 @@ public class SnapshotTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false ); @@ -220,7 +220,7 @@ public class SnapshotTransferTest Path expectedFile = managedDefaultDir.resolve(path); BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); @@ -251,7 +251,7 @@ public class SnapshotTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); // Configure Connector (usually done within archiva.xml configuration) saveConnector( ID_DEFAULT_MANAGED, ID_PROXIED1, false); @@ -274,7 +274,7 @@ public class SnapshotTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); Files.deleteIfExists(expectedFile); assertFalse( Files.exists(expectedFile) ); @@ -303,7 +303,7 @@ public class SnapshotTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); Files.deleteIfExists(expectedFile); assertFalse( Files.exists(expectedFile) ); @@ -332,7 +332,7 @@ public class SnapshotTransferTest BaseRepositoryContentLayout layout = managedDefaultRepository.getLayout( BaseRepositoryContentLayout.class ); - ArtifactReference artifact = layout.toArtifactReference( path ); + ArtifactReference artifact = managedDefaultRepository.toArtifactReference( path ); assertTrue( Files.exists(expectedFile) ); diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java index b4d6c52a4..a84fb1a48 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryContentProviderMock.java @@ -55,7 +55,7 @@ public class RepositoryContentProviderMock implements RepositoryContentProvider } @Override - public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository) throws RepositoryException { + public ManagedRepositoryContent createManagedContent( ManagedRepository repository) throws RepositoryException { return new ManagedRepositoryContentMock(repository); } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java index ab311ee36..5906c5695 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java @@ -84,7 +84,7 @@ import java.util.stream.Stream; */ public class ManagedDefaultRepositoryContent extends AbstractDefaultRepositoryContent - implements BaseRepositoryContentLayout + implements ManagedRepositoryContent, BaseRepositoryContentLayout { // attribute flag that marks version objects that point to a snapshot artifact version diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenContentProvider.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenContentProvider.java index 95bb042f4..39ebc2b3c 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenContentProvider.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenContentProvider.java @@ -20,6 +20,7 @@ package org.apache.archiva.repository.maven.content; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.configuration.FileTypes; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.BaseRepositoryContentLayout; @@ -98,7 +99,7 @@ public class MavenContentProvider implements RepositoryContentProvider } @Override - public BaseRepositoryContentLayout createManagedContent( ManagedRepository repository ) throws RepositoryException + public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException { if (!supports( repository.getType() )) { throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." ); diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenRepositoryRequestInfo.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenRepositoryRequestInfo.java index f033a490e..08afdcfbe 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenRepositoryRequestInfo.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/MavenRepositoryRequestInfo.java @@ -280,7 +280,7 @@ public class MavenRepositoryRequestInfo implements RepositoryRequestInfo // Treat as an artifact reference. ArtifactReference ref = toArtifactReference( referencedResource ); - String adjustedPath = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( ref ); + String adjustedPath = repository.getContent().toPath( ref ); return adjustedPath + supportfile; } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractBaseRepositoryContentLayoutTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractBaseRepositoryContentLayoutTest.java index bead9c8f2..1aad28715 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractBaseRepositoryContentLayoutTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractBaseRepositoryContentLayoutTest.java @@ -18,6 +18,7 @@ package org.apache.archiva.repository.maven.content; * under the License. */ +import org.apache.archiva.repository.BaseRepositoryContentLayout; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.content.ItemSelector; import org.apache.archiva.repository.content.base.ArchivaItemSelector; @@ -50,10 +51,11 @@ public abstract class AbstractBaseRepositoryContentLayoutTest extends AbstractRe } @Test - public void testGetArtifactOnEmptyPath() { + public void testGetArtifactOnEmptyPath() throws LayoutException + { ItemSelector selector = ArchivaItemSelector.builder( ).build( ); try { - getManaged( ).getArtifact( selector ); + getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getArtifact( selector ); fail( "getArtifact(ItemSelector) with empty selector should throw IllegalArgumentException" ); } catch (IllegalArgumentException e) { // Good diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractRepositoryContentTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractRepositoryContentTest.java index 94e10faae..f1a6444e4 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractRepositoryContentTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/AbstractRepositoryContentTest.java @@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven.content; */ import org.apache.archiva.model.ArtifactReference; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RepositoryContent; import org.apache.archiva.repository.maven.AbstractRepositoryLayerTestCase; import org.apache.archiva.repository.LayoutException; @@ -581,25 +582,25 @@ public abstract class AbstractRepositoryContentTest Version ver = null; if ( StringUtils.isNotEmpty( groupId ) ) { - ns = getManaged( ).getNamespace( expectedArtifact ); + ns = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getNamespace( expectedArtifact ); assertNotNull( ns ); assertEquals( groupId, ns.getNamespace( ) ); } if ( StringUtils.isNotEmpty( artifactId ) ) { - pr = getManaged( ).getProject( expectedArtifact ); + pr = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getProject( expectedArtifact ); assertNotNull( pr ); assertEquals( artifactId, pr.getId( ) ); assertEquals( ns, pr.getNamespace( ) ); } if ( StringUtils.isNotEmpty( version ) ) { - ver = getManaged( ).getVersion( expectedArtifact ); + ver = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getVersion( expectedArtifact ); assertNotNull( ver ); assertEquals( version, ver.getVersion( ) ); assertEquals( pr, ver.getProject( ) ); } - Artifact artifact = getManaged( ).getArtifact( expectedArtifact ); + Artifact artifact = getManaged( ).getLayout( BaseRepositoryContentLayout.class ).getArtifact( expectedArtifact ); assertNotNull( artifact ); assertEquals( artifactId, artifact.getId( ) ); assertEquals( ver, artifact.getVersion( ) ); @@ -642,7 +643,7 @@ public abstract class AbstractRepositoryContentTest protected abstract ItemSelector toItemSelector(String path) throws LayoutException; - protected abstract BaseRepositoryContentLayout getManaged(); + protected abstract ManagedRepositoryContent getManaged(); protected abstract RepositoryContent getContent( ); } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java index f465df107..e4728f2aa 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java @@ -410,7 +410,7 @@ public class ManagedDefaultRepositoryContentTest } @Override - protected BaseRepositoryContentLayout getManaged( ) + protected ManagedRepositoryContent getManaged( ) { return repoContent; } diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/RemoteDefaultRepositoryContentTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/RemoteDefaultRepositoryContentTest.java index 94d0cdb1d..25d414b53 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/RemoteDefaultRepositoryContentTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/RemoteDefaultRepositoryContentTest.java @@ -21,6 +21,7 @@ package org.apache.archiva.repository.maven.content; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.repository.LayoutException; import org.apache.archiva.repository.BaseRepositoryContentLayout; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.RemoteRepository; import org.apache.archiva.repository.RemoteRepositoryContent; import org.apache.archiva.repository.RepositoryContent; @@ -69,7 +70,7 @@ public class RemoteDefaultRepositoryContentTest } @Override - protected BaseRepositoryContentLayout getManaged( ) + protected ManagedRepositoryContent getManaged( ) { return null; } diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java index 424063537..7d9cd369a 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/TestConsumer.java @@ -98,7 +98,7 @@ public class TestConsumer { try { - consumed.add( repository.getLayout( BaseRepositoryContentLayout.class ).toArtifactReference( path ) ); + consumed.add( repository.toArtifactReference( path ) ); } catch ( LayoutException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index 1eca75d14..cfb5dfc30 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -375,7 +375,7 @@ public class DefaultRepositoriesService ManagedRepositoryContent sourceRepository = getManagedRepositoryContent( artifactTransferRequest.getRepositoryId() ); BaseRepositoryContentLayout layout = sourceRepository.getLayout( BaseRepositoryContentLayout.class ); - String artifactSourcePath = layout.toPath( artifactReference ); + String artifactSourcePath = sourceRepository.toPath( artifactReference ); if ( StringUtils.isEmpty( artifactSourcePath ) ) { @@ -396,7 +396,7 @@ public class DefaultRepositoriesService ManagedRepositoryContent targetRepository = getManagedRepositoryContent( artifactTransferRequest.getTargetRepositoryId() ); - String artifactPath = layout.toPath( artifactReference ); + String artifactPath = sourceRepository.toPath( artifactReference ); int lastIndex = artifactPath.lastIndexOf( '/' ); @@ -777,7 +777,7 @@ public class DefaultRepositoriesService .withVersion( artifact.getVersion( ) ).build( ); Version version1 = layout.getVersion( versionSelector ); - String path = layout.toPath( version1 ); + String path = repository.toPath( version1 ); ArtifactReference artifactReference = new ArtifactReference(); artifactReference.setArtifactId( artifact.getArtifactId() ); @@ -839,7 +839,7 @@ public class DefaultRepositoriesService { try { - layout.deleteItem( version1 ); + repository.deleteItem( version1 ); } catch ( ItemNotFoundException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java index b449d3abb..b6fee0864 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactBuilder.java @@ -100,7 +100,7 @@ public class ArtifactBuilder artifact.setPackaging( type ); artifact.setType( type ); artifact.setFileExtension( extension ); - artifact.setPath( layout.toPath( ref ) ); + artifact.setPath( managedRepositoryContent.toPath( ref ) ); // TODO: find a reusable formatter for this double s = this.artifactMetadata.getSize(); String symbol = "b"; diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 588a24da3..f10286339 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -651,7 +651,7 @@ public class ArchivaDavResourceFactory try { BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class ); - artifact = layout.toArtifactReference( resourcePath ); + artifact = managedRepositoryContent.toArtifactReference( resourcePath ); if ( !VersionUtil.isSnapshot( artifact.getVersion() ) ) { @@ -800,7 +800,7 @@ public class ArchivaDavResourceFactory StorageAsset proxiedFile = proxyHandler.fetchFromProxies( managedRepository, artifact ); - resource.setPath( managedRepository.getContent().getLayout( BaseRepositoryContentLayout.class ).toPath( artifact ) ); + resource.setPath( managedRepository.getContent().toPath( artifact ) ); log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java index e133d2fb3..c4d9c1b46 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java @@ -34,6 +34,7 @@ import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.configuration.RepositoryGroupConfiguration; +import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; import org.apache.archiva.proxy.ProxyRegistry; import org.apache.archiva.repository.EditableManagedRepository; @@ -250,11 +251,11 @@ public class ArchivaDavResourceFactoryTest return repoConfig; } - private BaseRepositoryContentLayout createManagedRepositoryContent( String repoId ) + private ManagedRepositoryContent createManagedRepositoryContent( String repoId ) throws RepositoryAdminException { org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository( repoId ); - BaseRepositoryContentLayout repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager); + ManagedRepositoryContent repoContent = new ManagedDefaultRepositoryContent(repo, artifactMappingProviders, fileTypes, fileLockManager); if (repo!=null && repo instanceof EditableManagedRepository) { ( (EditableManagedRepository) repo ).setContent( repoContent ); @@ -262,7 +263,7 @@ public class ArchivaDavResourceFactoryTest return repoContent; } - private RepositoryContentProvider createRepositoryContentProvider( BaseRepositoryContentLayout content) { + private RepositoryContentProvider createRepositoryContentProvider( ManagedRepositoryContent content) { Set TYPES = new HashSet<>( ); TYPES.add(RepositoryType.MAVEN); return new RepositoryContentProvider( ) @@ -294,7 +295,7 @@ public class ArchivaDavResourceFactoryTest } @Override - public BaseRepositoryContentLayout createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException + public ManagedRepositoryContent createManagedContent( org.apache.archiva.repository.ManagedRepository repository ) throws RepositoryException { content.setRepository( repository ); return content; @@ -330,8 +331,8 @@ public class ArchivaDavResourceFactoryTest + "/org/apache/archiva/archiva/1.2-SNAPSHOT/archiva-1.2-SNAPSHOT.jar", LOCAL_REPO_GROUP, new ArchivaDavLocatorFactory() ); - BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); - BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO ); + ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); + ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO ); try { @@ -407,9 +408,9 @@ public class ArchivaDavResourceFactoryTest config.setRepositoryGroups( repoGroups ); - BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); + ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); - BaseRepositoryContentLayout releasesRepo = createManagedRepositoryContent( RELEASES_REPO ); + ManagedRepositoryContent releasesRepo = createManagedRepositoryContent( RELEASES_REPO ); try { @@ -490,8 +491,8 @@ public class ArchivaDavResourceFactoryTest config.setRepositoryGroups( repoGroups ); - BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); - BaseRepositoryContentLayout localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO ); + ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); + ManagedRepositoryContent localMirrorRepo = createManagedRepositoryContent( LOCAL_MIRROR_REPO ); repositoryRegistry.putRepositoryGroup( repoGroup ); @@ -565,7 +566,7 @@ public class ArchivaDavResourceFactoryTest new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/jdtcore/maven-metadata.xml", INTERNAL_REPO, new ArchivaDavLocatorFactory() ); - BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); + ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); // use actual object (this performs the isMetadata, isDefault and isSupportFile check!) MavenRepositoryRequestInfo repoRequest = new MavenRepositoryRequestInfo(internalRepo.getRepository() ); @@ -622,7 +623,7 @@ public class ArchivaDavResourceFactoryTest new ArchivaDavResourceLocator( "", "/repository/" + INTERNAL_REPO + "/eclipse/maven-metadata.xml", INTERNAL_REPO, new ArchivaDavLocatorFactory() ); - BaseRepositoryContentLayout internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); + ManagedRepositoryContent internalRepo = createManagedRepositoryContent( INTERNAL_REPO ); try { @@ -662,7 +663,7 @@ public class ArchivaDavResourceFactoryTest public void testRequestMetadataRepoIsLegacy() throws Exception { - BaseRepositoryContentLayout legacyRepo = createManagedRepositoryContent( LEGACY_REPO ); + ManagedRepositoryContent legacyRepo = createManagedRepositoryContent( LEGACY_REPO ); ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) applicationContext).getBeanFactory(); RepositoryContentProvider provider = createRepositoryContentProvider(legacyRepo ); beanFactory.registerSingleton("repositoryContentProvider#legacy", provider);