]> source.dussan.org Git - archiva.git/commitdiff
[MRM-191] don't allow proxy requests if no proxy configured
authorBrett Porter <brett@apache.org>
Sat, 30 Sep 2006 14:09:20 +0000 (14:09 +0000)
committerBrett Porter <brett@apache.org>
Sat, 30 Sep 2006 14:09:20 +0000 (14:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@451603 13f79535-47bb-0310-9956-ffa450edef68

archiva-core/src/main/java/org/apache/maven/archiva/proxy/DefaultProxyManager.java

index fbd301829f57c94cea0b8da5841d438a1837ba55..53632ecace0f21719527936526a3f2a2a6db3fbc 100644 (file)
@@ -23,6 +23,9 @@ import org.apache.maven.archiva.configuration.ConfiguredRepositoryFactory;
 import org.apache.maven.archiva.configuration.ProxiedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.Proxy;
 import org.apache.maven.archiva.configuration.RepositoryConfiguration;
+import org.apache.maven.archiva.configuration.ConfigurationChangeListener;
+import org.apache.maven.archiva.configuration.InvalidConfigurationException;
+import org.apache.maven.archiva.configuration.ConfigurationChangeException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.wagon.ResourceDoesNotExistException;
 import org.apache.maven.wagon.proxy.ProxyInfo;
@@ -46,7 +49,7 @@ import java.util.Map;
  */
 public class DefaultProxyManager
     extends AbstractLogEnabled
-    implements ProxyManager
+    implements ProxyManager, ConfigurationChangeListener
 {
     /**
      * @plexus.requirement
@@ -143,6 +146,8 @@ public class DefaultProxyManager
         try
         {
             configuration = configurationStore.getConfigurationFromStore();
+
+            configurationStore.addChangeListener( this );
         }
         catch ( ConfigurationStoreException e )
         {
@@ -153,7 +158,7 @@ public class DefaultProxyManager
     }
 
     private Map getProxyGroups()
-        throws ProxyException
+        throws ProxyException, ResourceDoesNotExistException
     {
         if ( proxyGroups == null )
         {
@@ -170,8 +175,11 @@ public class DefaultProxyManager
                 List proxiedRepositories = getProxiedRepositoriesForManagedRepository(
                     configuration.getProxiedRepositories(), repository.getId() );
 
-                groups.put( repository.getId(),
-                            new ProxiedRepositoryGroup( proxiedRepositories, managedRepository, wagonProxy ) );
+                if ( !proxiedRepositories.isEmpty() )
+                {
+                    groups.put( repository.getId(),
+                                new ProxiedRepositoryGroup( proxiedRepositories, managedRepository, wagonProxy ) );
+                }
             }
 
             // TODO: ability to configure default proxy separately!
@@ -234,4 +242,13 @@ public class DefaultProxyManager
         }
         return proxyInfo;
     }
+
+    public void notifyOfConfigurationChange( Configuration configuration )
+        throws InvalidConfigurationException, ConfigurationChangeException
+    {
+        // reinit
+        proxyGroups = null;
+        defaultProxyGroup = null;
+        getLogger().debug( "Re-initialising proxy configuration" );
+    }
 }