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
This commit is contained in:
Olivier Lamy 2011-09-14 10:21:39 +00:00
parent da35eac6b5
commit f561846380
3 changed files with 34 additions and 22 deletions

View File

@ -54,7 +54,6 @@ import java.util.List;
public class MergeAction
extends AbstractActionSupport
implements Validateable, Preparable, Auditable
{
@Inject

View 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()
public Map<String, ManagedRepository> getManagedRepositories() throws RepositoryAdminException
{
return archivaConfiguration;
return managedRepositoryAdmin.getManagedRepositoriesAsMap();
}
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
{
this.archivaConfiguration = archivaConfiguration;
}
public Map<String, ManagedRepositoryConfiguration> getManagedRepositories()
{
return getArchivaConfiguration().getConfiguration().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;
}
}

View 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 );
}