--- /dev/null
+<?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>
--- /dev/null
+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 );
+}
--- /dev/null
+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;
+}
--- /dev/null
+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 );
+ }
+}
--- /dev/null
+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();
+ }
+}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+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 + '}';
+ }
+}
--- /dev/null
+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 + '}';
+ }
+}
--- /dev/null
+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 ) );
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<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
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-repository-layer</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-indexer-api</artifactId>
+ </dependency>
<dependency>
+++ /dev/null
-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 );
-}
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;
e.getMessage() );
continue;
}
+ catch ( RepositorySearchException e )
+ {
+ log.warn( "RepositorySearchException occured while accessing index of repository '{}' : {}", repo,
+ e.getMessage() );
+ continue;
+ }
}
return new ArrayList<>( indexingContextIds );
@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() )
{
artifactInfo.getPackaging() );
Map<String, SearchResultHit> hitsMap = results.getHitsMap();
+
if ( !applyArtifactInfoFilters( artifactInfo, artifactInfoFilters, hitsMap ) )
{
continue;
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;
}
* 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;
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() );
}
+++ /dev/null
-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;
-}
+++ /dev/null
-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 );
- }
-}
+++ /dev/null
-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();
- }
-}
+++ /dev/null
-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;
- }
-}
+++ /dev/null
-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 + '}';
- }
-}
+++ /dev/null
-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 + '}';
- }
-}
<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>
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;
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;
log.debug( "Skipping repository '{}' for user '{}': {}", repository, activePrincipal,
e.getMessage() );
}
+
}
log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
repositoryGroupConfiguration.getId(), authzRepos );
temporaryGroupIndexMap );
return mergedRepoDir;
}
- catch ( RepositoryAdminException e )
+ catch ( RepositorySearchException e )
{
throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
}
<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>