diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java index bea69f315..d9daedade 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/DefaultRepositoryBrowsing.java @@ -180,9 +180,9 @@ public class DefaultRepositoryBrowsing } /** - * @see RepositoryBrowsing#getTimestampedSnapshots(List, String, String, String) + * @see RepositoryBrowsing#getOtherSnapshotVersions(List, String, String, String) */ - public List getTimestampedSnapshots( List observableRepositoryIds, String groupId, + public List getOtherSnapshotVersions( List observableRepositoryIds, String groupId, String artifactId, String version ) throws ObjectNotFoundException, ArchivaDatabaseException { @@ -194,14 +194,15 @@ public class DefaultRepositoryBrowsing dao.query( new UniqueVersionConstraint( observableRepositoryIds, groupId, artifactId ) ); for ( String uniqueVersion : versions ) - { - if ( VersionUtil.getBaseVersion( uniqueVersion ).equals( version ) ) + { + if ( VersionUtil.getBaseVersion( uniqueVersion ).equals( version ) || + VersionUtil.getBaseVersion( uniqueVersion ).equals( VersionUtil.getBaseVersion( version ) ) ) { if ( !timestampedVersions.contains( uniqueVersion ) ) { timestampedVersions.add( uniqueVersion ); } - } + } } } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsing.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsing.java index 270291d2f..835d93aca 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsing.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsing.java @@ -91,7 +91,7 @@ public interface RepositoryBrowsing throws ObjectNotFoundException, ArchivaDatabaseException; /** - * Get the timestamped versions or versions with build numbers of the given SNAPSHOT artifact. + * Get the other versions of the given SNAPSHOT version. * * @param observableRepositoryIds * @param groupId @@ -101,7 +101,7 @@ public interface RepositoryBrowsing * @throws ObjectNotFoundException * @throws ArchivaDatabaseException */ - public List getTimestampedSnapshots( List observableRepositoryIds, + public List getOtherSnapshotVersions( List observableRepositoryIds, String groupId, String artifactId, String version ) throws ObjectNotFoundException, ArchivaDatabaseException; diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java index b574d829c..8ec1d5f2c 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/browsing/RepositoryBrowsingTest.java @@ -164,7 +164,37 @@ public class RepositoryBrowsingTest assertTrue( results.getVersions().contains( "2.1.1" ) ); assertTrue( results.getVersions().contains( "2.1-alpha-1" ) ); } - + + public void testGetOtherSnapshotVersionsRequestedVersionIsGeneric() + throws Exception + { + saveTestData(); + + RepositoryBrowsing browser = lookupBrowser(); + List results = + browser.getOtherSnapshotVersions( GUEST_REPO_IDS, "org.apache.maven.shared", "test-two", "2.1-SNAPSHOT" ); + assertNotNull( "Returned list of versions should not be null.", results ); + assertEquals( 3, results.size() ); + assertTrue( results.contains( "2.1-SNAPSHOT" ) ); + assertTrue( results.contains( "2.1-20070522.143249-1" ) ); + assertTrue( results.contains( "2.1-20070522.153141-2" ) ); + } + + public void testGetOtherSnapshotVersionsRequestedVersionIsUnique() + throws Exception + { + saveTestData(); + + RepositoryBrowsing browser = lookupBrowser(); + List results = + browser.getOtherSnapshotVersions( GUEST_REPO_IDS, "org.apache.maven.shared", "test-two", "2.1-20070522.143249-1" ); + assertNotNull( "Returned list of versions should not be null.", results ); + assertEquals( 3, results.size() ); + assertTrue( results.contains( "2.1-SNAPSHOT" ) ); + assertTrue( results.contains( "2.1-20070522.143249-1" ) ); + assertTrue( results.contains( "2.1-20070522.153141-2" ) ); + } + private void assertGroupIds( String msg, List actualGroupIds, String[] expectedGroupIds ) { assertEquals( msg + ": groupIds.length", expectedGroupIds.length, actualGroupIds.size() ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java index be1323844..f2ed927e6 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java @@ -112,7 +112,7 @@ public class ShowArtifactAction repoBrowsing.selectVersion( getPrincipal(), getObservableRepos(), groupId, artifactId, version ); this.snapshotVersions = - repoBrowsing.getTimestampedSnapshots( getObservableRepos(), groupId, artifactId, version ); + repoBrowsing.getOtherSnapshotVersions( getObservableRepos(), groupId, artifactId, version ); if( this.snapshotVersions.contains( version ) ) { this.snapshotVersions.remove( version );