]> source.dussan.org Git - archiva.git/commitdiff
[MRM-626] ClassCastException when saving proxy connector with property defined
authorBrett Porter <brett@apache.org>
Tue, 25 Mar 2008 07:34:25 +0000 (07:34 +0000)
committerBrett Porter <brett@apache.org>
Tue, 25 Mar 2008 07:34:25 +0000 (07:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@640726 13f79535-47bb-0310-9956-ffa450edef68

archiva-1.0.x/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
archiva-1.0.x/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
archiva-1.0.x/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java

index cee8a8fa62931d65938b314ba5e8e92dac495031..68adb6c57133d8d77d24ba60eeda794178672c50 100644 (file)
@@ -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;
index a5cd1ba1167c7ed515a7916427dc6e9ce2089e9e..b4747e393ed28681df915263891e41bc08e2b25e 100644 (file)
@@ -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()
index f24918d684200cb1603bebfa70f1e0d47cf600ff..626cf5654a791ad91ec86c065454bb455200e726 100644 (file)
@@ -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()