Repository: archiva Updated Branches: refs/heads/master 77c375434 -> 2ab8942cc
Extracting indexing api as single module [MRM-1964] Step to move all indexing features behind archiva API Project: http://git-wip-us.apache.org/repos/asf/archiva/repo Commit: http://git-wip-us.apache.org/repos/asf/archiva/commit/2ab8942c Tree: http://git-wip-us.apache.org/repos/asf/archiva/tree/2ab8942c Diff: http://git-wip-us.apache.org/repos/asf/archiva/diff/2ab8942c Branch: refs/heads/master Commit: 2ab8942ccff2a85c356b878875632410a3999ce8 Parents: 77c3754 Author: Martin Stockhammer <[email protected]> Authored: Sun Nov 5 19:36:42 2017 +0100 Committer: Martin Stockhammer <[email protected]> Committed: Sun Nov 5 19:36:42 2017 +0100 ---------------------------------------------------------------------- .../archiva-base/archiva-indexer-api/pom.xml | 99 +++++ .../indexer/search/ArtifactInfoFilter.java | 33 ++ .../indexer/search/RepositorySearch.java | 59 +++ .../search/RepositorySearchException.java | 44 ++ .../archiva/indexer/search/SearchFields.java | 324 ++++++++++++++ .../archiva/indexer/search/SearchResultHit.java | 435 +++++++++++++++++++ .../indexer/search/SearchResultLimits.java | 87 ++++ .../archiva/indexer/search/SearchResults.java | 148 +++++++ .../apache/archiva/indexer/util/SearchUtil.java | 36 ++ .../main/resources/META-INF/spring-context.xml | 39 ++ .../archiva-base/archiva-indexer/pom.xml | 4 + .../indexer/search/ArtifactInfoFilter.java | 32 -- .../indexer/search/MavenRepositorySearch.java | 31 +- .../search/NoClassifierArtifactInfoFilter.java | 4 +- .../indexer/search/RepositorySearch.java | 61 --- .../search/RepositorySearchException.java | 44 -- .../archiva/indexer/search/SearchFields.java | 324 -------------- .../archiva/indexer/search/SearchResultHit.java | 435 ------------------- .../indexer/search/SearchResultLimits.java | 87 ---- .../archiva/indexer/search/SearchResults.java | 148 ------- archiva-modules/archiva-base/pom.xml | 1 + .../webdav/ArchivaDavResourceFactory.java | 6 +- pom.xml | 5 + 23 files changed, 1347 insertions(+), 1139 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/pom.xml b/archiva-modules/archiva-base/archiva-indexer-api/pom.xml new file mode 100644 index 0000000..5aec104 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java new file mode 100644 index 0000000..39c32da --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java @@ -0,0 +1,33 @@ +package org.apache.archiva.indexer.search; +/* + * 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.archiva.model.ArchivaArtifactModel; +import org.apache.archiva.model.ArtifactReference; + +import java.util.Map; + +/** + * @author Olivier Lamy + * @since 1.4-M1 + */ +public interface ArtifactInfoFilter +{ + boolean addArtifactInResult( ArchivaArtifactModel artifact, Map<String, SearchResultHit> currentResult ); +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java new file mode 100644 index 0000000..272561b --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java @@ -0,0 +1,59 @@ +package org.apache.archiva.indexer.search; + +/* + * 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 java.util.Collection; +import java.util.List; +import java.util.Set; + + +public interface RepositorySearch +{ + /** + * Quick search by won't return artifact with file extension pom + * + * @param principal + * @param selectedRepos + * @param term + * @param limits + * @param previousSearchTerms + * @return + */ + SearchResults search( String principal, List<String> selectedRepos, String term, SearchResultLimits limits, + List<String> previousSearchTerms ) + throws RepositorySearchException; + + /** + * Advanced search. + * + * @param principal + * @param searchFields + * @param limits + * @return + */ + SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits ) + throws RepositorySearchException; + + Collection<String> getAllGroupIds( String principal, List<String> selectedRepos ) + throws RepositorySearchException; + + Set<String> getRemoteIndexingContextIds( String managedRepoId ) + throws RepositorySearchException; +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java new file mode 100644 index 0000000..e3da551 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java @@ -0,0 +1,44 @@ +package org.apache.archiva.indexer.search; + +/* + * 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. + */ + +public class RepositorySearchException + extends Exception +{ + public RepositorySearchException() + { + super(); + } + + public RepositorySearchException( String msg ) + { + super( msg ); + } + + public RepositorySearchException( Throwable e ) + { + super( e ); + } + + public RepositorySearchException( String msg, Throwable e ) + { + super( msg, e ); + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java new file mode 100644 index 0000000..e5844a7 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchFields.java @@ -0,0 +1,324 @@ +package org.apache.archiva.indexer.search; + +import java.util.ArrayList; +import java.util.List; + +/* + * 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. + */ + +public class SearchFields +{ + /** + * groupId + */ + private String groupId; + + /** + * artifactId + */ + private String artifactId; + + /** + * version + */ + private String version; + + /** + * packaging (jar, war, pom, etc.) + */ + private String packaging; + + /** + * class name or package name + */ + private String className; + + /** + * repositories + */ + private List<String> repositories = new ArrayList<>(); + + + /** + * contains osgi metadata Bundle-Version if available + * + * @since 1.4-M1 + */ + private String bundleVersion; + + /** + * contains osgi metadata Bundle-SymbolicName if available + * + * @since 1.4-M1 + */ + private String bundleSymbolicName; + + /** + * contains osgi metadata Export-Package if available + * + * @since 1.4-M1 + */ + private String bundleExportPackage; + + /** + * contains osgi metadata import package if available + * + * @since 1.4-M1 + */ + private String bundleImportPackage; + + /** + * contains osgi metadata name if available + * + * @since 1.4-M1 + */ + private String bundleName; + + /** + * contains osgi metadata Export-Service if available + * + * @since 1.4-M1 + */ + private String bundleExportService; + + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M3 + */ + private String bundleRequireBundle; + + /** + * not return artifact with file extension pom + * + * @since 1.4-M2 + */ + private boolean includePomArtifacts = false; + + private String classifier; + + /** + * we use exact String matching search + * + * @since 2.1.0 + */ + private boolean exactSearch = false; + + public SearchFields() + { + // no op + } + + public SearchFields( String groupId, String artifactId, String version, String packaging, String className, + List<String> repositories ) + { + this.groupId = groupId; + this.artifactId = artifactId; + this.version = version; + this.packaging = packaging; + this.className = className; + this.repositories = repositories; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getVersion() + { + return version; + } + + public void setVersion( String version ) + { + this.version = version; + } + + public String getPackaging() + { + return packaging; + } + + public void setPackaging( String packaging ) + { + this.packaging = packaging; + } + + public String getClassName() + { + return className; + } + + public void setClassName( String className ) + { + this.className = className; + } + + public List<String> getRepositories() + { + return repositories; + } + + public void setRepositories( List<String> repositories ) + { + this.repositories = repositories; + } + + + public String getBundleVersion() + { + return bundleVersion; + } + + public void setBundleVersion( String bundleVersion ) + { + this.bundleVersion = bundleVersion; + } + + public String getBundleSymbolicName() + { + return bundleSymbolicName; + } + + public void setBundleSymbolicName( String bundleSymbolicName ) + { + this.bundleSymbolicName = bundleSymbolicName; + } + + public String getBundleExportPackage() + { + return bundleExportPackage; + } + + public void setBundleExportPackage( String bundleExportPackage ) + { + this.bundleExportPackage = bundleExportPackage; + } + + public String getBundleExportService() + { + return bundleExportService; + } + + public void setBundleExportService( String bundleExportService ) + { + this.bundleExportService = bundleExportService; + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + public String getBundleImportPackage() + { + return bundleImportPackage; + } + + public void setBundleImportPackage( String bundleImportPackage ) + { + this.bundleImportPackage = bundleImportPackage; + } + + public String getBundleName() + { + return bundleName; + } + + public void setBundleName( String bundleName ) + { + this.bundleName = bundleName; + } + + public boolean isIncludePomArtifacts() + { + return includePomArtifacts; + } + + public void setIncludePomArtifacts( boolean includePomArtifacts ) + { + this.includePomArtifacts = includePomArtifacts; + } + + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + + public boolean isExactSearch() + { + return exactSearch; + } + + public void setExactSearch( boolean exactSearch ) + { + this.exactSearch = exactSearch; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "SearchFields" ); + sb.append( "{groupId='" ).append( groupId ).append( '\'' ); + sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); + sb.append( ", version='" ).append( version ).append( '\'' ); + sb.append( ", packaging='" ).append( packaging ).append( '\'' ); + sb.append( ", className='" ).append( className ).append( '\'' ); + sb.append( ", repositories=" ).append( repositories ); + sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); + sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); + sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); + sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); + sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); + sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); + sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); + sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java new file mode 100644 index 0000000..a493431 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java @@ -0,0 +1,435 @@ +package org.apache.archiva.indexer.search; + +/* + * 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 java.util.ArrayList; +import java.util.List; + +/** + * SearchResultHit + * + */ +public class SearchResultHit +{ + // The (optional) context for this result. + private String context; + + // Basic hit, direct to non-artifact resource. + private String url; + + // Advanced hit, reference to groupId. + private String groupId; + + // Advanced hit, reference to artifactId. + private String artifactId; + + private String repositoryId = ""; + + private List<String> versions = new ArrayList<>(); + + private String packaging; + + /** + * Plugin goal prefix (only if packaging is "maven-plugin") + */ + private String prefix; + + /** + * Plugin goals (only if packaging is "maven-plugin") + */ + private List<String> goals; + + /** + * contains osgi metadata Bundle-Version if available + * + * @since 1.4-M1 + */ + private String bundleVersion; + + /** + * contains osgi metadata Bundle-SymbolicName if available + * + * @since 1.4-M1 + */ + private String bundleSymbolicName; + + /** + * contains osgi metadata Export-Package if available + * + * @since 1.4-M1 + */ + private String bundleExportPackage; + + /** + * contains osgi metadata Export-Service if available + * + * @since 1.4-M1 + */ + private String bundleExportService; + + /** + * contains osgi metadata Bundle-Description if available + * + * @since 1.4-M1 + */ + private String bundleDescription; + + /** + * contains osgi metadata Bundle-Name if available + * + * @since 1.4-M1 + */ + private String bundleName; + + /** + * contains osgi metadata Bundle-License if available + * + * @since 1.4-M1 + */ + private String bundleLicense; + + /** + * contains osgi metadata Bundle-DocURL if available + * + * @since 1.4-M1 + */ + private String bundleDocUrl; + + /** + * contains osgi metadata Import-Package if available + * + * @since 1.4-M1 + */ + private String bundleImportPackage; + + /** + * contains osgi metadata Require-Bundle if available + * + * @since 1.4-M1 + */ + private String bundleRequireBundle; + + private String classifier; + + /** + * file extension of the search result + * @since 1.4-M2 + */ + private String fileExtension; + + public String getContext() + { + return context; + } + + public void setContext( String context ) + { + this.context = context; + } + + public String getUrl() + { + return url; + } + + public void setUrl( String url ) + { + this.url = url; + } + + public String getUrlFilename() + { + return this.url.substring( this.url.lastIndexOf( '/' ) ); + } + + public String getArtifactId() + { + return artifactId; + } + + public void setArtifactId( String artifactId ) + { + this.artifactId = artifactId; + } + + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public List<String> getVersions() + { + return versions; + } + + public void setVersions( List<String> versions ) + { + this.versions = versions; + } + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + + public void addVersion( String version ) + { + versions.add( version ); + } + + public String getBundleVersion() + { + return bundleVersion; + } + + public void setBundleVersion( String bundleVersion ) + { + this.bundleVersion = bundleVersion; + } + + public String getBundleSymbolicName() + { + return bundleSymbolicName; + } + + public void setBundleSymbolicName( String bundleSymbolicName ) + { + this.bundleSymbolicName = bundleSymbolicName; + } + + public String getBundleExportPackage() + { + return bundleExportPackage; + } + + public void setBundleExportPackage( String bundleExportPackage ) + { + this.bundleExportPackage = bundleExportPackage; + } + + public String getBundleExportService() + { + return bundleExportService; + } + + public void setBundleExportService( String bundleExportService ) + { + this.bundleExportService = bundleExportService; + } + + public String getPrefix() + { + return prefix; + } + + public void setPrefix( String prefix ) + { + this.prefix = prefix; + } + + public List<String> getGoals() + { + return goals; + } + + public void setGoals( List<String> goals ) + { + this.goals = goals; + } + + public String getBundleDescription() + { + return bundleDescription; + } + + public void setBundleDescription( String bundleDescription ) + { + this.bundleDescription = bundleDescription; + } + + public String getBundleName() + { + return bundleName; + } + + public void setBundleName( String bundleName ) + { + this.bundleName = bundleName; + } + + public String getBundleLicense() + { + return bundleLicense; + } + + public void setBundleLicense( String bundleLicense ) + { + this.bundleLicense = bundleLicense; + } + + public String getBundleDocUrl() + { + return bundleDocUrl; + } + + public void setBundleDocUrl( String bundleDocUrl ) + { + this.bundleDocUrl = bundleDocUrl; + } + + public String getBundleImportPackage() + { + return bundleImportPackage; + } + + public void setBundleImportPackage( String bundleImportPackage ) + { + this.bundleImportPackage = bundleImportPackage; + } + + public String getBundleRequireBundle() + { + return bundleRequireBundle; + } + + public void setBundleRequireBundle( String bundleRequireBundle ) + { + this.bundleRequireBundle = bundleRequireBundle; + } + + public String getPackaging() + { + return packaging; + } + + public void setPackaging( String packaging ) + { + this.packaging = packaging; + } + + public String getType() + { + return getPackaging(); + } + + public String getClassifier() + { + return classifier; + } + + public void setClassifier( String classifier ) + { + this.classifier = classifier; + } + + public String getFileExtension() + { + return fileExtension; + } + + public void setFileExtension( String fileExtension ) + { + this.fileExtension = fileExtension; + } + + @Override + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append( "SearchResultHit" ); + sb.append( "{context='" ).append( context ).append( '\'' ); + sb.append( ", url='" ).append( url ).append( '\'' ); + sb.append( ", groupId='" ).append( groupId ).append( '\'' ); + sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); + sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' ); + sb.append( ", versions=" ).append( versions ); + sb.append( ", packaging='" ).append( packaging ).append( '\'' ); + sb.append( ", prefix='" ).append( prefix ).append( '\'' ); + sb.append( ", goals=" ).append( goals ); + sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); + sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); + sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); + sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); + sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' ); + sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); + sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' ); + sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' ); + sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); + sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); + sb.append( ", classifier='" ).append( classifier ).append( '\'' ); + sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); + sb.append( '}' ); + return sb.toString(); + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + + SearchResultHit that = (SearchResultHit) o; + + if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null ) + { + return false; + } + if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null ) + { + return false; + } + if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null ) + { + return false; + } + if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null ) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + int result = groupId != null ? groupId.hashCode() : 0; + result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 ); + result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 ); + result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 ); + return result; + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java new file mode 100644 index 0000000..967ecc5 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java @@ -0,0 +1,87 @@ +package org.apache.archiva.indexer.search; + +/* + * 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. + */ + +/** + * SearchResultLimits - used to provide the search some limits on how the results are returned. + * This can provide paging for the result + */ +public class SearchResultLimits +{ + /** + * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES. + * USE WITH CAUTION!! + */ + public static final int ALL_PAGES = ( -1 ); + + private int pageSize = 30; + + private int selectedPage = 0; + + /** + * @param selectedPage page selected use -1 for all pages + */ + public SearchResultLimits( int selectedPage ) + { + this.selectedPage = selectedPage; + } + + /** + * @param pageSize number of groupId:artifact per page + * @param selectedPage page selected use -1 for all pages + * @since 1.4-M4 + */ + public SearchResultLimits( int pageSize, int selectedPage ) + { + this.pageSize = pageSize; + this.selectedPage = selectedPage; + } + + public int getPageSize() + { + return pageSize; + } + + /** + * Set page size for maximum # of hits to return per page. + * + * @param pageSize size of page by # of hits. + */ + public void setPageSize( int pageSize ) + { + this.pageSize = pageSize; + } + + public int getSelectedPage() + { + return selectedPage; + } + + public void setSelectedPage( int selectedPage ) + { + this.selectedPage = selectedPage; + } + + @Override + public String toString() + { + return "SearchResultLimits{" + "pageSize=" + pageSize + ", selectedPage=" + selectedPage + '}'; + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java new file mode 100644 index 0000000..9dc650f --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/search/SearchResults.java @@ -0,0 +1,148 @@ +package org.apache.archiva.indexer.search; + +/* + * 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 java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * SearchResults + * + */ +public class SearchResults +{ + private Map<String, SearchResultHit> hits = new HashMap<>(); + + private int totalHits; + + private int totalHitsMapSize; + + private int returnedHitsCount; + + private SearchResultLimits limits; + + public SearchResults() + { + /* do nothing */ + } + + // for new RepositorySearch + public void addHit( String id, SearchResultHit hit ) + { + hits.put( id, hit ); + } + + /** + * Get the list of {@link SearchResultHit} objects. + * + * @return the list of {@link SearchResultHit} objects. + */ + public List<SearchResultHit> getHits() + { + return new ArrayList<>( hits.values() ); + } + + /** + * see SearchUtil on how to generate the key + * + * @param key + * @return + */ + public SearchResultHit getSearchResultHit( String key ) + { + return hits.get( key ); + } + + public Map<String, SearchResultHit> getHitsMap() + { + return hits; + } + + public boolean isEmpty() + { + return hits.isEmpty(); + } + + public SearchResultLimits getLimits() + { + return limits; + } + + public void setLimits( SearchResultLimits limits ) + { + this.limits = limits; + } + + public int getTotalHits() + { + return totalHits; + } + + public void setTotalHits( int totalHits ) + { + this.totalHits = totalHits; + } + + /** + * @return + * @since 1.4-M1 + */ + public int getReturnedHitsCount() + { + return returnedHitsCount; + } + + /** + * @param returnedHitsCount + * @since 1.4-M1 + */ + public void setReturnedHitsCount( int returnedHitsCount ) + { + this.returnedHitsCount = returnedHitsCount; + } + + /** + * @return + * @since 1.4-M1 + */ + public int getTotalHitsMapSize() + { + return totalHitsMapSize; + } + + /** + * @param totalHitsMapSize + * @since 1.4-M1 + */ + public void setTotalHitsMapSize( int totalHitsMapSize ) + { + this.totalHitsMapSize = totalHitsMapSize; + } + + @Override + public String toString() + { + return "SearchResults{" + "hits=" + hits + ", totalHits=" + totalHits + ", returnedHitsCount=" + + returnedHitsCount + ", limits=" + limits + '}'; + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java new file mode 100644 index 0000000..0a0c922 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/java/org/apache/archiva/indexer/util/SearchUtil.java @@ -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 ) ); + } +} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml new file mode 100644 index 0000000..ce334de --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer-api/src/main/resources/META-INF/spring-context.xml @@ -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> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index 992fcf7..ab0d897 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java deleted file mode 100644 index cecb8c8..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ArtifactInfoFilter.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.apache.archiva.indexer.search; -/* - * 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.maven.index.ArtifactInfo; - -import java.util.Map; - -/** - * @author Olivier Lamy - * @since 1.4-M1 - */ -public interface ArtifactInfoFilter -{ - boolean addArtifactInResult( ArtifactInfo artifact, Map<String, SearchResultHit> currentResult ); -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java index 892d7b7..b6f4984 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/MavenRepositorySearch.java @@ -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; } http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NoClassifierArtifactInfoFilter.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NoClassifierArtifactInfoFilter.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NoClassifierArtifactInfoFilter.java index 49feb2d..f37c874 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NoClassifierArtifactInfoFilter.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NoClassifierArtifactInfoFilter.java @@ -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() ); } http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java deleted file mode 100644 index 4879ee3..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearch.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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.archiva.admin.model.RepositoryAdminException; - -import java.util.Collection; -import java.util.List; -import java.util.Set; - - -public interface RepositorySearch -{ - /** - * Quick search by won't return artifact with file extension pom - * - * @param principal - * @param selectedRepos - * @param term - * @param limits - * @param previousSearchTerms - * @return - */ - SearchResults search( String principal, List<String> selectedRepos, String term, SearchResultLimits limits, - List<String> previousSearchTerms ) - throws RepositorySearchException; - - /** - * Advanced search. - * - * @param principal - * @param searchFields - * @param limits - * @return - */ - SearchResults search( String principal, SearchFields searchFields, SearchResultLimits limits ) - throws RepositorySearchException; - - Collection<String> getAllGroupIds( String principal, List<String> selectedRepos ) - throws RepositorySearchException; - - Set<String> getRemoteIndexingContextIds( String managedRepoId ) - throws RepositoryAdminException; -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java deleted file mode 100644 index e3da551..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/RepositorySearchException.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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. - */ - -public class RepositorySearchException - extends Exception -{ - public RepositorySearchException() - { - super(); - } - - public RepositorySearchException( String msg ) - { - super( msg ); - } - - public RepositorySearchException( Throwable e ) - { - super( e ); - } - - public RepositorySearchException( String msg, Throwable e ) - { - super( msg, e ); - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java deleted file mode 100644 index e5844a7..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchFields.java +++ /dev/null @@ -1,324 +0,0 @@ -package org.apache.archiva.indexer.search; - -import java.util.ArrayList; -import java.util.List; - -/* - * 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. - */ - -public class SearchFields -{ - /** - * groupId - */ - private String groupId; - - /** - * artifactId - */ - private String artifactId; - - /** - * version - */ - private String version; - - /** - * packaging (jar, war, pom, etc.) - */ - private String packaging; - - /** - * class name or package name - */ - private String className; - - /** - * repositories - */ - private List<String> repositories = new ArrayList<>(); - - - /** - * contains osgi metadata Bundle-Version if available - * - * @since 1.4-M1 - */ - private String bundleVersion; - - /** - * contains osgi metadata Bundle-SymbolicName if available - * - * @since 1.4-M1 - */ - private String bundleSymbolicName; - - /** - * contains osgi metadata Export-Package if available - * - * @since 1.4-M1 - */ - private String bundleExportPackage; - - /** - * contains osgi metadata import package if available - * - * @since 1.4-M1 - */ - private String bundleImportPackage; - - /** - * contains osgi metadata name if available - * - * @since 1.4-M1 - */ - private String bundleName; - - /** - * contains osgi metadata Export-Service if available - * - * @since 1.4-M1 - */ - private String bundleExportService; - - - /** - * contains osgi metadata Require-Bundle if available - * - * @since 1.4-M3 - */ - private String bundleRequireBundle; - - /** - * not return artifact with file extension pom - * - * @since 1.4-M2 - */ - private boolean includePomArtifacts = false; - - private String classifier; - - /** - * we use exact String matching search - * - * @since 2.1.0 - */ - private boolean exactSearch = false; - - public SearchFields() - { - // no op - } - - public SearchFields( String groupId, String artifactId, String version, String packaging, String className, - List<String> repositories ) - { - this.groupId = groupId; - this.artifactId = artifactId; - this.version = version; - this.packaging = packaging; - this.className = className; - this.repositories = repositories; - } - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getVersion() - { - return version; - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getPackaging() - { - return packaging; - } - - public void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - public String getClassName() - { - return className; - } - - public void setClassName( String className ) - { - this.className = className; - } - - public List<String> getRepositories() - { - return repositories; - } - - public void setRepositories( List<String> repositories ) - { - this.repositories = repositories; - } - - - public String getBundleVersion() - { - return bundleVersion; - } - - public void setBundleVersion( String bundleVersion ) - { - this.bundleVersion = bundleVersion; - } - - public String getBundleSymbolicName() - { - return bundleSymbolicName; - } - - public void setBundleSymbolicName( String bundleSymbolicName ) - { - this.bundleSymbolicName = bundleSymbolicName; - } - - public String getBundleExportPackage() - { - return bundleExportPackage; - } - - public void setBundleExportPackage( String bundleExportPackage ) - { - this.bundleExportPackage = bundleExportPackage; - } - - public String getBundleExportService() - { - return bundleExportService; - } - - public void setBundleExportService( String bundleExportService ) - { - this.bundleExportService = bundleExportService; - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getBundleImportPackage() - { - return bundleImportPackage; - } - - public void setBundleImportPackage( String bundleImportPackage ) - { - this.bundleImportPackage = bundleImportPackage; - } - - public String getBundleName() - { - return bundleName; - } - - public void setBundleName( String bundleName ) - { - this.bundleName = bundleName; - } - - public boolean isIncludePomArtifacts() - { - return includePomArtifacts; - } - - public void setIncludePomArtifacts( boolean includePomArtifacts ) - { - this.includePomArtifacts = includePomArtifacts; - } - - public String getBundleRequireBundle() - { - return bundleRequireBundle; - } - - public void setBundleRequireBundle( String bundleRequireBundle ) - { - this.bundleRequireBundle = bundleRequireBundle; - } - - public boolean isExactSearch() - { - return exactSearch; - } - - public void setExactSearch( boolean exactSearch ) - { - this.exactSearch = exactSearch; - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "SearchFields" ); - sb.append( "{groupId='" ).append( groupId ).append( '\'' ); - sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); - sb.append( ", version='" ).append( version ).append( '\'' ); - sb.append( ", packaging='" ).append( packaging ).append( '\'' ); - sb.append( ", className='" ).append( className ).append( '\'' ); - sb.append( ", repositories=" ).append( repositories ); - sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); - sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); - sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); - sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); - sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); - sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); - sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); - sb.append( ", includePomArtifacts=" ).append( includePomArtifacts ); - sb.append( ", classifier='" ).append( classifier ).append( '\'' ); - sb.append( '}' ); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java deleted file mode 100644 index a493431..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java +++ /dev/null @@ -1,435 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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 java.util.ArrayList; -import java.util.List; - -/** - * SearchResultHit - * - */ -public class SearchResultHit -{ - // The (optional) context for this result. - private String context; - - // Basic hit, direct to non-artifact resource. - private String url; - - // Advanced hit, reference to groupId. - private String groupId; - - // Advanced hit, reference to artifactId. - private String artifactId; - - private String repositoryId = ""; - - private List<String> versions = new ArrayList<>(); - - private String packaging; - - /** - * Plugin goal prefix (only if packaging is "maven-plugin") - */ - private String prefix; - - /** - * Plugin goals (only if packaging is "maven-plugin") - */ - private List<String> goals; - - /** - * contains osgi metadata Bundle-Version if available - * - * @since 1.4-M1 - */ - private String bundleVersion; - - /** - * contains osgi metadata Bundle-SymbolicName if available - * - * @since 1.4-M1 - */ - private String bundleSymbolicName; - - /** - * contains osgi metadata Export-Package if available - * - * @since 1.4-M1 - */ - private String bundleExportPackage; - - /** - * contains osgi metadata Export-Service if available - * - * @since 1.4-M1 - */ - private String bundleExportService; - - /** - * contains osgi metadata Bundle-Description if available - * - * @since 1.4-M1 - */ - private String bundleDescription; - - /** - * contains osgi metadata Bundle-Name if available - * - * @since 1.4-M1 - */ - private String bundleName; - - /** - * contains osgi metadata Bundle-License if available - * - * @since 1.4-M1 - */ - private String bundleLicense; - - /** - * contains osgi metadata Bundle-DocURL if available - * - * @since 1.4-M1 - */ - private String bundleDocUrl; - - /** - * contains osgi metadata Import-Package if available - * - * @since 1.4-M1 - */ - private String bundleImportPackage; - - /** - * contains osgi metadata Require-Bundle if available - * - * @since 1.4-M1 - */ - private String bundleRequireBundle; - - private String classifier; - - /** - * file extension of the search result - * @since 1.4-M2 - */ - private String fileExtension; - - public String getContext() - { - return context; - } - - public void setContext( String context ) - { - this.context = context; - } - - public String getUrl() - { - return url; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public String getUrlFilename() - { - return this.url.substring( this.url.lastIndexOf( '/' ) ); - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getGroupId() - { - return groupId; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public List<String> getVersions() - { - return versions; - } - - public void setVersions( List<String> versions ) - { - this.versions = versions; - } - - public String getRepositoryId() - { - return repositoryId; - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } - - public void addVersion( String version ) - { - versions.add( version ); - } - - public String getBundleVersion() - { - return bundleVersion; - } - - public void setBundleVersion( String bundleVersion ) - { - this.bundleVersion = bundleVersion; - } - - public String getBundleSymbolicName() - { - return bundleSymbolicName; - } - - public void setBundleSymbolicName( String bundleSymbolicName ) - { - this.bundleSymbolicName = bundleSymbolicName; - } - - public String getBundleExportPackage() - { - return bundleExportPackage; - } - - public void setBundleExportPackage( String bundleExportPackage ) - { - this.bundleExportPackage = bundleExportPackage; - } - - public String getBundleExportService() - { - return bundleExportService; - } - - public void setBundleExportService( String bundleExportService ) - { - this.bundleExportService = bundleExportService; - } - - public String getPrefix() - { - return prefix; - } - - public void setPrefix( String prefix ) - { - this.prefix = prefix; - } - - public List<String> getGoals() - { - return goals; - } - - public void setGoals( List<String> goals ) - { - this.goals = goals; - } - - public String getBundleDescription() - { - return bundleDescription; - } - - public void setBundleDescription( String bundleDescription ) - { - this.bundleDescription = bundleDescription; - } - - public String getBundleName() - { - return bundleName; - } - - public void setBundleName( String bundleName ) - { - this.bundleName = bundleName; - } - - public String getBundleLicense() - { - return bundleLicense; - } - - public void setBundleLicense( String bundleLicense ) - { - this.bundleLicense = bundleLicense; - } - - public String getBundleDocUrl() - { - return bundleDocUrl; - } - - public void setBundleDocUrl( String bundleDocUrl ) - { - this.bundleDocUrl = bundleDocUrl; - } - - public String getBundleImportPackage() - { - return bundleImportPackage; - } - - public void setBundleImportPackage( String bundleImportPackage ) - { - this.bundleImportPackage = bundleImportPackage; - } - - public String getBundleRequireBundle() - { - return bundleRequireBundle; - } - - public void setBundleRequireBundle( String bundleRequireBundle ) - { - this.bundleRequireBundle = bundleRequireBundle; - } - - public String getPackaging() - { - return packaging; - } - - public void setPackaging( String packaging ) - { - this.packaging = packaging; - } - - public String getType() - { - return getPackaging(); - } - - public String getClassifier() - { - return classifier; - } - - public void setClassifier( String classifier ) - { - this.classifier = classifier; - } - - public String getFileExtension() - { - return fileExtension; - } - - public void setFileExtension( String fileExtension ) - { - this.fileExtension = fileExtension; - } - - @Override - public String toString() - { - final StringBuilder sb = new StringBuilder(); - sb.append( "SearchResultHit" ); - sb.append( "{context='" ).append( context ).append( '\'' ); - sb.append( ", url='" ).append( url ).append( '\'' ); - sb.append( ", groupId='" ).append( groupId ).append( '\'' ); - sb.append( ", artifactId='" ).append( artifactId ).append( '\'' ); - sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' ); - sb.append( ", versions=" ).append( versions ); - sb.append( ", packaging='" ).append( packaging ).append( '\'' ); - sb.append( ", prefix='" ).append( prefix ).append( '\'' ); - sb.append( ", goals=" ).append( goals ); - sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' ); - sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' ); - sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\'' ); - sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\'' ); - sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' ); - sb.append( ", bundleName='" ).append( bundleName ).append( '\'' ); - sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' ); - sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' ); - sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\'' ); - sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\'' ); - sb.append( ", classifier='" ).append( classifier ).append( '\'' ); - sb.append( ", fileExtension='" ).append( fileExtension ).append( '\'' ); - sb.append( '}' ); - return sb.toString(); - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || getClass() != o.getClass() ) - { - return false; - } - - SearchResultHit that = (SearchResultHit) o; - - if ( artifactId != null ? !artifactId.equals( that.artifactId ) : that.artifactId != null ) - { - return false; - } - if ( classifier != null ? !classifier.equals( that.classifier ) : that.classifier != null ) - { - return false; - } - if ( groupId != null ? !groupId.equals( that.groupId ) : that.groupId != null ) - { - return false; - } - if ( packaging != null ? !packaging.equals( that.packaging ) : that.packaging != null ) - { - return false; - } - - return true; - } - - @Override - public int hashCode() - { - int result = groupId != null ? groupId.hashCode() : 0; - result = 31 * result + ( artifactId != null ? artifactId.hashCode() : 0 ); - result = 31 * result + ( packaging != null ? packaging.hashCode() : 0 ); - result = 31 * result + ( classifier != null ? classifier.hashCode() : 0 ); - return result; - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java deleted file mode 100644 index 967ecc5..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultLimits.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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. - */ - -/** - * SearchResultLimits - used to provide the search some limits on how the results are returned. - * This can provide paging for the result - */ -public class SearchResultLimits -{ - /** - * Constant to use for {@link #setSelectedPage(int)} to indicate a desire to get ALL PAGES. - * USE WITH CAUTION!! - */ - public static final int ALL_PAGES = ( -1 ); - - private int pageSize = 30; - - private int selectedPage = 0; - - /** - * @param selectedPage page selected use -1 for all pages - */ - public SearchResultLimits( int selectedPage ) - { - this.selectedPage = selectedPage; - } - - /** - * @param pageSize number of groupId:artifact per page - * @param selectedPage page selected use -1 for all pages - * @since 1.4-M4 - */ - public SearchResultLimits( int pageSize, int selectedPage ) - { - this.pageSize = pageSize; - this.selectedPage = selectedPage; - } - - public int getPageSize() - { - return pageSize; - } - - /** - * Set page size for maximum # of hits to return per page. - * - * @param pageSize size of page by # of hits. - */ - public void setPageSize( int pageSize ) - { - this.pageSize = pageSize; - } - - public int getSelectedPage() - { - return selectedPage; - } - - public void setSelectedPage( int selectedPage ) - { - this.selectedPage = selectedPage; - } - - @Override - public String toString() - { - return "SearchResultLimits{" + "pageSize=" + pageSize + ", selectedPage=" + selectedPage + '}'; - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResults.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResults.java b/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResults.java deleted file mode 100644 index 9dc650f..0000000 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResults.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.apache.archiva.indexer.search; - -/* - * 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 java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * SearchResults - * - */ -public class SearchResults -{ - private Map<String, SearchResultHit> hits = new HashMap<>(); - - private int totalHits; - - private int totalHitsMapSize; - - private int returnedHitsCount; - - private SearchResultLimits limits; - - public SearchResults() - { - /* do nothing */ - } - - // for new RepositorySearch - public void addHit( String id, SearchResultHit hit ) - { - hits.put( id, hit ); - } - - /** - * Get the list of {@link SearchResultHit} objects. - * - * @return the list of {@link SearchResultHit} objects. - */ - public List<SearchResultHit> getHits() - { - return new ArrayList<>( hits.values() ); - } - - /** - * see SearchUtil on how to generate the key - * - * @param key - * @return - */ - public SearchResultHit getSearchResultHit( String key ) - { - return hits.get( key ); - } - - public Map<String, SearchResultHit> getHitsMap() - { - return hits; - } - - public boolean isEmpty() - { - return hits.isEmpty(); - } - - public SearchResultLimits getLimits() - { - return limits; - } - - public void setLimits( SearchResultLimits limits ) - { - this.limits = limits; - } - - public int getTotalHits() - { - return totalHits; - } - - public void setTotalHits( int totalHits ) - { - this.totalHits = totalHits; - } - - /** - * @return - * @since 1.4-M1 - */ - public int getReturnedHitsCount() - { - return returnedHitsCount; - } - - /** - * @param returnedHitsCount - * @since 1.4-M1 - */ - public void setReturnedHitsCount( int returnedHitsCount ) - { - this.returnedHitsCount = returnedHitsCount; - } - - /** - * @return - * @since 1.4-M1 - */ - public int getTotalHitsMapSize() - { - return totalHitsMapSize; - } - - /** - * @param totalHitsMapSize - * @since 1.4-M1 - */ - public void setTotalHitsMapSize( int totalHitsMapSize ) - { - this.totalHitsMapSize = totalHitsMapSize; - } - - @Override - public String toString() - { - return "SearchResults{" + "hits=" + hits + ", totalHits=" + totalHits + ", returnedHitsCount=" - + returnedHitsCount + ", limits=" + limits + '}'; - } -} http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-base/pom.xml ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-base/pom.xml b/archiva-modules/archiva-base/pom.xml index e78f79b..d77129d 100644 --- a/archiva-modules/archiva-base/pom.xml +++ b/archiva-modules/archiva-base/pom.xml @@ -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> http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java ---------------------------------------------------------------------- diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index 6774e85..6598b07 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -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 ); } http://git-wip-us.apache.org/repos/asf/archiva/blob/2ab8942c/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index c4da9a2..8b981b6 100644 --- a/pom.xml +++ b/pom.xml @@ -289,6 +289,11 @@ </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> <version>${project.version}</version> </dependency>
