diff options
author | Brett Porter <brett@apache.org> | 2008-03-25 07:38:10 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2008-03-25 07:38:10 +0000 |
commit | eb49de5e7267ef610328d583579a4fb9a5f3ec7a (patch) | |
tree | 92ce1776aba5b94b00f240a6ee6671d4a3d2d30b | |
parent | e821a90870421f3e2a84e0c0191cb8a559d1c342 (diff) | |
download | archiva-eb49de5e7267ef610328d583579a4fb9a5f3ec7a.tar.gz archiva-eb49de5e7267ef610328d583579a4fb9a5f3ec7a.zip |
[MRM-626] ClassCastException when saving proxy connector with property defined
Merged from: r640726
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@640728 13f79535-47bb-0310-9956-ffa450edef68
3 files changed, 21 insertions, 3 deletions
diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java index cee8a8fa6..68adb6c57 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork.Preparable; - import org.apache.commons.lang.StringUtils; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.policies.DownloadPolicy; @@ -29,6 +28,7 @@ import org.apache.maven.archiva.policies.PreDownloadPolicy; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -399,6 +399,19 @@ public abstract class AbstractProxyConnectorFormAction continue; } + Map properties = connector.getProperties(); + for ( Iterator j = properties.keySet().iterator(); j.hasNext(); ) + { + String key = (String) j.next(); + + Object value = properties.get( key ); + if ( value.getClass().isArray() ) + { + String[] arr = (String[]) value; + properties.put( key, arr[0] ); + } + } + // Ugly hack to compensate for ugly browsers. Object o = connector.getPolicies().get( policyId ); String value; diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java index a5cd1ba11..b4747e393 100644 --- a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java +++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork.Action; - import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; @@ -126,6 +125,8 @@ public class AddProxyConnectorActionTest action.prepare(); ProxyConnectorConfiguration connector = action.getConnector(); populateProxyConnector( connector ); + // forms will use an array + connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } ); // Create the input screen. assertRequestStatus( action, Action.SUCCESS, "commit" ); @@ -143,6 +144,7 @@ public class AddProxyConnectorActionTest assertNull( actualConnector.getProxyId() ); assertEquals( "corporate", actualConnector.getSourceRepoId() ); assertEquals( "central", actualConnector.getTargetRepoId() ); + assertEquals( "gramov-a-bits", actualConnector.getProperties().get( "eat-a" ) ); } public void testAddProxyConnectorInitialPage() diff --git a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java index f24918d68..626cf5654 100644 --- a/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java +++ b/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java @@ -20,7 +20,6 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy; */ import com.opensymphony.xwork.Action; - import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.IndeterminateConfigurationException; @@ -122,6 +121,7 @@ public class EditProxyConnectorActionTest // Should have no error, and 1 property added. assertNoErrors( action ); assertEquals( 1, connector.getProperties().size() ); + assertEquals( "gramov-a-bits", connector.getProperties().get( "eat-a" ) ); } public void testAddWhiteListPattern() @@ -169,6 +169,8 @@ public class EditProxyConnectorActionTest action.prepare(); ProxyConnectorConfiguration connector = action.getConnector(); assertInitialProxyConnector( connector ); + // forms will use an array + connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } ); // Create the input screen. assertRequestStatus( action, Action.SUCCESS, "commit" ); @@ -186,6 +188,7 @@ public class EditProxyConnectorActionTest assertNull( actualConnector.getProxyId() ); assertEquals( "corporate", actualConnector.getSourceRepoId() ); assertEquals( "central", actualConnector.getTargetRepoId() ); + } public void testEditProxyConnectorInitialPage() |