}
public VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
throws VersionRangeResolutionException
{
VersionRangeResult result = new VersionRangeResult( request );
VersionScheme versionScheme = new GenericVersionScheme();
VersionConstraint versionConstraint;
try
{
versionConstraint = versionScheme.parseVersionConstraint( request.getArtifact().getVersion() );
}
catch ( InvalidVersionSpecificationException e )
{
result.addException( e );
throw new VersionRangeResolutionException( result );
}
result.setVersionConstraint( versionConstraint );
if ( versionConstraint.getRanges().isEmpty() )
{
result.addVersion( versionConstraint.getVersion() );
}
else
{
Map<String, ArtifactRepository> versionIndex =
getVersions( session, result, request, getNature( session, versionConstraint.getRanges() ) );
List<Version> versions = new ArrayList<Version>();
for ( Map.Entry<String, ArtifactRepository> v : versionIndex.entrySet() )
{
try
{
Version ver = versionScheme.parseVersion( v.getKey() );
if ( versionConstraint.containsVersion( ver ) )
{
versions.add( ver );
result.setRepository( ver, v.getValue() );
}
}
catch ( InvalidVersionSpecificationException e )
{
result.addException( e );
}
}
Collections.sort( versions );
result.setVersions( versions );
}
return result;
}