xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="nexusRepositorySearch" class="org.apache.archiva.indexer.search.NexusRepositorySearch">
- <constructor-arg ref="nexusIndexer"/>
+ <constructor-arg ref="nexusIndexer#archiva"/>
<constructor-arg ref="archivaConfiguration"/>
</bean>
</beans>
\ No newline at end of file
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="indexerConsumer" class="org.apache.archiva.consumers.lucene.NexusIndexerConsumer">
- <constructor-arg ref="nexusIndexer"/>
+ <constructor-arg ref="nexusIndexer#archiva"/>
<constructor-arg ref="indexPacker"/>
<constructor-arg ref="indexerEngine"/>
</bean>
</check>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>merge</id>
+ <goals>
+ <goal>merge-descriptors</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
+ <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
this.archivaConfig = archivaConfig;
}
+ /**
+ * @see RepositorySearch#search(String, List, String, SearchResultLimits)
+ */
public SearchResults search( String principal, List<String> selectedRepos, String term, SearchResultLimits limits )
throws RepositorySearchException
{
}
}
}
-
+
+ /**
+ * @see RepositorySearch#search(String, SearchFields, SearchResultLimits)
+ */
public SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits )
throws RepositorySearchException
{
private SearchResults paginate( SearchResultLimits limits, SearchResults results )
{
- SearchResults paginated = new SearchResults();
-
+ SearchResults paginated = new SearchResults();
int fetchCount = limits.getPageSize();
int offset = ( limits.getSelectedPage() * limits.getPageSize() );
-
+
+ if( fetchCount > results.getTotalHits() )
+ {
+ fetchCount = results.getTotalHits();
+ }
+
// Goto offset.
- if ( offset <= results.getTotalHits() )
+ if ( offset < results.getTotalHits() )
{
// only process if the offset is within the hit count.
for ( int i = 0; i < fetchCount; i++ )
break;
}
- SearchResultHit hit = results.getHits().get( ( offset + i ) - 1 );
+ SearchResultHit hit = results.getHits().get( ( offset + i ) );
if( hit != null )
{
String id = SearchUtil.getHitId( hit.getGroupId(), hit.getArtifactId() );
--- /dev/null
+<?xml version="1.0" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "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
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.sonatype.nexus.index.NexusIndexer</role>
+ <role-hint>archiva</role-hint>
+ <implementation>org.sonatype.nexus.index.DefaultNexusIndexer</implementation>
+ <description>The default nexus indexer implementation.</description>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <isolated-realm>false</isolated-realm>
+ <requirements>
+ <requirement>
+ <role>org.sonatype.nexus.index.scan.Scanner</role>
+ <role-hint>default</role-hint>
+ <field-name>scanner</field-name>
+ </requirement>
+ <requirement>
+ <role>org.sonatype.nexus.index.search.SearchEngine</role>
+ <role-hint>default</role-hint>
+ <field-name>searcher</field-name>
+ </requirement>
+ <requirement>
+ <role>org.sonatype.nexus.index.creator.IndexerEngine</role>
+ <role-hint>default</role-hint>
+ <field-name>indexerEngine</field-name>
+ </requirement>
+ <requirement>
+ <role>org.sonatype.nexus.index.QueryCreator</role>
+ <role-hint>default</role-hint>
+ <field-name>queryCreator</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ </components>
+
+</component-set>
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="nexusSearch" class="org.apache.archiva.indexer.search.NexusRepositorySearch">
- <constructor-arg ref="nexusIndexer"/>
+ <constructor-arg ref="nexusIndexer#archiva"/>
<constructor-arg ref="archivaConfiguration"/>
</bean>
</beans>
\ No newline at end of file
selectedRepos.add( TEST_REPO_1 );
// page 1
- SearchResultLimits limits = new SearchResultLimits( 1 );
+ SearchResultLimits limits = new SearchResultLimits( 0 );
limits.setPageSize( 1 );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
archivaConfigControl.reset();
// page 2
- limits = new SearchResultLimits( 2 );
+ limits = new SearchResultLimits( 1 );
limits.setPageSize( 1 );
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
import java.util.List;
import java.util.Map;
+import org.apache.archiva.indexer.search.RepositorySearch;
+import org.apache.archiva.indexer.search.RepositorySearchException;
import org.apache.archiva.indexer.util.SearchUtil;
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.database.constraints.UniqueVersionConstraint;
import org.apache.maven.archiva.indexer.search.SearchResultHit;
+import org.apache.struts2.ServletActionContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* Search all indexed fields by the given criteria.
private boolean fromResultsPage;
+ private RepositorySearch nexusSearch;
+
public boolean isFromResultsPage()
{
return fromResultsPage;
else
{
completeQueryString = "";
- results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits );
+ //results = crossRepoSearch.searchForTerm( getPrincipal(), selectedRepos, q, limits );
+ try
+ {
+ results = getNexusSearch().search( getPrincipal(), selectedRepos, q, limits );
+ }
+ catch ( RepositorySearchException e )
+ {
+ addActionError( e.getMessage() );
+ return ERROR;
+ }
}
}
{
this.className = className;
}
+
+ public RepositorySearch getNexusSearch()
+ {
+ if( nexusSearch == null )
+ {
+ WebApplicationContext wac =
+ WebApplicationContextUtils.getRequiredWebApplicationContext( ServletActionContext.getServletContext() );
+ nexusSearch = ( RepositorySearch ) wac.getBean( "nexusSearch" );
+ }
+ return nexusSearch;
+ }
+
+ public void setNexusSearch( RepositorySearch nexusSearch )
+ {
+ this.nexusSearch = nexusSearch;
+ }
}