import com.opensymphony.xwork2.Preparable;
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.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.policies.DownloadErrorPolicy;
import org.apache.maven.archiva.policies.Policy;
import org.apache.maven.archiva.policies.PostDownloadPolicy;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
protected ProxyConnector connector;
@Inject
- private ArchivaConfiguration archivaConfiguration;
+ private NetworkProxyAdmin networkProxyAdmin;
@PostConstruct
public void initialize()
}
protected List<String> createNetworkProxyOptions()
+ throws RepositoryAdminException
{
List<String> options = new ArrayList<String>();
options.add( DIRECT_CONNECTION );
- options.addAll( archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().keySet() );
+ options.addAll( getNetworkProxiesKeys() );
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()
{
Map<String, Policy> policyMap = new HashMap<String, Policy>();
}
}
- // FIXME remove
- public ArchivaConfiguration getArchivaConfiguration()
+ public NetworkProxyAdmin getNetworkProxyAdmin()
{
- return archivaConfiguration;
+ return networkProxyAdmin;
}
- public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+ public void setNetworkProxyAdmin( NetworkProxyAdmin networkProxyAdmin )
{
- this.archivaConfiguration = archivaConfiguration;
+ this.networkProxyAdmin = networkProxyAdmin;
}
}
import java.util.Map;
/**
- * AddProxyConnectorActionTest
+ * AddProxyConnectorActionTest
*
* @version $Id$
*/
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
- action.setArchivaConfiguration( archivaConfiguration );
( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
archivaConfiguration );
( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
assertEquals( 1, connector.getProperties().size() );
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
public void testAddProxyConnectorCommit()
throws Exception
{
archivaConfiguration.save( config );
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
private void populateProxyConnector( ProxyConnector connector )
{
connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
{
super.setUp();
- //action = (EditProxyConnectorAction) lookup( Action.class.getName(), "editProxyConnectorAction" );
action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
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(
archivaConfiguration );
{
Configuration config = createInitialConfiguration();
- archivaConfiguration.getConfiguration();
- archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+ archivaConfigurationControl.expectAndReturn( archivaConfiguration.getConfiguration(), config,
+ requestConfigCount , 20);
+ //archivaConfiguration.getConfiguration();
+ //archivaConfigurationControl.setReturnValue( config, requestConfigCount );
for ( int i = 0; i <= saveRequestCount; i++ )
{
archivaConfiguration.save( config );
}
+
+ ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+ archivaConfiguration );
+ ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+ archivaConfiguration );
+ ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+ archivaConfiguration );
}
public void testAddBlackListPattern()
public void testSecureActionBundle()
throws Exception
{
+ /* Configuration will be requested at least 3 times. */
+ archivaConfiguration.getConfiguration();
+ archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
archivaConfigurationControl.replay();
action.prepare();