]> source.dussan.org Git - archiva.git/commitdiff
[MRM-328] Unable to delete network proxies
authorJoakim Erdfelt <joakime@apache.org>
Thu, 10 May 2007 19:49:10 +0000 (19:49 +0000)
committerJoakim Erdfelt <joakime@apache.org>
Thu, 10 May 2007 19:49:10 +0000 (19:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@536978 13f79535-47bb-0310-9956-ffa450edef68

archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/networkproxies/ConfigureNetworkProxyAction.java
archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteNetworkProxy.jsp

index 68365ebbd4a9762d5d5fe3a5241c461640464805..1068bb21d3c9e1d41150599161f69429f0e0cdaa 100644 (file)
@@ -26,7 +26,6 @@ import org.apache.commons.collections.functors.NotPredicate;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.InvalidConfigurationException;
 import org.apache.maven.archiva.configuration.NetworkProxyConfiguration;
 import org.apache.maven.archiva.configuration.functors.NetworkProxySelectionPredicate;
 import org.apache.maven.archiva.security.ArchivaRoleConstants;
@@ -37,8 +36,6 @@ import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
 import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
 import org.codehaus.plexus.xwork.action.PlexusActionSupport;
 
-import java.io.IOException;
-
 /**
  * ConfigureNetworkProxyAction 
  *
@@ -75,7 +72,27 @@ public class ConfigureNetworkProxyAction
 
     public String delete()
     {
-        return INPUT;
+        Configuration config = archivaConfiguration.getConfiguration();
+
+        String id = getProxyid();
+        if ( StringUtils.isBlank( id ) )
+        {
+            addActionError( "Unable to delete network proxy with blank id." );
+            return SUCCESS;
+        }
+
+        NetworkProxySelectionPredicate networkProxySelection = new NetworkProxySelectionPredicate( id );
+        NetworkProxyConfiguration proxyConfig = (NetworkProxyConfiguration) CollectionUtils.find( config
+            .getNetworkProxies(), networkProxySelection );
+        if ( proxyConfig == null )
+        {
+            addActionError( "Unable to remove network proxy, proxy with id [" + id + "] not found." );
+            return SUCCESS;
+        }
+        
+        archivaConfiguration.getConfiguration().removeNetworkProxy( proxyConfig );
+        addActionMessage( "Successfully removed network proxy [" + id + "]" );
+        return saveConfiguration();
     }
 
     public String edit()
@@ -93,7 +110,7 @@ public class ConfigureNetworkProxyAction
     {
         return proxy;
     }
-    
+
     public String getProxyid()
     {
         return proxyid;
@@ -142,25 +159,8 @@ public class ConfigureNetworkProxyAction
             removeNetworkProxy( id );
         }
 
-        try
-        {
-            addNetworkProxy( getProxy() );
-            saveConfiguration();
-        }
-        catch ( IOException e )
-        {
-            addActionError( "I/O Exception: " + e.getMessage() );
-        }
-        catch ( InvalidConfigurationException e )
-        {
-            addActionError( "Invalid Configuration Exception: " + e.getMessage() );
-        }
-        catch ( RegistryException e )
-        {
-            addActionError( "Configuration Registry Exception: " + e.getMessage() );
-        }
-
-        return SUCCESS;
+        addNetworkProxy( getProxy() );
+        return saveConfiguration();
     }
 
     public void setMode( String mode )
@@ -200,11 +200,16 @@ public class ConfigureNetworkProxyAction
     }
 
     private String saveConfiguration()
-        throws IOException, InvalidConfigurationException, RegistryException
     {
-        archivaConfiguration.save( archivaConfiguration.getConfiguration() );
-
-        addActionMessage( "Successfully saved configuration" );
+        try
+        {
+            archivaConfiguration.save( archivaConfiguration.getConfiguration() );
+            addActionMessage( "Successfully saved configuration" );
+        }
+        catch ( RegistryException e )
+        {
+            addActionError( "Unable to save configuration: " + e.getMessage() );
+        }
 
         return SUCCESS;
     }
index 584a99c72f8eccbd87bb4c274082ccb4f420a11a..ff7ceadf2a551def4fcc24630b707088a782d0bf 100644 (file)
@@ -38,7 +38,7 @@
   </blockquote>
   
   <p>
-  Are you sure you want to delete network proxy ${proxyid} ?
+  Are you sure you want to delete network proxy <code>${proxyid}</code> ?
   </p>
 
   <ww:form method="post" action="deleteNetworkProxy!delete" namespace="/admin" validate="true">