]> source.dussan.org Git - archiva.git/commitdiff
Moving to new repository content API
authorMartin Stockhammer <martin_s@apache.org>
Tue, 21 Apr 2020 17:45:23 +0000 (19:45 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Tue, 21 Apr 2020 17:45:23 +0000 (19:45 +0200)
archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/metadata/base/MetadataTools.java

index a8298e2ae0c7c27b30c1cc4075efd1124b8b81c0..67e1310095a4628f4afd385bc6446aebf0ee168e 100644 (file)
@@ -45,6 +45,7 @@ import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.RemoteRepositoryContent;
 import org.apache.archiva.repository.RepositoryRegistry;
 import org.apache.archiva.repository.RepositoryType;
+import org.apache.archiva.repository.content.Artifact;
 import org.apache.archiva.repository.content.ItemSelector;
 import org.apache.archiva.repository.content.Project;
 import org.apache.archiva.repository.content.base.ArchivaItemSelector;
@@ -153,11 +154,22 @@ public class MetadataTools
         Set<String> foundVersions = null;
         try
         {
-            foundVersions = managedRepository.getVersions( reference );
+            ArchivaItemSelector selector = ArchivaItemSelector.builder( )
+                .withNamespace( reference.getGroupId( ) )
+                .withProjectId( reference.getArtifactId( ) )
+                .withArtifactId( reference.getArtifactId( ) )
+                .withVersion( reference.getVersion( ) )
+                .build( );
+            try(Stream<? extends Artifact> stream = managedRepository.newArtifactStream( selector )) {
+                foundVersions = stream.map( a -> a.getArtifactVersion( ) )
+                    .filter( StringUtils::isNotEmpty )
+                    .collect( Collectors.toSet( ) );
+            }
         }
         catch ( org.apache.archiva.repository.ContentAccessException e )
         {
-            e.printStackTrace( );
+            log.error( "Error while accessing content {}", e.getMessage( ) );
+            throw new IOException( "Could not access repository content: " + e.getMessage( ) );
         }
 
         // Next gather up the referenced 'latest' versions found in any proxied repositories