- ensure we only blacklist a repository on resolve, not deploy

- fail if offline when attempting to deploy or retrieve essential metadata

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307317 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-08 17:37:55 +00:00
parent 13b0cf75e6
commit 3a601de20d
3 changed files with 29 additions and 19 deletions

View File

@ -59,8 +59,8 @@ public class DefaultArtifactDeployer
{ {
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {
getLogger().warn( "System is offline. Cannot deploy artifact: " + artifact + "." ); // deployment shouldn't silently fail when offline
return; throw new ArtifactDeploymentException( "System is offline. Cannot deploy artifact: " + artifact + "." );
} }
try try

View File

@ -85,7 +85,7 @@ public class DefaultRepositoryMetadataManager
{ {
getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() ); getLogger().info( metadata.getKey() + ": checking for updates from " + repository.getId() );
resolveAlways( metadata, repository, file, policy.getChecksumPolicy() ); resolveAlways( metadata, repository, file, policy.getChecksumPolicy(), true );
} }
// touch file so that this is not checked again until interval has passed // touch file so that this is not checked again until interval has passed
@ -247,14 +247,15 @@ public class DefaultRepositoryMetadataManager
{ {
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" ); // metadata is required for deployment, can't be offline
return; throw new ArtifactMetadataRetrievalException(
"System is offline. Cannot resolve required metadata:\n" + metadata.extendedToString() );
} }
File file = new File( localRepository.getBasedir(), File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) ); localRepository.pathOfLocalRepositoryMetadata( metadata, remoteRepository ) );
resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); resolveAlways( metadata, remoteRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
if ( file.exists() ) if ( file.exists() )
{ {
@ -264,12 +265,23 @@ public class DefaultRepositoryMetadataManager
} }
private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file, private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file,
String checksumPolicy ) String checksumPolicy, boolean allowBlacklisting )
throws ArtifactMetadataRetrievalException
{ {
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" ); if ( !allowBlacklisting )
return; {
getLogger().debug(
"System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
return;
}
else
{
// metadata is required for deployment, can't be offline
throw new ArtifactMetadataRetrievalException(
"System is offline. Cannot resolve required metadata:\n" + metadata.extendedToString() );
}
} }
try try
@ -292,7 +304,7 @@ public class DefaultRepositoryMetadataManager
" due to an error: " + e.getCause().getMessage() ); " due to an error: " + e.getCause().getMessage() );
getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" ); getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" );
getLogger().debug( "Exception", e ); getLogger().debug( "Exception", e );
repository.setBlacklisted( true ); repository.setBlacklisted( allowBlacklisting );
} }
} }
@ -307,8 +319,9 @@ public class DefaultRepositoryMetadataManager
{ {
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {
getLogger().warn( "System is offline. Cannot deploy metadata:\n" + metadata.extendedToString() + "\n\n" ); // deployment shouldn't silently fail when offline
return; throw new ArtifactMetadataRetrievalException(
"System is offline. Cannot deploy metadata:\n" + metadata.extendedToString() );
} }
getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() ); getLogger().info( "Retrieving previous metadata from " + deploymentRepository.getId() );
@ -316,7 +329,7 @@ public class DefaultRepositoryMetadataManager
File file = new File( localRepository.getBasedir(), File file = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) ); localRepository.pathOfLocalRepositoryMetadata( metadata, deploymentRepository ) );
resolveAlways( metadata, deploymentRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN ); resolveAlways( metadata, deploymentRepository, file, ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN, false );
metadata.storeInLocalRepository( localRepository, deploymentRepository ); metadata.storeInLocalRepository( localRepository, deploymentRepository );

View File

@ -133,12 +133,9 @@ public class SnapshotTransformation
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )
{ {
getLogger().debug( "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" ); // build number is a required feature for metadata consistency
throw new ArtifactMetadataRetrievalException(
getLogger().info( "System is offline. Assuming build number of 0 for " + metadata.getGroupId() + ":" + "System is offline. Cannot resolve metadata:\n" + metadata.extendedToString() + "\n\n" );
metadata.getArtifactId() + " snapshot." );
return 0;
} }
getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() ); getLogger().info( "Retrieving previous build number from " + remoteRepository.getId() );