mirror of https://github.com/apache/archiva.git
more cleanup of direct use of archiva-configuration
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d1fe90fe66
commit
ebac483742
|
@ -28,9 +28,10 @@
|
|||
<artifactId>archiva-indexer</artifactId>
|
||||
<name>Archiva Base :: Indexer</name>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
<artifactId>archiva-repository-admin-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
|
@ -82,6 +83,16 @@
|
|||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-admin-default</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
|
|
|
@ -19,6 +19,9 @@ package org.apache.archiva.indexer.search;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
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.common.plexusbridge.MavenIndexerUtils;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||
|
@ -26,9 +29,6 @@ import org.apache.archiva.indexer.util.SearchUtil;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.index.ArtifactInfo;
|
||||
import org.apache.maven.index.FlatSearchRequest;
|
||||
import org.apache.maven.index.FlatSearchResponse;
|
||||
|
@ -62,17 +62,17 @@ public class NexusRepositorySearch
|
|||
|
||||
private NexusIndexer indexer;
|
||||
|
||||
private ArchivaConfiguration archivaConfig;
|
||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||
|
||||
private MavenIndexerUtils mavenIndexerUtils;
|
||||
|
||||
@Inject
|
||||
public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ArchivaConfiguration archivaConfig,
|
||||
public NexusRepositorySearch( PlexusSisuBridge plexusSisuBridge, ManagedRepositoryAdmin managedRepositoryAdmin,
|
||||
MavenIndexerUtils mavenIndexerUtils )
|
||||
throws PlexusSisuBridgeException
|
||||
{
|
||||
this.indexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
this.archivaConfig = archivaConfig;
|
||||
this.managedRepositoryAdmin = managedRepositoryAdmin;
|
||||
this.mavenIndexerUtils = mavenIndexerUtils;
|
||||
|
||||
}
|
||||
|
@ -283,16 +283,15 @@ public class NexusRepositorySearch
|
|||
{
|
||||
try
|
||||
{
|
||||
Configuration config = archivaConfig.getConfiguration();
|
||||
ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repo );
|
||||
ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repo );
|
||||
|
||||
if ( repoConfig != null )
|
||||
{
|
||||
String indexDir = repoConfig.getIndexDir();
|
||||
String indexDir = repoConfig.getIndexDirectory();
|
||||
File indexDirectory = null;
|
||||
if ( indexDir != null && !"".equals( indexDir ) )
|
||||
{
|
||||
indexDirectory = new File( repoConfig.getIndexDir() );
|
||||
indexDirectory = new File( repoConfig.getIndexDirectory() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -338,6 +337,10 @@ public class NexusRepositorySearch
|
|||
{
|
||||
log.warn( "IO error occured while accessing index of repository '" + repo + "' : " + e.getMessage() );
|
||||
continue;
|
||||
} catch ( RepositoryAdminException e )
|
||||
{
|
||||
log.warn( "RepositoryAdminException occured while accessing index of repository '" + repo + "' : " + e.getMessage() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return indexingContextIds;
|
||||
|
|
|
@ -31,15 +31,8 @@
|
|||
<context:annotation-config/>
|
||||
<context:component-scan base-package="org.apache.archiva.indexer.search"/>
|
||||
|
||||
<!--
|
||||
<bean id="nexusSearch" class="org.apache.archiva.indexer.search.NexusRepositorySearch">
|
||||
<constructor-arg ref="nexusIndexer"/>
|
||||
<constructor-arg ref="archivaConfiguration#default"/>
|
||||
</bean>
|
||||
-->
|
||||
<bean id="logger" class="org.apache.maven.archiva.common.utils.Slf4JPlexusLogger">
|
||||
<constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg>
|
||||
</bean>
|
||||
|
||||
<!-- <bean id="indexingContextMap" class="org.apache.archiva.indexer.IndexingContextMap"/> -->
|
||||
|
||||
</beans>
|
|
@ -20,6 +20,7 @@ package org.apache.archiva.indexer.search;
|
|||
*/
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
|
||||
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -94,7 +95,10 @@ public abstract class AbstractNexusRepositorySearch
|
|||
|
||||
archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
|
||||
|
||||
search = new NexusRepositorySearch( plexusSisuBridge, archivaConfig, mavenIndexerUtils );
|
||||
DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin();
|
||||
defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig );
|
||||
|
||||
search = new NexusRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils );
|
||||
|
||||
nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
|
||||
|
||||
|
|
Loading…
Reference in New Issue