From cb0e5f8eeab97320617eeb026be5e47d0ab50af8 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Wed, 3 Jun 2020 16:03:29 +0200 Subject: [PATCH] Removing method from repository layout --- .../repository/BaseRepositoryContentLayout.java | 13 ------------- .../repository/metadata/base/MetadataTools.java | 15 ++++++++------- .../mock/ManagedRepositoryContentMock.java | 6 ------ .../mock/ManagedRepositoryContentMock.java | 6 ------ .../mock/ManagedRepositoryContentMock.java | 6 ------ .../content/ManagedDefaultRepositoryContent.java | 6 ------ .../tree/Maven3DependencyTreeBuilder.java | 9 +-------- 7 files changed, 9 insertions(+), 52 deletions(-) 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 3cb7b153c..71562b127 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 @@ -270,17 +270,4 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay /// ***************** End of new generation interface ********************** - /** - *

- * Convenience method to get the repository (on disk) root directory. - *

- *

- * Equivalent to calling .getRepository().getLocation() - *

- * - * @return the repository (on disk) root directory. - */ - String getRepoRoot(); - - } 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 a31554bb1..a9eebef59 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 @@ -937,23 +937,24 @@ public class MetadataTools path = path.substring( 0, idx ); } - Path repoDir = Paths.get( managedRepository.getRepoRoot(), path ); + StorageAsset repoDir = managedRepository.getGenericContent( ).getRepository( ).getAsset( "" ); - if ( !Files.exists(repoDir)) + if ( !repoDir.exists()) { throw new IOException( "Unable to gather the list of snapshot versions on a non-existant directory: " - + repoDir.toAbsolutePath() ); + + repoDir.toString() ); } - if ( !Files.isDirectory( repoDir )) + if ( !repoDir.isContainer()) { throw new IOException( - "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.toAbsolutePath() ); + "Unable to gather the list of snapshot versions on a non-directory: " + repoDir.toString() ); } - try(Stream stream = Files.list(repoDir)) { + Path repoRoot = repoDir.getFilePath( ); + try(Stream stream = Files.list(repoRoot)) { String result = stream.filter( Files::isRegularFile ).map( path1 -> - PathUtil.getRelative( managedRepository.getRepoRoot(), path1 ) + repoRoot.relativize( path1 ).toString() ).filter( filetypes::matchesArtifactPattern ).findFirst().orElse( null ); if (result!=null) { return managedRepository.getGenericContent().toArtifactReference( result ); 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 60e8fd35f..69af3d37f 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 @@ -303,12 +303,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout return null; } - @Override - public String getRepoRoot( ) - { - return null; - } - @Override public ManagedRepository getRepository( ) { 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 ecc6430eb..06e9680e2 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 @@ -305,12 +305,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout return repository.getId(); } - @Override - public String getRepoRoot( ) - { - return getRepoRootAsset().getFilePath().toString(); - } - private StorageAsset getRepoRootAsset() { if (fsStorage==null) { try { diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java index 63a037277..831b2c6c0 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java @@ -326,12 +326,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout return repository.getId(); } - @Override - public String getRepoRoot( ) - { - return getRepoRootAsset().getFilePath().toString(); - } - private StorageAsset getRepoRootAsset() { if (fsStorage==null) { try { 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 f63d83a76..6349618df 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 @@ -1374,12 +1374,6 @@ public class ManagedDefaultRepositoryContent } - @Override - public String getRepoRoot( ) - { - return convertUriToPath( repository.getLocation( ) ); - } - private String convertUriToPath( URI uri ) { if ( uri.getScheme( ) == null ) diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java index b7dbc0974..d8d0a0c3c 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/dependency/tree/Maven3DependencyTreeBuilder.java @@ -159,14 +159,7 @@ public class Maven3DependencyTreeBuilder // FIXME take care of relative path ResolveRequest resolveRequest = new ResolveRequest(); resolveRequest.dependencyVisitor = dependencyVisitor; - try - { - resolveRequest.localRepoDir = repository.getContent().getLayout( BaseRepositoryContentLayout.class ).getRepoRoot(); - } - catch ( LayoutException e ) - { - throw new DependencyTreeBuilderException( "Could not convert to layout " + e.getMessage( ), e ); - } + resolveRequest.localRepoDir = repository.getAsset( "" ).getFilePath().toAbsolutePath().toString(); resolveRequest.groupId = groupId; resolveRequest.artifactId = artifactId; resolveRequest.version = version; -- 2.39.5