]> source.dussan.org Git - archiva.git/commitdiff
PR: MRM-97
authorEdwin L. Punzalan <epunzalan@apache.org>
Mon, 20 Feb 2006 03:42:00 +0000 (03:42 +0000)
committerEdwin L. Punzalan <epunzalan@apache.org>
Mon, 20 Feb 2006 03:42:00 +0000 (03:42 +0000)
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

maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/DefaultProxyManager.java
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/configuration/ProxyConfiguration.java
maven-repository-proxy/src/main/java/org/apache/maven/repository/proxy/repository/ProxyRepository.java

index bd8ceee7d5178715c0310102db66eb0de3ffdfa7..a3627a912c0ecb4c944bef1e01c87d91eb183f58 100644 (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 );
+        }
+    }
 }
index d36fa4961bf1afbee15747ec5cb08fedcbc9725e..3d393624197078ab16864c038176290ebb0d4960 100644 (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 );
index 3cf2e09787a1475dcbfb5478a879490c4ed0e5e8..8e5a2e82405a5b85fa3cf87473d972a1f2ecb24d 100644 (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;
+    }
 }