{
Comparator<String> comparator = VersionComparator.getInstance();
File metadataFile = new File( managedRepository.getUrl().getPath(), toPath( reference ) );
ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
metadata.setGroupId( reference.getGroupId() );
metadata.setArtifactId( reference.getArtifactId() );
// Gather up the versions found in the managed repository.
Set<String> availableVersions = gatherAvailableVersions( managedRepository, reference );
// Does this repository have a set of remote proxied repositories?
Set proxiedRepoIds = this.proxies.get( managedRepository.getId() );
String latestVersion = null;
String releaseVersion = null;
if ( proxiedRepoIds != null )
{
// Add in the proxied repo version ids too.
Iterator<String> it = proxiedRepoIds.iterator();
while ( it.hasNext() )
{
String proxyId = it.next();
ArchivaRepositoryMetadata proxyMetadata = readProxyMetadata( managedRepository, reference, proxyId );
if ( proxyMetadata != null )
{
availableVersions.addAll( proxyMetadata.getAvailableVersions() );
if ( latestVersion == null ||
comparator.compare( proxyMetadata.getLatestVersion(), latestVersion ) > 0 )
{
latestVersion = proxyMetadata.getLatestVersion();
}
if ( releaseVersion == null ||
comparator.compare( proxyMetadata.getReleasedVersion(), releaseVersion ) > 0 )
{
releaseVersion = proxyMetadata.getReleasedVersion();
}
}
}
}