in maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java [58:178]
public void resolve( RepositoryMetadata metadata, List remoteRepositories, ArtifactRepository localRepository )
throws RepositoryMetadataResolutionException
{
boolean alreadyResolved = alreadyResolved( metadata );
if ( !alreadyResolved )
{
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
ArtifactRepository repository = (ArtifactRepository) i.next();
ArtifactRepositoryPolicy policy =
metadata.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
if ( !policy.isEnabled() )
{
getLogger().debug( "Skipping disabled repository " + repository.getId() );
}
else if ( repository.isBlacklisted() )
{
getLogger().debug( "Skipping blacklisted repository " + repository.getId() );
}
else
{
File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, repository ) );
boolean checkForUpdates =
!file.exists() || policy.checkOutOfDate( new Date( file.lastModified() ) );
if ( checkForUpdates )
{
if ( wagonManager.isOnline() )
{
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
boolean storeMetadata = false;
try
{
wagonManager.getArtifactMetadata( metadata, repository, file,
policy.getChecksumPolicy() );
storeMetadata = true;
}
catch ( ResourceDoesNotExistException e )
{
getLogger().debug(
metadata + " could not be found on repository: " + repository.getId() );
// delete the local copy so the old details aren't used.
if ( file.exists() )
{
file.delete();
}
storeMetadata = true;
}
catch ( TransferFailedException e )
{
getLogger().warn( metadata + " could not be retrieved from repository: "
+ repository.getId() + " due to an error: " + e.getMessage() );
getLogger().debug( "Exception", e );
getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" );
repository.setBlacklisted( true );
// TODO: [jc; 08-Nov-2005] revisit this for 2.1
// suppressing logging to avoid logging this error twice.
}
if ( storeMetadata )
{
// touch file so that this is not checked again until interval has passed
if ( file.exists() )
{
file.setLastModified( System.currentTimeMillis() );
}
else
{
// this ensures that files are not continuously checked when they don't exist remotely
// TODO: [jdcasey] If this happens as a result of ResourceDoesNotExistException, what effect will it have on subsequent runs?
// Will the updateInterval come into play cleanly, or will this plug up the works??
try
{
metadata.storeInLocalRepository( localRepository, repository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataResolutionException(
"Unable to store local copy of metadata: " + e.getMessage(), e );
}
}
}
}
else
{
getLogger().debug( "System is offline. Cannot resolve metadata:\n"
+ metadata.extendedToString() + "\n\n" );
}
}
}
}
// TODO: [jdcasey] what happens here when the system is offline, or there is a TransferFailedException
// ...and no metadata file is written?
cachedMetadata.add( metadata.getKey() );
}
try
{
mergeMetadata( metadata, remoteRepositories, localRepository );
}
catch ( RepositoryMetadataStoreException e )
{
throw new RepositoryMetadataResolutionException(
"Unable to store local copy of metadata: " + e.getMessage(), e );
}
catch ( RepositoryMetadataReadException e )
{
throw new RepositoryMetadataResolutionException( "Unable to read local copy of metadata: " + e.getMessage(),
e );
}
}