PR: MRM-97

Added hardfail configuration option in ProxyRepository and implemented it in DefaultProxyManager

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@379010 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Edwin L. Punzalan 2006-02-20 03:42:00 +00:00
parent 136af3e214
commit 644ee33484
3 changed files with 47 additions and 6 deletions

View File

@ -283,7 +283,8 @@ public class DefaultProxyManager
}
catch ( TransferFailedException e )
{
getLogger().info( "Skipping repository " + repository.getUrl() + ": " + e.getMessage() );
String message = "Skipping repository " + repository.getUrl() + ": " + e.getMessage();
processRepositoryFailure( repository, message, e );
}
catch ( ResourceDoesNotExistException e )
{
@ -292,12 +293,14 @@ public class DefaultProxyManager
}
catch ( AuthorizationException e )
{
getLogger().info( "Skipping repository " + repository.getUrl() + ": " + e.getMessage() );
String message = "Skipping repository " + repository.getUrl() + ": " + e.getMessage();
processRepositoryFailure( repository, message, e );
}
catch ( UnsupportedProtocolException e )
{
getLogger().info( "Skipping repository " + repository.getUrl() + ": no wagonManager configured " +
"for protocol " + repository.getProtocol() );
String message = "Skipping repository " + repository.getUrl() + ": no wagonManager configured " +
"for protocol " + repository.getProtocol();
processRepositoryFailure( repository, message, e );
}
finally
{
@ -558,4 +561,18 @@ public class DefaultProxyManager
getLogger().error( "Problem disconnecting from wagonManager - ignoring: " + e.getMessage() );
}
}
private void processRepositoryFailure( ProxyRepository repository, String message, Throwable t )
throws ProxyException
{
if ( repository.isHardfail() )
{
throw new ProxyException(
"An error occurred in hardfailing repository " + repository.getName() + "...\n " + message, t );
}
else
{
getLogger().debug( message, t );
}
}
}

View File

@ -170,13 +170,14 @@ public class ProxyConfiguration
ProxyRepository repo = new ProxyRepository( repoConfig.getKey(), repoConfig.getUrl(), layout );
repo.setCacheFailures( repoConfig.getCacheFailures() );
repo.setCachePeriod( repoConfig.getCachePeriod() );
repo.setHardfail( repoConfig.getHardFail() );
if ( repoConfig instanceof HttpRepoConfiguration )
{
HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
MavenProxyConfiguration httpProxy = httpRepo.getProxy();
repo.setProxy( httpProxy.getHost(), httpProxy.getPort(),
httpProxy.getUsername(), httpProxy.getPassword() );
repo.setProxy( httpProxy.getHost(), httpProxy.getPort(), httpProxy.getUsername(),
httpProxy.getPassword() );
}
repoList.add( repo );

View File

@ -34,6 +34,8 @@ public class ProxyRepository
private boolean cacheFailures = false;
private boolean hardfail = false;
private ProxyInfo proxy;
public ProxyRepository( String id, String url, ArtifactRepositoryLayout layout, boolean cacheFailures,
@ -118,4 +120,25 @@ public class ProxyRepository
{
this.proxy = proxy;
}
/**
* Checks the repository hardfail setting.
*
* @return true if the hardfail is enabled, otherwise, returns false.
*/
public boolean isHardfail()
{
return hardfail;
}
/**
* If hardfail is set to true, then any unexpected errors from retrieving files from this repository
* will cause the download to fail.
*
* @param hardfail set to true to enable hard failures
*/
public void setHardfail( boolean hardfail )
{
this.hardfail = hardfail;
}
}