mirror of https://github.com/apache/archiva.git
more cleanup of direct use of archiva-configuration
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170513 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
76ddd65c91
commit
2459cfd7a8
|
@ -21,9 +21,10 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
|
||||||
|
|
||||||
import com.opensymphony.xwork2.Preparable;
|
import com.opensymphony.xwork2.Preparable;
|
||||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
|
import org.apache.archiva.admin.model.networkproxy.NetworkProxy;
|
||||||
|
import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
|
||||||
import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
|
import org.apache.archiva.admin.model.proxyconnector.ProxyConnector;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
|
||||||
import org.apache.maven.archiva.policies.DownloadErrorPolicy;
|
import org.apache.maven.archiva.policies.DownloadErrorPolicy;
|
||||||
import org.apache.maven.archiva.policies.Policy;
|
import org.apache.maven.archiva.policies.Policy;
|
||||||
import org.apache.maven.archiva.policies.PostDownloadPolicy;
|
import org.apache.maven.archiva.policies.PostDownloadPolicy;
|
||||||
|
@ -32,6 +33,8 @@ import org.apache.maven.archiva.policies.PreDownloadPolicy;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -96,7 +99,7 @@ public abstract class AbstractProxyConnectorFormAction
|
||||||
protected ProxyConnector connector;
|
protected ProxyConnector connector;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ArchivaConfiguration archivaConfiguration;
|
private NetworkProxyAdmin networkProxyAdmin;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void initialize()
|
public void initialize()
|
||||||
|
@ -395,15 +398,33 @@ public abstract class AbstractProxyConnectorFormAction
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> createNetworkProxyOptions()
|
protected List<String> createNetworkProxyOptions()
|
||||||
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
List<String> options = new ArrayList<String>();
|
List<String> options = new ArrayList<String>();
|
||||||
|
|
||||||
options.add( DIRECT_CONNECTION );
|
options.add( DIRECT_CONNECTION );
|
||||||
options.addAll( archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().keySet() );
|
options.addAll( getNetworkProxiesKeys() );
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Collection<String> getNetworkProxiesKeys()
|
||||||
|
throws RepositoryAdminException
|
||||||
|
{
|
||||||
|
List<NetworkProxy> networkProxies = networkProxyAdmin.getNetworkProxies();
|
||||||
|
if ( networkProxies == null || networkProxies.isEmpty() )
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
List<String> keys = new ArrayList<String>( networkProxies.size() );
|
||||||
|
for ( NetworkProxy networkProxy : networkProxies )
|
||||||
|
{
|
||||||
|
keys.add( networkProxy.getId() );
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected Map<String, Policy> createPolicyMap()
|
protected Map<String, Policy> createPolicyMap()
|
||||||
{
|
{
|
||||||
Map<String, Policy> policyMap = new HashMap<String, Policy>();
|
Map<String, Policy> policyMap = new HashMap<String, Policy>();
|
||||||
|
@ -485,14 +506,13 @@ public abstract class AbstractProxyConnectorFormAction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME remove
|
public NetworkProxyAdmin getNetworkProxyAdmin()
|
||||||
public ArchivaConfiguration getArchivaConfiguration()
|
|
||||||
{
|
{
|
||||||
return archivaConfiguration;
|
return networkProxyAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
|
public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
|
||||||
{
|
{
|
||||||
this.archivaConfiguration = archivaConfiguration;
|
this.networkProxyAdmin = networkProxyAdmin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ public class AddProxyConnectorActionTest
|
||||||
|
|
||||||
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
|
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
|
||||||
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
||||||
action.setArchivaConfiguration( archivaConfiguration );
|
|
||||||
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
||||||
archivaConfiguration );
|
archivaConfiguration );
|
||||||
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
|
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
|
||||||
|
@ -140,7 +139,7 @@ public class AddProxyConnectorActionTest
|
||||||
assertEquals( 1, connector.getProperties().size() );
|
assertEquals( 1, connector.getProperties().size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings( "unchecked" )
|
||||||
public void testAddProxyConnectorCommit()
|
public void testAddProxyConnectorCommit()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
@ -411,7 +410,7 @@ public class AddProxyConnectorActionTest
|
||||||
archivaConfiguration.save( config );
|
archivaConfiguration.save( config );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings( "unchecked" )
|
||||||
private void populateProxyConnector( ProxyConnector connector )
|
private void populateProxyConnector( ProxyConnector connector )
|
||||||
{
|
{
|
||||||
connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
|
connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
|
||||||
|
|
|
@ -68,16 +68,12 @@ public class EditProxyConnectorActionTest
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
//action = (EditProxyConnectorAction) lookup( Action.class.getName(), "editProxyConnectorAction" );
|
|
||||||
action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
|
action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
|
||||||
|
|
||||||
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
|
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
|
||||||
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
|
||||||
action.setArchivaConfiguration( archivaConfiguration );
|
|
||||||
|
|
||||||
/* Configuration will be requested at least 3 times. */
|
|
||||||
archivaConfiguration.getConfiguration();
|
|
||||||
archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
|
|
||||||
|
|
||||||
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
||||||
archivaConfiguration );
|
archivaConfiguration );
|
||||||
|
@ -98,13 +94,22 @@ public class EditProxyConnectorActionTest
|
||||||
{
|
{
|
||||||
Configuration config = createInitialConfiguration();
|
Configuration config = createInitialConfiguration();
|
||||||
|
|
||||||
archivaConfiguration.getConfiguration();
|
archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config,
|
||||||
archivaConfigurationControl.setReturnValue( config, requestConfigCount );
|
requestConfigCount , 20);
|
||||||
|
//archivaConfiguration.getConfiguration();
|
||||||
|
//archivaConfigurationControl.setReturnValue( config, requestConfigCount );
|
||||||
|
|
||||||
for ( int i = 0; i <= saveRequestCount; i++ )
|
for ( int i = 0; i <= saveRequestCount; i++ )
|
||||||
{
|
{
|
||||||
archivaConfiguration.save( config );
|
archivaConfiguration.save( config );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
|
||||||
|
archivaConfiguration );
|
||||||
|
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
|
||||||
|
archivaConfiguration );
|
||||||
|
( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
|
||||||
|
archivaConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAddBlackListPattern()
|
public void testAddBlackListPattern()
|
||||||
|
@ -408,6 +413,9 @@ public class EditProxyConnectorActionTest
|
||||||
public void testSecureActionBundle()
|
public void testSecureActionBundle()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
/* Configuration will be requested at least 3 times. */
|
||||||
|
archivaConfiguration.getConfiguration();
|
||||||
|
archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
|
||||||
archivaConfigurationControl.replay();
|
archivaConfigurationControl.replay();
|
||||||
|
|
||||||
action.prepare();
|
action.prepare();
|
||||||
|
|
Loading…
Reference in New Issue