From 9eb977f581bf3689551222e1b3f91ff86b0ea286 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 29 Feb 2012 09:14:28 +0000 Subject: [PATCH] correctly sort versions on artifact view git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295024 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/rest/services/DefaultBrowseService.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index c6f2d7869..c98fdab69 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -18,6 +18,7 @@ package org.apache.archiva.rest.services; * under the License. */ +import org.apache.archiva.common.utils.VersionComparator; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.repository.MetadataResolutionException; import org.apache.archiva.metadata.repository.MetadataResolver; @@ -185,7 +186,7 @@ public class DefaultBrowseService } - private Set getVersions( List selectedRepos, String groupId, String artifactId ) + private Collection getVersions( List selectedRepos, String groupId, String artifactId ) throws MetadataResolutionException { @@ -202,7 +203,12 @@ public class DefaultBrowseService metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId, artifactId ) ); } - return versions; + List sortedVersions = new ArrayList( versions ); + + Collections.sort( sortedVersions, VersionComparator.getInstance() ); + + + return sortedVersions; } finally { @@ -226,7 +232,7 @@ public class DefaultBrowseService try { - Set projectVersions = getVersions( selectedRepos, groupId, artifactId ); + Collection projectVersions = getVersions( selectedRepos, groupId, artifactId ); repositorySession = repositorySessionFactory.createSession(); -- 2.39.5