{
File metadataFile = new File( managedRepository.getRepoRoot(), toPath( reference ) );
long lastUpdated = getExistingLastUpdated( metadataFile );
ArchivaRepositoryMetadata metadata = new ArchivaRepositoryMetadata();
metadata.setGroupId( reference.getGroupId() );
metadata.setArtifactId( reference.getArtifactId() );
// Gather up all versions found in the managed repository.
Set<String> allVersions = managedRepository.getVersions( reference );
// Gather up all plugins found in the managed repository.
// TODO: do we know this information instead?
// Set<Plugin> allPlugins = managedRepository.getPlugins( reference );
Set<Plugin> allPlugins;
if ( metadataFile.exists() )
{
allPlugins = new LinkedHashSet<Plugin>( RepositoryMetadataReader.read( metadataFile ).getPlugins() );
}
else
{
allPlugins = new LinkedHashSet<Plugin>();
}
// Does this repository have a set of remote proxied repositories?
Set<String> proxiedRepoIds = this.proxies.get( managedRepository.getId() );
if ( CollectionUtils.isNotEmpty( proxiedRepoIds ) )
{
// 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 )
{
allVersions.addAll( proxyMetadata.getAvailableVersions() );
allPlugins.addAll( proxyMetadata.getPlugins() );
long proxyLastUpdated = getLastUpdated( proxyMetadata );
lastUpdated = Math.max( lastUpdated, proxyLastUpdated );
}
}