diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-03-29 19:12:30 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-03-29 19:12:30 +0200 |
commit | b55ac5e29f81d58971c714e561ed6e4423f829b0 (patch) | |
tree | 3979566f569d2e2fb9428b4bec221544a2bd09ab /archiva-modules/archiva-maven | |
parent | ff7a10213879a19956ff036e1dbf7554814c2a89 (diff) | |
download | archiva-b55ac5e29f81d58971c714e561ed6e4423f829b0.tar.gz archiva-b55ac5e29f81d58971c714e561ed6e4423f829b0.zip |
Moving first client calls to new content repo API
Diffstat (limited to 'archiva-modules/archiva-maven')
3 files changed, 1 insertions, 148 deletions
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 81d240eea..f5036797b 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 @@ -287,12 +287,6 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent } @Override - public Set<String> getVersions( ProjectReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException - { - return null; - } - - @Override public Set<String> getVersions( VersionedReference reference ) throws ContentNotFoundException, ContentAccessException, LayoutException { return null; @@ -305,12 +299,6 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent } @Override - public boolean hasContent( ProjectReference reference ) throws ContentAccessException - { - return false; - } - - @Override public boolean hasContent( VersionedReference reference ) throws ContentAccessException { return false; 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 b79753cc7..9a02dce94 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 @@ -173,7 +173,7 @@ public class ManagedDefaultRepositoryContent } - /// ************* End of new generation interface ****************** + /// ************* Start of new generation interface ****************** /** * Removes the item from the filesystem. For namespaces, projects and versions it deletes @@ -1245,59 +1245,6 @@ public class ManagedDefaultRepositoryContent return repository; } - /** - * Gather the Available Versions (on disk) for a specific Project Reference, based on filesystem - * information. - * - * @return the Set of available versions, based on the project reference. - * @throws LayoutException - */ - @Override - public Set<String> getVersions( ProjectReference reference ) - throws ContentNotFoundException, LayoutException, ContentAccessException - { - final String path = toPath( reference ); - final Path projDir = getRepoDir().resolve(toPath(reference)); - if ( !Files.exists(projDir) ) - { - throw new ContentNotFoundException( - "Unable to get Versions on a non-existant directory for repository "+getId()+": " + path ); - } - - if ( !Files.isDirectory(projDir) ) - { - throw new ContentNotFoundException( - "Unable to get Versions on a non-directory for repository "+getId()+": " + path ); - } - - final String groupId = reference.getGroupId(); - final String artifactId = reference.getArtifactId(); - try(Stream<Path> stream = Files.list(projDir)) { - return stream.filter(Files::isDirectory).map( - p -> toVersion(groupId, artifactId, p.getFileName().toString()) - ).filter(this::hasArtifact).map(ref -> ref.getVersion()) - .collect(Collectors.toSet()); - } catch (IOException e) { - log.error("Could not read directory {}: {}", projDir, e.getMessage(), e); - throw new ContentAccessException( "Could not read path for repository "+getId()+": "+ path, e ); - } catch (RuntimeException e) { - Throwable cause = e.getCause( ); - if (cause!=null) - { - if ( cause instanceof LayoutException ) - { - throw (LayoutException) cause; - } else { - log.error("Could not read directory {}: {}", projDir, cause.getMessage(), cause); - throw new ContentAccessException( "Could not read path for repository "+getId()+": "+ path, cause ); - } - } else { - log.error("Could not read directory {}: {}", projDir, e.getMessage(), e); - throw new ContentAccessException( "Could not read path for repository "+getId()+": "+ path, cause ); - } - } - } - @Override public Set<String> getVersions( VersionedReference reference ) throws ContentNotFoundException, ContentAccessException, LayoutException @@ -1322,20 +1269,6 @@ public class ManagedDefaultRepositoryContent } @Override - public boolean hasContent( ProjectReference reference ) throws ContentAccessException - { - try - { - Set<String> versions = getVersions( reference ); - return !versions.isEmpty(); - } - catch ( ContentNotFoundException | LayoutException e ) - { - return false; - } - } - - @Override public boolean hasContent( VersionedReference reference ) throws ContentAccessException { try 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 b19d336c0..7587be30d 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 @@ -124,41 +124,6 @@ public class ManagedDefaultRepositoryContentTest } @Test - public void testGetVersionsBadArtifact() - throws Exception - { - assertGetVersions( "bad_artifact", Collections.emptyList() ); - } - - @Test - public void testGetVersionsMissingMultipleVersions() - throws Exception - { - assertGetVersions( "missing_metadata_b", Arrays.asList( "1.0", "1.0.1", "2.0", "2.0.1", "2.0-20070821-dev" ) ); - } - - @Test - public void testGetVersionsSimple() - throws Exception - { - assertVersions( "proxied_multi", "2.1", new String[]{ "2.1" } ); - } - - @Test - public void testGetVersionsSimpleYetIncomplete() - throws Exception - { - assertGetVersions( "incomplete_metadata_a", Collections.singletonList( "1.0" ) ); - } - - @Test - public void testGetVersionsSimpleYetMissing() - throws Exception - { - assertGetVersions( "missing_metadata_a", Collections.singletonList( "1.0" ) ); - } - - @Test public void testGetVersionsSnapshotA() throws Exception { @@ -213,39 +178,6 @@ public class ManagedDefaultRepositoryContentTest assertVersions( "include_xml", "1.0", new String[]{ "1.0" } ); } - private void assertGetVersions( String artifactId, List<String> expectedVersions ) - throws Exception - { - ProjectReference reference = new ProjectReference(); - reference.setGroupId( "org.apache.archiva.metadata.tests" ); - reference.setArtifactId( artifactId ); - - // Use the test metadata-repository, which is already setup for - // These kind of version tests. - Path repoDir = getRepositoryPath( "metadata-repository" ); - (( EditableManagedRepository)repoContent.getRepository()).setLocation( repoDir.toAbsolutePath().toUri() ); - - // Request the versions. - Set<String> testedVersionSet = repoContent.getVersions( reference ); - - // Sort the list (for asserts) - VersionComparator comparator = new VersionComparator( ); - List<String> testedVersions = new ArrayList<>(); - testedVersions.addAll( testedVersionSet ); - Collections.sort( testedVersions, comparator ); - - // Test the expected array of versions, to the actual tested versions - assertEquals( "available versions", expectedVersions, testedVersions ); - - ItemSelector selector = ArchivaItemSelector.builder( ) - .withNamespace( "org.apache.archiva.metadata.tests" ) - .withProjectId( artifactId ) - .build( ); - Project project = repoContent.getProject( selector ); - assertNotNull( project ); - List<String> versions = repoContent.getVersions( project ).stream().map(v -> v.getVersion()).sorted( comparator ).collect( Collectors.toList()); - assertArrayEquals( expectedVersions.toArray(), versions.toArray( ) ); - } private void assertVersions( String artifactId, String version, String[] expectedVersions ) throws Exception |