mirror of https://github.com/apache/archiva.git
[MRM-328] Unable to delete network proxies
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@536978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
711bb6c0c6
commit
9091ac4b89
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue