{
String localPath = getLocalMetadataPath( pluginGroup, localRepository );
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
PluginPrefixResult result =
resolveFromRepository( request, pluginGroup, groupMetadataFile, localRepository );
if ( result != null )
{
return result;
}
}
Map<String, List<ArtifactRepository>> recheck = new HashMap<String, List<ArtifactRepository>>();
// Process all the remote repositories.
//
for ( String pluginGroup : request.getPluginGroups() )
{
for ( ArtifactRepository repository : request.getRemoteRepositories() )
{
String localPath = getLocalMetadataPath( pluginGroup, repository );
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
if ( !request.isOffline() && ( !groupMetadataFile.exists() || request.isForceUpdate() ) )
{
String remotePath = getRemoteMetadataPath( pluginGroup, repository );
try
{
repositorySystem.retrieve( repository, groupMetadataFile, remotePath,
request.getTransferListener() );
}
catch ( ArtifactTransferFailedException e )
{
if ( logger.isDebugEnabled() )
{
logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
+ e.getMessage(), e );
}
else
{
logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
+ e.getMessage() );
}
}
catch ( ArtifactDoesNotExistException e )
{
continue;
}
}
else if ( !request.isOffline() && !request.isForceUpdate() )
{
List<ArtifactRepository> repos = recheck.get( pluginGroup );
if ( repos == null )
{
repos = new ArrayList<ArtifactRepository>();
recheck.put( pluginGroup, repos );
}
repos.add( repository );
}
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, groupMetadataFile,
repository );
if ( result != null )
{
return result;
}
}
}
// Retry the remote repositories for which we previously only consulted the possibly outdated local cache.
//
for ( String pluginGroup : request.getPluginGroups() )
{
List<ArtifactRepository> repos = recheck.get( pluginGroup );
if ( repos == null )
{
continue;
}
for ( ArtifactRepository repository : repos )
{
String localPath = getLocalMetadataPath( pluginGroup, repository );
File groupMetadataFile = new File( localRepository.getBasedir(), localPath );
String remotePath = getRemoteMetadataPath( pluginGroup, repository );
try
{
repositorySystem.retrieve( repository, groupMetadataFile, remotePath,
request.getTransferListener() );
}
catch ( ArtifactTransferFailedException e )
{
if ( logger.isDebugEnabled() )
{
logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
+ e.getMessage(), e );
}
else
{
logger.warn( "Failed to retrieve " + remotePath + " from " + repository.getId() + ": "
+ e.getMessage() );
}
}
catch ( ArtifactDoesNotExistException e )
{
continue;
}
PluginPrefixResult result = resolveFromRepository( request, pluginGroup, groupMetadataFile,
repository );
if ( result != null )
{
return result;