From f561846380b2fab5c2c5fee41dbddee4c6d5c701 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 14 Sep 2011 10:21:39 +0000 Subject: [PATCH] more cleanup of direct use of archiva-configuration git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170511 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/archiva/web/action/MergeAction.java | 1 - .../archiva/web/action/SearchAction.java | 40 ++++++++++--------- .../archiva/web/action/SearchActionTest.java | 15 ++++++- 3 files changed, 34 insertions(+), 22 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java index dfcb7b755..138b92fdd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/MergeAction.java @@ -54,7 +54,6 @@ import java.util.List; public class MergeAction extends AbstractActionSupport implements Validateable, Preparable, Auditable - { @Inject diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java index fd9dfc8b5..7de6c5764 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/SearchAction.java @@ -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 getManagedRepositories() + public Map getManagedRepositories() throws RepositoryAdminException { - return getArchivaConfiguration().getConfiguration().getManagedRepositoriesAsMap(); + return managedRepositoryAdmin.getManagedRepositoriesAsMap(); } - public void setManagedRepositories( Map managedRepositories ) + // wtf : does nothing ?? + public void setManagedRepositories( Map managedRepositories ) { } @@ -582,4 +574,14 @@ public class SearchAction { this.infoMessage = infoMessage; } + + public ManagedRepositoryAdmin getManagedRepositoryAdmin() + { + return managedRepositoryAdmin; + } + + public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin ) + { + this.managedRepositoryAdmin = managedRepositoryAdmin; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java index cb0c5aca0..f54f8847a 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/SearchActionTest.java @@ -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 ); } -- 2.39.5