]> source.dussan.org Git - archiva.git/commitdiff
more cleanup of direct use of archiva-configuration
authorOlivier Lamy <olamy@apache.org>
Wed, 14 Sep 2011 10:21:39 +0000 (10:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 14 Sep 2011 10:21:39 +0000 (10:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170511 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java

index dfcb7b7557db579eb17262115ca0110494bd1c10..138b92fdd78ab08f317c0293c15eb259018a1613 100644 (file)
@@ -54,7 +54,6 @@ import java.util.List;
 public class MergeAction
     extends AbstractActionSupport
     implements Validateable, Preparable, Auditable
-
 {
 
     @Inject
index fd9dfc8b56d740a688fbce99719379502cc13191..7de6c57642f0914e2e220b9f979017915750cb97 100644 (file)
@@ -20,6 +20,9 @@ package org.apache.maven.archiva.web.action;
  */
 
 import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.indexer.search.RepositorySearch;
 import org.apache.archiva.indexer.search.RepositorySearchException;
 import org.apache.archiva.indexer.search.SearchFields;
@@ -31,9 +34,6 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.RepositorySession;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.common.utils.VersionUtil;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.struts2.ServletActionContext;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
@@ -56,14 +56,15 @@ public class SearchAction
     extends AbstractRepositoryBasedAction
     implements Preparable
 {
+
+    @Inject
+    protected ManagedRepositoryAdmin managedRepositoryAdmin;
+
     /**
      * Query string.
      */
     private String q;
 
-    // FIXME olamy WTF here??
-    private ArchivaConfiguration archivaConfiguration;
-
     /**
      * The Search Results.
      */
@@ -448,22 +449,13 @@ public class SearchAction
         this.completeQueryString = completeQueryString;
     }
 
-    public ArchivaConfiguration getArchivaConfiguration()
-    {
-        return archivaConfiguration;
-    }
-
-    public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
-    {
-        this.archivaConfiguration = archivaConfiguration;
-    }
-
-    public Map<String, ManagedRepositoryConfiguration> getManagedRepositories()
+    public Map<String, ManagedRepository> getManagedRepositories() throws RepositoryAdminException
     {
-        return getArchivaConfiguration().getConfiguration().getManagedRepositoriesAsMap();
+        return managedRepositoryAdmin.getManagedRepositoriesAsMap();
     }
 
-    public void setManagedRepositories( Map<String, ManagedRepositoryConfiguration> managedRepositories )
+    // wtf : does nothing ??
+    public void setManagedRepositories( Map<String, ManagedRepository> managedRepositories )
     {
     }
 
@@ -582,4 +574,14 @@ public class SearchAction
     {
         this.infoMessage = infoMessage;
     }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
 }
index cb0c5aca087897186d3956e07ded7a970965a7d7..f54f8847ab411efbae6f67362fa7d8365b12325a 100644 (file)
@@ -20,6 +20,8 @@ package org.apache.maven.archiva.web.action;
  */
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
 import org.apache.archiva.indexer.search.RepositorySearch;
 import org.apache.archiva.indexer.search.SearchFields;
 import org.apache.archiva.indexer.search.SearchResultHit;
@@ -30,8 +32,8 @@ import org.apache.archiva.metadata.model.ArtifactMetadata;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.RepositorySession;
 import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.archiva.security.UserRepositories;
+import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.easymock.MockControl;
 
 import java.util.ArrayList;
@@ -56,6 +58,10 @@ public class SearchActionTest
 
     private MockControl searchControl;
 
+    private MockControl repoAdminControl;
+
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
     private RepositorySearch search;
 
     private static final String TEST_CHECKSUM = "afbcdeaadbcffceabbba1";
@@ -90,7 +96,12 @@ public class SearchActionTest
         searchControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER );
         search = (RepositorySearch) searchControl.getMock();
 
-        action.setArchivaConfiguration( archivaConfig );
+        repoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        managedRepositoryAdmin = (ManagedRepositoryAdmin) repoAdminControl.getMock();
+
+        //( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfig );
+
+        action.setManagedRepositoryAdmin( managedRepositoryAdmin );
         action.setUserRepositories( userRepos );
         action.setNexusSearch( search );
     }