archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1166391 - in /archiva/trunk: ./ archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ archiva-modules/archiva-base/archiva-repository-admin/ archiva-modules/archiva-base/archiva-r...
Date Wed, 07 Sep 2011 20:33:49 GMT
Author: olamy
Date: Wed Sep  7 20:33:48 2011
New Revision: 1166391

URL: http://svn.apache.org/viewvc?rev=1166391&view=rev
Log:
use beanlib for wrappers constructions

Added:
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorOrderComparator.java
      - copied, changed from r1166163, archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorSelectionPredicate.java
      - copied, changed from r1166163, archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
    archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/pom.xml
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
    archiva/trunk/pom.xml

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
Wed Sep  7 20:33:48 2011
@@ -24,6 +24,7 @@ import org.apache.maven.archiva.configur
 import java.util.Comparator;
 
 /**
+ * @deprecated
  * ProxyConnectorConfigurationOrderComparator 
  *
  * @version $Id$

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
Wed Sep  7 20:33:48 2011
@@ -24,8 +24,7 @@ import org.apache.commons.lang.StringUti
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 
 /**
- * ProxyConnectorPredicate 
- *
+ * ProxyConnectorPredicate
  * @version $Id$
  */
 public class ProxyConnectorSelectionPredicate

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/pom.xml?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/pom.xml Wed Sep  7
20:33:48 2011
@@ -47,7 +47,10 @@
     <dependency>
       <groupId>javax.inject</groupId>
       <artifactId>javax.inject</artifactId>
-      <version>1</version>
+    </dependency>
+    <dependency>
+      <groupId>net.sf.beanlib</groupId>
+      <artifactId>beanlib</artifactId>
     </dependency>
     <dependency>
       <groupId>org.springframework</groupId>

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
Wed Sep  7 20:33:48 2011
@@ -18,6 +18,7 @@ package org.apache.archiva.admin.reposit
  * under the License.
  */
 
+import net.sf.beanlib.provider.replicator.BeanReplicator;
 import org.apache.archiva.admin.AuditInformation;
 import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
 import org.apache.archiva.admin.repository.RepositoryAdminException;
@@ -33,8 +34,11 @@ import org.springframework.stereotype.Se
 
 import javax.inject.Inject;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author Olivier Lamy
@@ -150,8 +154,42 @@ public class DefaultProxyConnectorAdmin
         return rawPatterns;
     }
 
-    protected ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId,
-                                                              Configuration configuration
)
+    public Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+        throws RepositoryAdminException
+    {
+        java.util.Map<String, List<ProxyConnector>> proxyConnectorMap =
+            new HashMap<String, java.util.List<ProxyConnector>>();
+
+        Iterator<ProxyConnector> it = getProxyConnectors().iterator();
+        while ( it.hasNext() )
+        {
+            ProxyConnector proxyConfig = it.next();
+            String key = proxyConfig.getSourceRepoId();
+
+            java.util.List<ProxyConnector> connectors = proxyConnectorMap.get( key
);
+            if ( connectors == null )
+            {
+                connectors = new ArrayList<ProxyConnector>();
+                proxyConnectorMap.put( key, connectors );
+            }
+
+            connectors.add( proxyConfig );
+
+            Collections.sort( connectors, ProxyConnectorOrderComparator.getInstance() );
+        }
+
+        return proxyConnectorMap;
+    }
+
+    public ProxyConnector findProxyConnector( String sourceId, String targetId )
+        throws RepositoryAdminException
+    {
+        return getProxyConnector(
+            findProxyConnector( sourceId, targetId, getArchivaConfiguration().getConfiguration()
) );
+    }
+
+    private ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId,
+                                                            Configuration configuration )
     {
         if ( StringUtils.isBlank( sourceId ) )
         {
@@ -169,6 +207,7 @@ public class DefaultProxyConnectorAdmin
 
     protected ProxyConnectorConfiguration getProxyConnectorConfiguration( ProxyConnector
proxyConnector )
     {
+        /*
         ProxyConnectorConfiguration proxyConnectorConfiguration = new ProxyConnectorConfiguration();
         proxyConnectorConfiguration.setOrder( proxyConnector.getOrder() );
         proxyConnectorConfiguration.setBlackListPatterns(
@@ -181,7 +220,13 @@ public class DefaultProxyConnectorAdmin
         proxyConnectorConfiguration.setProxyId( proxyConnector.getProxyId() );
         proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
         proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
-        return proxyConnectorConfiguration;
+        return proxyConnectorConfiguration;*/
+        return new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class
);
+    }
+
+    protected ProxyConnector getProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration
)
+    {
+        return new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class
);
     }
 
     protected void validateProxyConnector( ProxyConnector proxyConnector )

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java
Wed Sep  7 20:33:48 2011
@@ -22,6 +22,7 @@ import org.apache.archiva.admin.AuditInf
 import org.apache.archiva.admin.repository.RepositoryAdminException;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * No update method here as id is : sourceRepoId and targetRepoId, use delete then add.
@@ -43,4 +44,10 @@ public interface ProxyConnectorAdmin
     Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation
)
         throws RepositoryAdminException;
 
+    Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
+        throws RepositoryAdminException;
+
+    ProxyConnector findProxyConnector( String sourceId, String targetId )
+        throws RepositoryAdminException;
+
 }

Copied: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorOrderComparator.java
(from r1166163, archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java)
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorOrderComparator.java?p2=archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorOrderComparator.java&p1=archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java&r1=1166163&r2=1166391&rev=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorConfigurationOrderComparator.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorOrderComparator.java
Wed Sep  7 20:33:48 2011
@@ -1,5 +1,4 @@
-package org.apache.maven.archiva.configuration.functors;
-
+package org.apache.archiva.admin.repository.proxyconnector;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +8,7 @@ package org.apache.maven.archiva.configu
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -19,21 +18,18 @@ package org.apache.maven.archiva.configu
  * under the License.
  */
 
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-
 import java.util.Comparator;
 
 /**
- * ProxyConnectorConfigurationOrderComparator 
- *
- * @version $Id$
+ * @author Olivier Lamy
+ * @since 1.4
  */
-public class ProxyConnectorConfigurationOrderComparator
-    implements Comparator<ProxyConnectorConfiguration>
+public class ProxyConnectorOrderComparator
+    implements Comparator<ProxyConnector>
 {
-    private static ProxyConnectorConfigurationOrderComparator INSTANCE = new ProxyConnectorConfigurationOrderComparator();
-    
-    public int compare( ProxyConnectorConfiguration o1, ProxyConnectorConfiguration o2 )
+    private static ProxyConnectorOrderComparator INSTANCE = new ProxyConnectorOrderComparator();
+
+    public int compare( ProxyConnector o1, ProxyConnector o2 )
     {
         if ( o1 == null && o2 == null )
         {
@@ -56,7 +52,7 @@ public class ProxyConnectorConfiguration
         {
             return 1;
         }
-        
+
         if ( o1.getOrder() != 0 && o2.getOrder() == 0 )
         {
             return -1;
@@ -65,7 +61,7 @@ public class ProxyConnectorConfiguration
         return o1.getOrder() - o2.getOrder();
     }
 
-    public static ProxyConnectorConfigurationOrderComparator getInstance()
+    public static ProxyConnectorOrderComparator getInstance()
     {
         return INSTANCE;
     }

Copied: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorSelectionPredicate.java
(from r1166163, archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java)
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorSelectionPredicate.java?p2=archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorSelectionPredicate.java&p1=archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java&r1=1166163&r2=1166391&rev=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/functors/ProxyConnectorSelectionPredicate.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorSelectionPredicate.java
Wed Sep  7 20:33:48 2011
@@ -1,5 +1,4 @@
-package org.apache.maven.archiva.configuration.functors;
-
+package org.apache.archiva.admin.repository.proxyconnector;
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +8,7 @@ package org.apache.maven.archiva.configu
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -21,12 +20,10 @@ package org.apache.maven.archiva.configu
 
 import org.apache.commons.collections.Predicate;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 
 /**
- * ProxyConnectorPredicate 
- *
- * @version $Id$
+ * @author Olivier Lamy
+ * @since 1.4
  */
 public class ProxyConnectorSelectionPredicate
     implements Predicate
@@ -45,14 +42,13 @@ public class ProxyConnectorSelectionPred
     {
         boolean satisfies = false;
 
-        if ( object instanceof ProxyConnectorConfiguration )
+        if ( object instanceof ProxyConnector )
         {
-            ProxyConnectorConfiguration connector = (ProxyConnectorConfiguration) object;
-            return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) &&
StringUtils
-                .equals( targetId, connector.getTargetRepoId() ) );
+            ProxyConnector connector = (ProxyConnector) object;
+            return ( StringUtils.equals( sourceId, connector.getSourceRepoId() ) &&
StringUtils.equals( targetId,
+                                                                                        
               connector.getTargetRepoId() ) );
         }
 
         return satisfies;
     }
-
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/DefaultRemoteRepositoryAdmin.java
Wed Sep  7 20:33:48 2011
@@ -29,7 +29,9 @@ import org.apache.maven.archiva.configur
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author Olivier Lamy
@@ -159,6 +161,19 @@ public class DefaultRemoteRepositoryAdmi
         return Boolean.TRUE;
     }
 
+    public Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
+        throws RepositoryAdminException
+    {
+        java.util.Map<String, RemoteRepository> map = new HashMap<String, RemoteRepository>();
+
+        for ( RemoteRepository repo : getRemoteRepositories() )
+        {
+            map.put( repo.getId(), repo );
+        }
+
+        return map;
+    }
+
     private RemoteRepositoryConfiguration getRemoteRepositoryConfiguration( RemoteRepository
remoteRepository )
     {
         RemoteRepositoryConfiguration remoteRepositoryConfiguration = new RemoteRepositoryConfiguration();

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/remote/RemoteRepositoryAdmin.java
Wed Sep  7 20:33:48 2011
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.AuditInf
 import org.apache.archiva.admin.repository.RepositoryAdminException;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author Olivier Lamy
@@ -44,4 +45,7 @@ public interface RemoteRepositoryAdmin
 
     Boolean updateRemoteRepository( RemoteRepository remoteRepository, AuditInformation auditInformation
)
         throws RepositoryAdminException;
+
+    Map<String, RemoteRepository> getRemoteRepositoriesAsMap()
+        throws RepositoryAdminException;
 }

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java
Wed Sep  7 20:33:48 2011
@@ -23,6 +23,8 @@ import org.apache.archiva.admin.reposito
 import org.apache.archiva.audit.AuditEvent;
 import org.junit.Test;
 
+import java.util.Arrays;
+
 /**
  * @author Olivier Lamy
  */
@@ -81,12 +83,15 @@ public class ProxyConnectorAdminTest
         ProxyConnector proxyConnector = new ProxyConnector();
         proxyConnector.setSourceRepoId( "snapshots" );
         proxyConnector.setTargetRepoId( "central" );
+        proxyConnector.setWhiteListPatterns( Arrays.asList( "foo", "bar" ) );
         proxyConnectorAdmin.addProxyConnector( proxyConnector, getFakeAuditInformation()
);
 
         assertFalse( proxyConnectorAdmin.getProxyConnectors().isEmpty() );
         assertEquals( 3, proxyConnectorAdmin.getProxyConnectors().size() );
 
         assertNotNull( proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ) );
+        assertEquals( Arrays.asList( "foo", "bar" ),
+                      proxyConnectorAdmin.getProxyConnector( "snapshots", "central" ).getWhiteListPatterns()
);
 
         proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getFakeAuditInformation()
);
 
@@ -123,4 +128,12 @@ public class ProxyConnectorAdminTest
         mockAuditListener.clearEvents();
     }
 
+    @Test
+    public void findProxyConnector()
+        throws Exception
+    {
+        ProxyConnector proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal",
"central" );
+        assertNotNull( proxyConnector );
+    }
+
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorAction.java
Wed Sep  7 20:33:48 2011
@@ -19,29 +19,25 @@ package org.apache.maven.archiva.web.act
  * under the License.
  */
 
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
-import org.apache.commons.collections.CollectionUtils;
-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.IndeterminateConfigurationException;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
-import org.apache.maven.archiva.configuration.functors.ProxyConnectorSelectionPredicate;
 import org.apache.maven.archiva.web.action.AbstractActionSupport;
 import org.codehaus.plexus.redback.rbac.Resource;
-import org.codehaus.plexus.registry.RegistryException;
-
-import java.util.List;
-import java.util.Map;
 import org.codehaus.redback.integration.interceptor.SecureAction;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
 import javax.inject.Inject;
+import java.util.List;
+import java.util.Map;
 
 /**
- * AbstractProxyConnectorAction 
+ * AbstractProxyConnectorAction
  *
  * @version $Id$
  */
@@ -52,7 +48,13 @@ public abstract class AbstractProxyConne
     public static final String DIRECT_CONNECTION = "(direct connection)";
 
     @Inject
-    protected ArchivaConfiguration archivaConfiguration;
+    private ProxyConnectorAdmin proxyConnectorAdmin;
+
+    @Inject
+    private RemoteRepositoryAdmin remoteRepositoryAdmin;
+
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
 
     public SecureActionBundle getSecureActionBundle()
         throws SecureActionException
@@ -65,17 +67,15 @@ public abstract class AbstractProxyConne
         return bundle;
     }
 
-    public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
-    {
-        this.archivaConfiguration = archivaConfiguration;
-    }
 
-    protected void addProxyConnector( ProxyConnectorConfiguration proxyConnector )
+    protected void addProxyConnector( ProxyConnector proxyConnector )
+        throws RepositoryAdminException
     {
-        getConfig().addProxyConnector( proxyConnector );
+        getProxyConnectorAdmin().addProxyConnector( proxyConnector, getAuditInformation()
);
     }
 
-    protected ProxyConnectorConfiguration findProxyConnector( String sourceId, String targetId
)
+    protected ProxyConnector findProxyConnector( String sourceId, String targetId )
+        throws RepositoryAdminException
     {
         if ( StringUtils.isBlank( sourceId ) )
         {
@@ -87,50 +87,59 @@ public abstract class AbstractProxyConne
             return null;
         }
 
-        ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate(
sourceId, targetId );
-        return (ProxyConnectorConfiguration) CollectionUtils.find( getConfig().getProxyConnectors(),
selectedProxy );
+        return getProxyConnectorAdmin().findProxyConnector( sourceId, targetId );
     }
 
-    protected Configuration getConfig()
+    protected Map<String, List<ProxyConnector>> createProxyConnectorMap()
+        throws RepositoryAdminException
     {
-        return this.archivaConfiguration.getConfiguration();
+        return getProxyConnectorAdmin().getProxyConnectorAsMap();
     }
 
-    protected Map<String, List<ProxyConnectorConfiguration>> createProxyConnectorMap()
+    protected void removeConnector( String sourceId, String targetId )
+        throws RepositoryAdminException
     {
-        return getConfig().getProxyConnectorAsMap();
+        ProxyConnector proxyConnector = findProxyConnector( sourceId, targetId );
+        if ( proxyConnector != null )
+        {
+            getProxyConnectorAdmin().deleteProxyConnector( proxyConnector, getAuditInformation()
);
+        }
     }
 
-    protected void removeConnector( String sourceId, String targetId )
+    protected void removeProxyConnector( ProxyConnector connector )
+        throws RepositoryAdminException
     {
-        ProxyConnectorSelectionPredicate selectedProxy = new ProxyConnectorSelectionPredicate(
sourceId, targetId );
-        NotPredicate notSelectedProxy = new NotPredicate( selectedProxy );
-        CollectionUtils.filter( getConfig().getProxyConnectors(), notSelectedProxy );
+        getProxyConnectorAdmin().deleteProxyConnector( connector, getAuditInformation() );
     }
 
-    protected void removeProxyConnector( ProxyConnectorConfiguration connector )
+
+    public ProxyConnectorAdmin getProxyConnectorAdmin()
     {
-        getConfig().removeProxyConnector( connector );
+        return proxyConnectorAdmin;
     }
 
-    protected String saveConfiguration()
+    public void setProxyConnectorAdmin( ProxyConnectorAdmin proxyConnectorAdmin )
     {
-        try
-        {
-            archivaConfiguration.save( getConfig() );
-            addActionMessage( "Successfully saved configuration" );
-        }
-        catch ( RegistryException e )
-        {
-            addActionError( "Unable to save configuration: " + e.getMessage() );
-            return INPUT;
-        }
-        catch ( IndeterminateConfigurationException e )
-        {
-            addActionError( e.getMessage() );
-            return INPUT;
-        }
+        this.proxyConnectorAdmin = proxyConnectorAdmin;
+    }
+
+    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
+    {
+        return remoteRepositoryAdmin;
+    }
+
+    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
+    {
+        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
+    }
 
-        return SUCCESS;
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin
)
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
     }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
Wed Sep  7 20:33:48 2011
@@ -19,27 +19,26 @@ package org.apache.maven.archiva.web.act
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.google.common.collect.Lists;
-import org.apache.archiva.audit.AuditListener;
+import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+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 org.apache.maven.archiva.policies.PreDownloadPolicy;
 
-import com.opensymphony.xwork2.Preparable;
-
 import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
- * AbstractProxyConnectorFormAction - generic fields and methods for either add or edit actions
related with the 
- * Proxy Connector. 
+ * AbstractProxyConnectorFormAction - generic fields and methods for either add or edit actions
related with the
+ * Proxy Connector.
  *
  * @version $Id$
  */
@@ -94,8 +93,10 @@ public abstract class AbstractProxyConne
     /**
      * The model for this action.
      */
-    protected ProxyConnectorConfiguration connector;
+    protected ProxyConnector connector;
 
+    @Inject
+    private ArchivaConfiguration archivaConfiguration;
 
     @PostConstruct
     public void initialize()
@@ -107,38 +108,38 @@ public abstract class AbstractProxyConne
     }
 
     protected List<String> escapePatterns( List<String> patterns )
-    {   
+    {
         List<String> escapedPatterns = new ArrayList<String>();
-        if( patterns != null )
+        if ( patterns != null )
         {
-            for( String pattern : patterns )
+            for ( String pattern : patterns )
             {
                 escapedPatterns.add( StringUtils.replace( pattern, "\\", "\\\\" ) );
             }
         }
-        
+
         return escapedPatterns;
     }
-    
+
     protected List<String> unescapePatterns( List<String> patterns )
     {
         List<String> rawPatterns = new ArrayList<String>();
-        if( patterns != null )
+        if ( patterns != null )
         {
-            for( String pattern : patterns )
+            for ( String pattern : patterns )
             {
                 rawPatterns.add( StringUtils.replace( pattern, "\\\\", "\\" ) );
             }
         }
-        
+
         return rawPatterns;
     }
-    
+
     private String escapePattern( String pattern )
     {
         return StringUtils.replace( pattern, "\\", "\\\\" );
     }
-        
+
     public String addBlackListPattern()
     {
         String pattern = getBlackListPattern();
@@ -147,17 +148,17 @@ public abstract class AbstractProxyConne
         {
             addActionError( "Cannot add a blank black list pattern." );
         }
-        
+
         if ( !hasActionErrors() )
         {
             getConnector().getBlackListPatterns().add( escapePattern( pattern ) );
             setBlackListPattern( null );
         }
-        
+
         return INPUT;
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public String addProperty()
     {
         String key = getPropertyKey();
@@ -197,7 +198,7 @@ public abstract class AbstractProxyConne
             getConnector().getWhiteListPatterns().add( escapePattern( pattern ) );
             setWhiteListPattern( null );
         }
-        
+
         return INPUT;
     }
 
@@ -206,7 +207,7 @@ public abstract class AbstractProxyConne
         return blackListPattern;
     }
 
-    public ProxyConnectorConfiguration getConnector()
+    public ProxyConnector getConnector()
     {
         return connector;
     }
@@ -252,6 +253,7 @@ public abstract class AbstractProxyConne
     }
 
     public void prepare()
+        throws RepositoryAdminException
     {
         proxyIdOptions = createNetworkProxyOptions();
         managedRepoIdList = createManagedRepoOptions();
@@ -262,14 +264,14 @@ public abstract class AbstractProxyConne
     public String removeBlackListPattern()
     {
         String pattern = getPattern();
-        
+
         if ( StringUtils.isBlank( pattern ) )
         {
             addActionError( "Cannot remove a blank black list pattern." );
         }
 
-        if ( !getConnector().getBlackListPatterns().contains( pattern ) && 
-            !getConnector().getBlackListPatterns().contains( StringUtils.replace( pattern,
"\\", "\\\\" ) ) )
+        if ( !getConnector().getBlackListPatterns().contains( pattern )
+            && !getConnector().getBlackListPatterns().contains( StringUtils.replace(
pattern, "\\", "\\\\" ) ) )
         {
             addActionError( "Non-existant black list pattern [" + pattern + "], no black
list pattern removed." );
         }
@@ -319,8 +321,8 @@ public abstract class AbstractProxyConne
             addActionError( "Cannot remove a blank white list pattern." );
         }
 
-        if ( !getConnector().getWhiteListPatterns().contains( pattern ) &&
-                !getConnector().getWhiteListPatterns().contains( StringUtils.replace( pattern,
"\\", "\\\\" ) ) )
+        if ( !getConnector().getWhiteListPatterns().contains( pattern )
+            && !getConnector().getWhiteListPatterns().contains( StringUtils.replace(
pattern, "\\", "\\\\" ) ) )
         {
             addActionError( "Non-existant white list pattern [" + pattern + "], no white
list pattern removed." );
         }
@@ -341,7 +343,7 @@ public abstract class AbstractProxyConne
         this.blackListPattern = blackListPattern;
     }
 
-    public void setConnector( ProxyConnectorConfiguration connector )
+    public void setConnector( ProxyConnector connector )
     {
         this.connector = connector;
     }
@@ -387,8 +389,9 @@ public abstract class AbstractProxyConne
     }
 
     protected List<String> createManagedRepoOptions()
+        throws RepositoryAdminException
     {
-        return new ArrayList<String>( getConfig().getManagedRepositoriesAsMap().keySet()
);
+        return new ArrayList<String>( getManagedRepositoryAdmin().getManagedRepositoriesAsMap().keySet()
);
     }
 
     protected List<String> createNetworkProxyOptions()
@@ -396,7 +399,7 @@ public abstract class AbstractProxyConne
         List<String> options = new ArrayList<String>();
 
         options.add( DIRECT_CONNECTION );
-        options.addAll( getConfig().getNetworkProxiesAsMap().keySet() );
+        options.addAll( archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().keySet()
);
 
         return options;
     }
@@ -413,11 +416,12 @@ public abstract class AbstractProxyConne
     }
 
     protected List<String> createRemoteRepoOptions()
+        throws RepositoryAdminException
     {
-        return new ArrayList<String>( getConfig().getRemoteRepositoriesAsMap().keySet()
);
+        return new ArrayList<String>( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap().keySet()
);
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     protected void validateConnector()
     {
         if ( connector.getPolicies() == null )
@@ -439,8 +443,8 @@ public abstract class AbstractProxyConne
                     continue;
                 }
 
-                Map<String, Object> properties = connector.getProperties();
-                for ( Map.Entry<String, Object> entry2 : properties.entrySet())
+                Map<String, String> properties = connector.getProperties();
+                for ( Map.Entry<String, String> entry2 : properties.entrySet() )
                 {
                     Object value = entry2.getValue();
                     if ( value.getClass().isArray() )
@@ -473,11 +477,21 @@ public abstract class AbstractProxyConne
 
                 if ( !options.contains( value ) )
                 {
-                    addActionError( "Value of [" + value + "] is invalid for policy [" +
policyId + "], valid values: "
-                        + options );
+                    addActionError(
+                        "Value of [" + value + "] is invalid for policy [" + policyId + "],
valid values: " + options );
                     continue;
                 }
             }
         }
     }
+
+    public ArchivaConfiguration getArchivaConfiguration()
+    {
+        return archivaConfiguration;
+    }
+
+    public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
+    {
+        this.archivaConfiguration = archivaConfiguration;
+    }
 }

Modified: archiva/trunk/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/pom.xml?rev=1166391&r1=1166390&r2=1166391&view=diff
==============================================================================
--- archiva/trunk/pom.xml (original)
+++ archiva/trunk/pom.xml Wed Sep  7 20:33:48 2011
@@ -461,6 +461,11 @@
         <version>1.2.0</version>
       </dependency>
       <dependency>
+        <groupId>net.sf.beanlib</groupId>
+        <artifactId>beanlib</artifactId>
+        <version>5.0.2beta</version>
+      </dependency>
+      <dependency>
         <groupId>commons-codec</groupId>
         <artifactId>commons-codec</artifactId>
         <version>1.4</version>



Mime
View raw message