mirror of https://github.com/apache/archiva.git
Extracting indexing api as single module
[MRM-1964] Step to move all indexing features behind archiva API
This commit is contained in:
parent
77c375434f
commit
2ab8942ccf
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-base</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>archiva-indexer-api</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>Archiva Base :: Indexer API</name>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-model</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.rat</groupId>
|
||||
<artifactId>apache-rat-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>src/test/maven-search-test-repo*/**</exclude>
|
||||
<exclude>src/test/repo-release*/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>org.apache.archiva.indexer.api</Bundle-SymbolicName>
|
||||
<Bundle-Version>${project.version}</Bundle-Version>
|
||||
<Export-Package>
|
||||
org.apache.archiva.indexer.*;version=${project.version};-split-package:=merge-first
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
javax.annotation,
|
||||
javax.inject,
|
||||
org.apache.commons.lang*;version="[2.4,3)",
|
||||
org.slf4j;resolution:=optional
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
|
||||
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
|
||||
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
|
||||
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
|
||||
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
|
||||
<archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id>
|
||||
<openjpa.Log>${openjpa.Log}</openjpa.Log>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -18,7 +18,8 @@ package org.apache.archiva.indexer.search;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.index.ArtifactInfo;
|
||||
import org.apache.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -28,5 +29,5 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ArtifactInfoFilter
|
||||
{
|
||||
boolean addArtifactInResult( ArtifactInfo artifact, Map<String, SearchResultHit> currentResult );
|
||||
boolean addArtifactInResult( ArchivaArtifactModel artifact, Map<String, SearchResultHit> currentResult );
|
||||
}
|
|
@ -19,8 +19,6 @@ package org.apache.archiva.indexer.search;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -57,5 +55,5 @@ public interface RepositorySearch
|
|||
throws RepositorySearchException;
|
||||
|
||||
Set<String> getRemoteIndexingContextIds( String managedRepoId )
|
||||
throws RepositoryAdminException;
|
||||
throws RepositorySearchException;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package org.apache.archiva.indexer.util;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* SearchUtil - utility class for search.
|
||||
*/
|
||||
public class SearchUtil
|
||||
{
|
||||
public static String getHitId( String groupId, String artifactId, String classifier, String packaging )
|
||||
{
|
||||
return ( StringUtils.isBlank( groupId ) ? "" : StringUtils.trim( groupId ) ) + ":" //
|
||||
+ ( StringUtils.isBlank( artifactId ) ? "" : StringUtils.trim( artifactId ) ) + ":" //
|
||||
+ ( StringUtils.isBlank( classifier ) ? "" : StringUtils.trim( classifier ) ) + ":" //
|
||||
+ ( StringUtils.isBlank( packaging ) ? "" : StringUtils.trim( packaging ) );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?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.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:task="http://www.springframework.org/schema/task"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/task
|
||||
http://www.springframework.org/schema/task/spring-task-3.0.xsd"
|
||||
default-lazy-init="false">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="org.apache.archiva.indexer.search,org.apache.archiva.indexer.merger"/>
|
||||
|
||||
|
||||
|
||||
</beans>
|
|
@ -42,6 +42,10 @@
|
|||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-layer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-indexer-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
|||
import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||
import org.apache.archiva.indexer.util.SearchUtil;
|
||||
import org.apache.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.archiva.model.ArtifactReference;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.index.ArtifactInfo;
|
||||
import org.apache.maven.index.FlatSearchRequest;
|
||||
|
@ -407,6 +409,12 @@ public class MavenRepositorySearch
|
|||
e.getMessage() );
|
||||
continue;
|
||||
}
|
||||
catch ( RepositorySearchException e )
|
||||
{
|
||||
log.warn( "RepositorySearchException occured while accessing index of repository '{}' : {}", repo,
|
||||
e.getMessage() );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return new ArrayList<>( indexingContextIds );
|
||||
|
@ -415,11 +423,19 @@ public class MavenRepositorySearch
|
|||
|
||||
@Override
|
||||
public Set<String> getRemoteIndexingContextIds( String managedRepoId )
|
||||
throws RepositoryAdminException
|
||||
throws RepositorySearchException
|
||||
{
|
||||
Set<String> ids = new HashSet<>();
|
||||
|
||||
List<ProxyConnector> proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId );
|
||||
List<ProxyConnector> proxyConnectors = null;
|
||||
try
|
||||
{
|
||||
proxyConnectors = proxyConnectorAdmin.getProxyConnectorAsMap().get( managedRepoId );
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new RepositorySearchException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
if ( proxyConnectors == null || proxyConnectors.isEmpty() )
|
||||
{
|
||||
|
@ -486,6 +502,7 @@ public class MavenRepositorySearch
|
|||
artifactInfo.getPackaging() );
|
||||
Map<String, SearchResultHit> hitsMap = results.getHitsMap();
|
||||
|
||||
|
||||
if ( !applyArtifactInfoFilters( artifactInfo, artifactInfoFilters, hitsMap ) )
|
||||
{
|
||||
continue;
|
||||
|
@ -650,9 +667,17 @@ public class MavenRepositorySearch
|
|||
return true;
|
||||
}
|
||||
|
||||
ArchivaArtifactModel artifact = new ArchivaArtifactModel();
|
||||
artifact.setArtifactId( artifactInfo.getArtifactId() );
|
||||
artifact.setClassifier( artifactInfo.getClassifier() );
|
||||
artifact.setGroupId( artifactInfo.getGroupId() );
|
||||
artifact.setRepositoryId( artifactInfo.getRepository() );
|
||||
artifact.setVersion( artifactInfo.getVersion() );
|
||||
artifact.setChecksumMD5( artifactInfo.getMd5() );
|
||||
artifact.setChecksumSHA1( artifactInfo.getSha1() );
|
||||
for ( ArtifactInfoFilter filter : artifactInfoFilters )
|
||||
{
|
||||
if ( !filter.addArtifactInResult( artifactInfo, currentResult ) )
|
||||
if ( !filter.addArtifactInResult( artifact, currentResult ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ package org.apache.archiva.indexer.search;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.index.ArtifactInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -36,7 +36,7 @@ public class NoClassifierArtifactInfoFilter
|
|||
public static final List<? extends ArtifactInfoFilter> LIST = Arrays.asList( INSTANCE );
|
||||
|
||||
@Override
|
||||
public boolean addArtifactInResult( ArtifactInfo artifact, Map<String, SearchResultHit> currentResult )
|
||||
public boolean addArtifactInResult( ArchivaArtifactModel artifact, Map<String, SearchResultHit> currentResult )
|
||||
{
|
||||
return StringUtils.isBlank( artifact.getClassifier() );
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<module>archiva-checksum</module>
|
||||
<module>archiva-plexus-bridge</module>
|
||||
<module>archiva-policies</module>
|
||||
<module>archiva-indexer-api</module>
|
||||
<module>archiva-indexer</module>
|
||||
<module>archiva-consumers</module>
|
||||
<module>archiva-repository-layer</module>
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.archiva.indexer.merger.MergedRemoteIndexesTask;
|
|||
import org.apache.archiva.indexer.merger.MergedRemoteIndexesTaskRequest;
|
||||
import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
|
||||
import org.apache.archiva.indexer.search.RepositorySearch;
|
||||
import org.apache.archiva.indexer.search.RepositorySearchException;
|
||||
import org.apache.archiva.maven2.metadata.MavenMetadataReader;
|
||||
import org.apache.archiva.metadata.model.facets.AuditEvent;
|
||||
import org.apache.archiva.metadata.repository.storage.RelocationException;
|
||||
|
@ -60,8 +61,6 @@ import org.apache.archiva.repository.ManagedRepository;
|
|||
import org.apache.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.archiva.repository.ReleaseScheme;
|
||||
import org.apache.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.archiva.repository.RepositoryException;
|
||||
import org.apache.archiva.repository.RepositoryNotFoundException;
|
||||
import org.apache.archiva.repository.RepositoryRegistry;
|
||||
import org.apache.archiva.repository.content.maven2.RepositoryRequest;
|
||||
import org.apache.archiva.repository.events.AuditListener;
|
||||
|
@ -1348,6 +1347,7 @@ public class ArchivaDavResourceFactory
|
|||
log.debug( "Skipping repository '{}' for user '{}': {}", repository, activePrincipal,
|
||||
e.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
|
||||
repositoryGroupConfiguration.getId(), authzRepos );
|
||||
|
@ -1378,7 +1378,7 @@ public class ArchivaDavResourceFactory
|
|||
temporaryGroupIndexMap );
|
||||
return mergedRepoDir;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
catch ( RepositorySearchException e )
|
||||
{
|
||||
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
|
||||
}
|
||||
|
|
5
pom.xml
5
pom.xml
|
@ -287,6 +287,11 @@
|
|||
<artifactId>test-repository</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-indexer-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-indexer</artifactId>
|
||||
|
|
Loading…
Reference in New Issue