You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2023/01/31 16:44:45 UTC
[maven-indexer] branch master updated: [MINDEXER-182] Update parent POM to 39 (#291)
This is an automated email from the ASF dual-hosted git repository.
cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-indexer.git
The following commit(s) were added to refs/heads/master by this push:
new 7730f50 [MINDEXER-182] Update parent POM to 39 (#291)
7730f50 is described below
commit 7730f500d7330dc9223a93331bf1433efe886a8d
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Tue Jan 31 17:44:38 2023 +0100
[MINDEXER-182] Update parent POM to 39 (#291)
* [MINDEXER-182] Update parent POM to 39
Changes:
* update parent POM (and remove unneeded version updates)
* full reformat of sources
---
https://issues.apache.org/jira/browse/MINDEXER-182
---
indexer-cli/pom.xml | 9 +-
.../org/apache/maven/index/cli/Components.java | 6 +-
.../apache/maven/index/cli/NexusIndexerCli.java | 616 ++++-----
.../maven/index/cli/PartialImplementation.java | 33 +-
.../index/cli/AbstractNexusIndexerCliTest.java | 140 +-
.../apache/maven/index/cli/NexusIndexerCliIT.java | 68 +-
.../maven/index/cli/NexusIndexerCliTest.java | 98 +-
indexer-core/pom.xml | 6 +-
.../index/AbstractMultiArtifactInfoFilter.java | 53 +-
.../maven/index/AbstractSearchPageableRequest.java | 36 +-
.../apache/maven/index/AbstractSearchRequest.java | 93 +-
.../apache/maven/index/AbstractSearchResponse.java | 41 +-
.../maven/index/AndMultiArtifactInfoFilter.java | 26 +-
.../apache/maven/index/ArtifactAvailability.java | 35 +-
.../org/apache/maven/index/ArtifactContext.java | 115 +-
.../maven/index/ArtifactContextProducer.java | 12 +-
.../maven/index/ArtifactDiscoveryListener.java | 12 +-
.../java/org/apache/maven/index/ArtifactInfo.java | 572 +++-----
.../org/apache/maven/index/ArtifactInfoFilter.java | 12 +-
.../org/apache/maven/index/ArtifactInfoGroup.java | 35 +-
.../maven/index/ArtifactInfoPostprocessor.java | 12 +-
.../org/apache/maven/index/ArtifactInfoRecord.java | 30 +-
.../maven/index/ArtifactScanningListener.java | 18 +-
.../org/apache/maven/index/CleaningEncoder.java | 14 +-
.../index/DefaultArtifactContextProducer.java | 91 +-
.../org/apache/maven/index/DefaultIndexer.java | 217 ++-
.../apache/maven/index/DefaultIndexerEngine.java | 149 +--
.../maven/index/DefaultIteratorResultSet.java | 299 ++---
.../apache/maven/index/DefaultNexusIndexer.java | 461 +++----
.../apache/maven/index/DefaultQueryCreator.java | 404 +++---
.../org/apache/maven/index/DefaultScanner.java | 87 +-
.../apache/maven/index/DefaultScannerListener.java | 253 ++--
.../apache/maven/index/DefaultSearchEngine.java | 352 +++--
.../main/java/org/apache/maven/index/Field.java | 44 +-
.../org/apache/maven/index/FlatSearchRequest.java | 37 +-
.../org/apache/maven/index/FlatSearchResponse.java | 19 +-
.../apache/maven/index/GroupedSearchRequest.java | 45 +-
.../apache/maven/index/GroupedSearchResponse.java | 19 +-
.../main/java/org/apache/maven/index/Grouping.java | 15 +-
.../main/java/org/apache/maven/index/Indexer.java | 91 +-
.../java/org/apache/maven/index/IndexerEngine.java | 18 +-
.../java/org/apache/maven/index/IndexerField.java | 74 +-
.../apache/maven/index/IndexerFieldVersion.java | 8 +-
.../org/apache/maven/index/IteratorResultSet.java | 13 +-
.../apache/maven/index/IteratorSearchRequest.java | 38 +-
.../apache/maven/index/IteratorSearchResponse.java | 71 +-
.../main/java/org/apache/maven/index/MAVEN.java | 40 +-
.../org/apache/maven/index/MatchHighlight.java | 17 +-
.../org/apache/maven/index/MatchHighlightMode.java | 8 +-
.../apache/maven/index/MatchHighlightRequest.java | 20 +-
.../main/java/org/apache/maven/index/NEXUS.java | 16 +-
.../java/org/apache/maven/index/NexusIndexer.java | 221 +--
.../src/main/java/org/apache/maven/index/OSGI.java | 39 +-
.../org/apache/maven/index/OneLineFragmenter.java | 43 +-
.../java/org/apache/maven/index/QueryCreator.java | 29 +-
.../main/java/org/apache/maven/index/Scanner.java | 12 +-
.../org/apache/maven/index/ScanningRequest.java | 43 +-
.../org/apache/maven/index/ScanningResult.java | 40 +-
.../java/org/apache/maven/index/SearchEngine.java | 49 +-
.../java/org/apache/maven/index/SearchType.java | 16 +-
.../index/UniqueArtifactFilterPostprocessor.java | 57 +-
.../index/UniqueGAArtifactFilterPostprocessor.java | 43 +-
.../archetype/AbstractArchetypeDataSource.java | 71 +-
.../index/artifact/ArtifactPackagingMapper.java | 16 +-
.../artifact/DefaultArtifactPackagingMapper.java | 120 +-
.../java/org/apache/maven/index/artifact/Gav.java | 177 ++-
.../apache/maven/index/artifact/GavCalculator.java | 16 +-
.../maven/index/artifact/M1ArtifactRecognizer.java | 30 +-
.../maven/index/artifact/M1GavCalculator.java | 186 +--
.../maven/index/artifact/M2ArtifactRecognizer.java | 36 +-
.../maven/index/artifact/M2GavCalculator.java | 315 ++---
.../apache/maven/index/artifact/VersionUtils.java | 16 +-
.../index/context/AbstractIndexingContext.java | 21 +-
.../maven/index/context/ContextMemberProvider.java | 8 +-
.../index/context/DefaultIndexingContext.java | 744 +++++-----
.../apache/maven/index/context/DocumentFilter.java | 10 +-
.../ExistingLuceneIndexMismatchException.java | 16 +-
.../apache/maven/index/context/IndexCreator.java | 34 +-
.../org/apache/maven/index/context/IndexUtils.java | 293 ++--
.../maven/index/context/IndexingContext.java | 105 +-
.../maven/index/context/MergedIndexingContext.java | 254 ++--
.../apache/maven/index/context/NexusAnalyzer.java | 78 +-
.../maven/index/context/NexusIndexMultiReader.java | 56 +-
.../index/context/NexusIndexMultiSearcher.java | 22 +-
.../maven/index/context/NexusIndexSearcher.java | 26 +-
.../index/context/NexusIndexSearcherFactory.java | 18 +-
.../maven/index/context/NexusIndexWriter.java | 37 +-
.../maven/index/context/NexusLegacyAnalyzer.java | 52 +-
.../index/context/StaticContextMemberProvider.java | 24 +-
.../maven/index/context/TrackingLockFactory.java | 66 +-
.../UnsupportedExistingLuceneIndexException.java | 21 +-
.../maven/index/creator/AbstractIndexCreator.java | 45 +-
.../index/creator/JarFileContentsIndexCreator.java | 177 +--
.../maven/index/creator/LegacyDocumentUpdater.java | 13 +-
.../MavenArchetypeArtifactInfoIndexCreator.java | 84 +-
.../MavenPluginArtifactInfoIndexCreator.java | 134 +-
.../creator/MinimalArtifactInfoIndexCreator.java | 476 +++----
.../index/creator/OsgiArtifactIndexCreator.java | 625 ++++-----
.../apache/maven/index/expr/SearchExpression.java | 12 +-
.../org/apache/maven/index/expr/SearchTyped.java | 10 +-
.../expr/SearchTypedStringSearchExpression.java | 27 +-
.../maven/index/expr/SourcedSearchExpression.java | 17 +-
.../maven/index/expr/StringSearchExpression.java | 24 +-
.../index/expr/UserInputSearchExpression.java | 17 +-
.../main/java/org/apache/maven/index/fs/Lock.java | 10 +-
.../java/org/apache/maven/index/fs/Locker.java | 13 +-
.../incremental/DefaultIncrementalHandler.java | 229 ++--
.../index/incremental/IncrementalHandler.java | 24 +-
.../maven/index/locator/ArtifactLocator.java | 54 +-
.../maven/index/locator/GavHelpedLocator.java | 10 +-
.../apache/maven/index/locator/JavadocLocator.java | 16 +-
.../org/apache/maven/index/locator/Locator.java | 12 +-
.../org/apache/maven/index/locator/Md5Locator.java | 16 +-
.../maven/index/locator/MetadataLocator.java | 16 +-
.../org/apache/maven/index/locator/PomLocator.java | 14 +-
.../apache/maven/index/locator/Sha1Locator.java | 16 +-
.../maven/index/locator/SignatureLocator.java | 16 +-
.../apache/maven/index/locator/SourcesLocator.java | 16 +-
.../maven/index/packer/DefaultIndexPacker.java | 227 ++--
.../apache/maven/index/packer/DigesterUtils.java | 152 +--
.../org/apache/maven/index/packer/IndexPacker.java | 16 +-
.../maven/index/packer/IndexPackingRequest.java | 61 +-
.../index/search/grouping/AbstractGrouping.java | 38 +-
.../maven/index/search/grouping/GAGrouping.java | 23 +-
.../maven/index/search/grouping/GAVGrouping.java | 25 +-
.../maven/index/search/grouping/GGrouping.java | 23 +-
.../maven/index/search/grouping/RGAVGrouping.java | 25 +-
.../maven/index/search/grouping/RGGrouping.java | 23 +-
.../maven/index/treeview/AbstractTreeNode.java | 138 +-
.../maven/index/treeview/DefaultIndexTreeView.java | 407 +++---
.../maven/index/treeview/DefaultTreeNode.java | 20 +-
.../index/treeview/DefaultTreeNodeFactory.java | 116 +-
.../apache/maven/index/treeview/IndexTreeView.java | 17 +-
.../org/apache/maven/index/treeview/TreeNode.java | 38 +-
.../maven/index/treeview/TreeNodeFactory.java | 18 +-
.../maven/index/treeview/TreeViewRequest.java | 73 +-
.../maven/index/updater/DefaultIndexUpdater.java | 651 ++++-----
.../maven/index/updater/FSDirectoryFactory.java | 13 +-
.../maven/index/updater/IndexDataReader.java | 443 +++---
.../maven/index/updater/IndexDataWriter.java | 218 ++-
.../maven/index/updater/IndexUpdateRequest.java | 83 +-
.../maven/index/updater/IndexUpdateResult.java | 33 +-
.../maven/index/updater/IndexUpdateSideEffect.java | 15 +-
.../apache/maven/index/updater/IndexUpdater.java | 17 +-
.../maven/index/updater/ResourceFetcher.java | 21 +-
.../maven/index/util/IndexCreatorSorter.java | 58 +-
.../maven/index/AbstractIndexCreatorHelper.java | 68 +-
.../maven/index/AbstractNexusIndexerTest.java | 48 +-
.../maven/index/AbstractRepoNexusIndexerTest.java | 504 ++++---
.../apache/maven/index/AbstractTestSupport.java | 14 +-
.../org/apache/maven/index/ConcurrentUseTest.java | 164 +--
...ncurrentUseWithMergedContextPublishingTest.java | 52 +-
.../index/ConcurrentUseWithMergedContextTest.java | 41 +-
.../maven/index/DefaultIndexNexusIndexerTest.java | 256 ++--
.../maven/index/DefaultSearchEngineTest.java | 118 +-
.../apache/maven/index/DuplicateSearchTest.java | 121 +-
.../apache/maven/index/FSDirectoryDeleteTest.java | 61 +-
.../maven/index/FullIndexNexusIndexerTest.java | 443 +++---
.../org/apache/maven/index/Java11HttpClient.java | 48 +-
.../apache/maven/index/Mindexer14HitLimitTest.java | 118 +-
.../maven/index/Mindexer35NexusIndexerTest.java | 52 +-
.../maven/index/MinimalIndexNexusIndexerTest.java | 43 +-
.../maven/index/Nexus1179NexusIndexerTest.java | 104 +-
.../maven/index/Nexus13NexusIndexerTest.java | 236 ++--
.../index/Nexus1911IncrementalMergedCtxTest.java | 26 +-
.../maven/index/Nexus1911IncrementalTest.java | 406 +++---
.../maven/index/Nexus2046NexusIndexerTest.java | 49 +-
.../maven/index/Nexus3177HitLimitChecks.java | 120 +-
.../maven/index/Nexus3233NexusIndexerTest.java | 47 +-
.../index/Nexus3293TimestampSnapshotTest.java | 97 +-
.../maven/index/Nexus3881NexusIndexerTest.java | 49 +-
.../maven/index/Nexus4674GavPathReindexTest.java | 50 +-
.../maven/index/Nexus645NexusIndexerTest.java | 81 +-
.../maven/index/Nexus658NexusIndexerTest.java | 96 +-
.../maven/index/Nexus687NexusIndexerTest.java | 43 +-
.../maven/index/Nexus737NexusIndexerTest.java | 42 +-
.../org/apache/maven/index/NexusIndexerTest.java | 472 +++----
.../maven/index/SearchWithAnEmptyIndexTest.java | 214 ++-
.../org/apache/maven/index/SubPathReindexTest.java | 78 +-
.../maven/index/UniqueArtifactFilterTest.java | 82 +-
.../maven/index/artifact/M1GavCalculatorTest.java | 601 ++++-----
.../maven/index/artifact/M2GavCalculatorTest.java | 1415 ++++++++++----------
.../artifact/MavenArtifactRecognizerTest.java | 59 +-
.../maven/index/context/NexusAnalyzerTest.java | 41 +-
.../index/context/TrackingLockFactoryTest.java | 3 +-
.../creator/JarFileContentsIndexCreatorTest.java | 144 +-
.../MavenPluginArtifactInfoIndexCreatorTest.java | 94 +-
.../creator/OsgiArtifactIndexCreatorTest.java | 328 +++--
.../incremental/DefaultIncrementalHandlerTest.java | 130 +-
.../maven/index/locator/ArtifactLocatorTest.java | 49 +-
.../index/packer/NEXUS4149TransferFormatTest.java | 187 ++-
.../maven/index/treeview/IndexTreeViewTest.java | 138 +-
.../index/updater/AbstractIndexUpdaterTest.java | 125 +-
.../updater/DefaultIndexUpdaterEmbeddingIT.java | 233 ++--
.../index/updater/DefaultIndexUpdaterTest.java | 942 ++++++-------
.../updater/DownloadRemoteIndexerManagerTest.java | 124 +-
.../apache/maven/index/updater/IndexDataTest.java | 105 +-
.../maven/index/updater/LocalIndexCacheTest.java | 404 +++---
.../maven/index/updater/TrackingFetcher.java | 37 +-
.../index/updater/fixtures/ServerTestFixture.java | 131 +-
.../maven/index/util/IndexCreatorSorterTest.java | 103 +-
.../apache/maven/index/util/SpoofIndexCreator.java | 25 +-
indexer-examples/indexer-examples-basic/pom.xml | 104 +-
.../maven/index/examples/BasicUsageExample.java | 365 +++--
.../index/examples/BasicUsageExampleTest.java | 16 +-
indexer-examples/indexer-examples-spring/pom.xml | 174 ++-
.../examples/indexing/IndexerConfiguration.java | 43 +-
.../examples/indexing/RepositoryIndexManager.java | 64 +-
.../index/examples/indexing/RepositoryIndexer.java | 323 ++---
.../indexing/RepositoryIndexerFactory.java | 82 +-
.../index/examples/indexing/SearchRequest.java | 26 +-
.../index/examples/indexing/SearchResults.java | 21 +-
.../examples/services/ArtifactIndexingService.java | 37 +-
.../services/impl/ArtifactIndexingServiceImpl.java | 133 +-
.../index/examples/SimpleArtifactGenerator.java | 134 +-
.../index/examples/SpringUsageExampleTest.java | 205 ++-
.../index/examples/boot/RepositoryBooter.java | 103 +-
indexer-examples/pom.xml | 4 +-
indexer-reader/pom.xml | 6 +-
.../org/apache/maven/index/reader/ChunkReader.java | 163 +--
.../org/apache/maven/index/reader/ChunkWriter.java | 130 +-
.../org/apache/maven/index/reader/IndexReader.java | 197 +--
.../org/apache/maven/index/reader/IndexWriter.java | 131 +-
.../java/org/apache/maven/index/reader/Record.java | 207 ++-
.../apache/maven/index/reader/RecordCompactor.java | 206 ++-
.../apache/maven/index/reader/RecordExpander.java | 262 ++--
.../apache/maven/index/reader/ResourceHandler.java | 22 +-
.../java/org/apache/maven/index/reader/Utils.java | 92 +-
.../index/reader/WritableResourceHandler.java | 13 +-
.../index/reader/resource/BufferedResource.java | 22 +-
.../reader/resource/BufferedResourceHandler.java | 19 +-
.../reader/resource/BufferedWritableResource.java | 22 +-
.../resource/BufferedWritableResourceHandler.java | 19 +-
.../reader/resource/PathWritableResource.java | 32 +-
.../resource/PathWritableResourceHandler.java | 16 +-
.../index/reader/resource/UriResourceHandler.java | 16 +-
.../maven/index/reader/resource/UrlResource.java | 21 +-
.../maven/index/reader/CachingResourceHandler.java | 79 +-
.../apache/maven/index/reader/ChunkReaderTest.java | 70 +-
.../index/reader/DirectoryResourceHandler.java | 53 +-
.../maven/index/reader/HttpResourceHandler.java | 56 +-
.../apache/maven/index/reader/IndexReaderTest.java | 186 ++-
.../apache/maven/index/reader/IndexWriterTest.java | 54 +-
.../org/apache/maven/index/reader/TestSupport.java | 92 +-
.../org/apache/maven/index/reader/TestUtils.java | 70 +-
.../apache/maven/index/reader/TransformTest.java | 85 +-
.../resource/BufferedResourceHandlerTest.java | 82 +-
.../BufferedWritableResourceHandlerTest.java | 67 +-
.../resource/BufferedWritableResourceTest.java | 22 +-
.../resource/PathWritableResourceHandlerTest.java | 36 +-
.../reader/resource/UriResourceHandlerTest.java | 27 +-
pom.xml | 74 +-
search-api/pom.xml | 4 +-
.../main/java/org/apache/maven/search/MAVEN.java | 35 +-
.../main/java/org/apache/maven/search/Record.java | 57 +-
.../org/apache/maven/search/SearchBackend.java | 6 +-
.../java/org/apache/maven/search/SearchEngine.java | 8 +-
.../org/apache/maven/search/SearchRequest.java | 32 +-
.../org/apache/maven/search/SearchResponse.java | 6 +-
.../apache/maven/search/request/BooleanQuery.java | 45 +-
.../org/apache/maven/search/request/Field.java | 77 +-
.../apache/maven/search/request/FieldQuery.java | 29 +-
.../org/apache/maven/search/request/Paging.java | 38 +-
.../org/apache/maven/search/request/Query.java | 22 +-
.../maven/search/support/SearchBackendSupport.java | 22 +-
.../search/support/SearchResponseSupport.java | 28 +-
search-backend-indexer/pom.xml | 4 +-
.../backend/indexer/IndexerCoreSearchBackend.java | 8 +-
.../indexer/IndexerCoreSearchBackendFactory.java | 16 +-
.../backend/indexer/IndexerCoreSearchResponse.java | 6 +-
.../internal/IndexerCoreSearchBackendImpl.java | 213 ++-
.../internal/IndexerCoreSearchResponseImpl.java | 27 +-
.../internal/IndexerCoreSearchBackendImplTest.java | 281 ++--
search-backend-smo/pom.xml | 8 +-
.../maven/search/backend/smo/SmoSearchBackend.java | 8 +-
.../backend/smo/SmoSearchBackendFactory.java | 22 +-
.../search/backend/smo/SmoSearchResponse.java | 6 +-
.../search/backend/smo/SmoSearchTransport.java | 8 +-
.../backend/smo/internal/SmoSearchBackendImpl.java | 217 ++-
.../smo/internal/SmoSearchResponseImpl.java | 23 +-
.../smo/internal/SmoSearchTransportSupplier.java | 9 +-
.../internal/UrlConnectionSmoSearchTransport.java | 37 +-
.../Java11HttpClientSmoSearchTransport.java | 3 +-
.../smo/internal/SmoSearchTransportSupplier.java | 3 +-
.../smo/internal/SmoSearchBackendImplTest.java | 173 ++-
285 files changed, 12568 insertions(+), 16830 deletions(-)
diff --git a/indexer-cli/pom.xml b/indexer-cli/pom.xml
index d93911a..f54065a 100644
--- a/indexer-cli/pom.xml
+++ b/indexer-cli/pom.xml
@@ -29,9 +29,7 @@ under the License.
<artifactId>indexer-cli</artifactId>
<name>Maven :: Indexer CLI</name>
- <description>
- Indexer CLI produces a CLI tool for indexing and publishing Maven repositories.
- </description>
+ <description>Indexer CLI produces a CLI tool for indexing and publishing Maven repositories.</description>
<!-- IMPORTANT! * WHEN YOU CHANGE DEPS MAKE SURE TO UPDATE SHADE CONFIG! * DON'T FORGET OTHERWISE YOU ARE RENDERING CLI
UNWORKABLE! -->
@@ -61,7 +59,8 @@ under the License.
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
- <scope>compile</scope> <!-- to make it into shaded CLI JAR -->
+ <scope>compile</scope>
+ <!-- to make it into shaded CLI JAR -->
</dependency>
<!-- Needed for CLI assembly only, to make it work in "standalone" CLI mode -->
@@ -106,10 +105,10 @@ under the License.
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
- <phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
+ <phase>package</phase>
<configuration>
<shadedClassifierName>${cliClassifier}</shadedClassifierName>
<shadedArtifactAttached>true</shadedArtifactAttached>
diff --git a/indexer-cli/src/main/java/org/apache/maven/index/cli/Components.java b/indexer-cli/src/main/java/org/apache/maven/index/cli/Components.java
index 5398101..7547da2 100644
--- a/indexer-cli/src/main/java/org/apache/maven/index/cli/Components.java
+++ b/indexer-cli/src/main/java/org/apache/maven/index/cli/Components.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import javax.inject.Inject;
import javax.inject.Named;
@@ -31,8 +30,7 @@ import org.apache.maven.index.packer.IndexPacker;
@Named
@Singleton
-public class Components
-{
+public class Components {
@Inject
Map<String, IndexCreator> allIndexCreators;
diff --git a/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java b/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java
index fe220c9..648becb 100644
--- a/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java
+++ b/indexer-cli/src/main/java/org/apache/maven/index/cli/NexusIndexerCli.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import java.io.BufferedInputStream;
import java.io.File;
@@ -77,8 +76,7 @@ import static java.util.Objects.requireNonNull;
* {@link org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator} and
* {@link org.apache.maven.index.creator.JarFileContentsIndexCreator}.
*/
-public class NexusIndexerCli
-{
+public class NexusIndexerCli {
// Generic command line options
@@ -114,87 +112,64 @@ public class NexusIndexerCli
private Options options;
- public static void main( String[] args )
- {
- System.exit( new NexusIndexerCli().execute( args ) );
+ public static void main(String[] args) {
+ System.exit(new NexusIndexerCli().execute(args));
}
/**
* Visible for testing.
*/
- int execute( String[] args )
- {
+ int execute(String[] args) {
CommandLine cli;
- try
- {
- cli = new DefaultParser().parse( buildCliOptions(), cleanArgs( args ) );
- }
- catch ( ParseException e )
- {
- System.err.println( "Unable to parse command line options: " + e.getMessage() );
+ try {
+ cli = new DefaultParser().parse(buildCliOptions(), cleanArgs(args));
+ } catch (ParseException e) {
+ System.err.println("Unable to parse command line options: " + e.getMessage());
displayHelp();
return 1;
}
- boolean debug = cli.hasOption( DEBUG );
+ boolean debug = cli.hasOption(DEBUG);
- if ( cli.hasOption( HELP ) )
- {
+ if (cli.hasOption(HELP)) {
displayHelp();
return 0;
}
- if ( cli.hasOption( VERSION ) )
- {
+ if (cli.hasOption(VERSION)) {
showVersion();
return 0;
- }
- else if ( debug )
- {
+ } else if (debug) {
showVersion();
}
- final Module app = Main.wire(
- BeanScanning.INDEX
- );
+ final Module app = Main.wire(BeanScanning.INDEX);
- Components components =
- Guice.createInjector( app ).getInstance( Components.class );
+ Components components = Guice.createInjector(app).getInstance(Components.class);
- if ( cli.hasOption( UNPACK ) )
- {
- try
- {
- return unpack( cli, components );
- }
- catch ( Exception e )
- {
- e.printStackTrace( System.err );
+ if (cli.hasOption(UNPACK)) {
+ try {
+ return unpack(cli, components);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
return 1;
}
- }
- else if ( cli.hasOption( INDEX ) && cli.hasOption( REPO ) )
- {
- try
- {
- return index( cli, components );
- }
- catch ( Exception e )
- {
- e.printStackTrace( System.err );
+ } else if (cli.hasOption(INDEX) && cli.hasOption(REPO)) {
+ try {
+ return index(cli, components);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
return 1;
}
- }
- else
- {
+ } else {
System.out.println();
- System.out.println( "Use either unpack (\"" + UNPACK + "\") or index (\"" + INDEX + "\" and \"" + REPO
- + "\") options, but none has been found!" );
+ System.out.println("Use either unpack (\"" + UNPACK + "\") or index (\"" + INDEX + "\" and \"" + REPO
+ + "\") options, but none has been found!");
System.out.println();
displayHelp();
return 1;
@@ -204,105 +179,131 @@ public class NexusIndexerCli
/**
* Visible for testing.
*/
- Options buildCliOptions()
- {
+ Options buildCliOptions() {
this.options = new Options();
- options.addOption( Option.builder( QUIET ).longOpt( "quiet" )
- .desc( "Quiet output - only show errors" ).build() );
-
- options.addOption( Option.builder( DEBUG ).longOpt( "debug" )
- .desc( "Produce execution debug output" ).build() );
-
- options.addOption( Option.builder( VERSION ).longOpt( "version" )
- .desc( "Display version information" ).build() );
-
- options.addOption( Option.builder( HELP ).longOpt( "help" )
- .desc( "Display help information" ).build() );
-
-
- options.addOption( Option.builder( INDEX ).longOpt( "index" ).argName( "path" ).hasArg()
- .desc( "Path to the index folder" ).build() );
-
- options.addOption( Option.builder( TARGET_DIR ).longOpt( "destination" ).argName( "path" ).hasArg()
- .desc( "Target folder" ).build() );
-
- options.addOption( Option.builder( REPO ).longOpt( "repository" ).argName( "path" ).hasArg()
- .desc( "Path to the Maven repository" ).build() );
-
- options.addOption( Option.builder( NAME ).longOpt( "name" ).argName( "string" ).hasArg()
- .desc( "Repository name" ).build() );
-
- options.addOption( Option.builder( CREATE_INCREMENTAL_CHUNKS ).longOpt( "chunks" )
- .desc( "Create incremental chunks" ).build() );
-
- options.addOption( Option.builder( INCREMENTAL_CHUNK_KEEP_COUNT ).longOpt( "keep" ).argName( "num" ).hasArg()
- .desc( "Number of incremental chunks to keep" ).build() );
-
- options.addOption( Option.builder( CREATE_FILE_CHECKSUMS ).longOpt( "checksums" )
- .desc( "Create checksums for all files (sha1, md5)" ).build() );
-
- options.addOption( Option.builder( TYPE ).longOpt( "type" ).argName( "type" ).hasArg()
- .desc( "Indexer type (default, min, full or comma separated list of custom types)" ).build() );
-
- options.addOption( Option.builder( UNPACK ).longOpt( "unpack" )
- .desc( "Unpack an index file" ).build() );
+ options.addOption(Option.builder(QUIET)
+ .longOpt("quiet")
+ .desc("Quiet output - only show errors")
+ .build());
+
+ options.addOption(Option.builder(DEBUG)
+ .longOpt("debug")
+ .desc("Produce execution debug output")
+ .build());
+
+ options.addOption(Option.builder(VERSION)
+ .longOpt("version")
+ .desc("Display version information")
+ .build());
+
+ options.addOption(Option.builder(HELP)
+ .longOpt("help")
+ .desc("Display help information")
+ .build());
+
+ options.addOption(Option.builder(INDEX)
+ .longOpt("index")
+ .argName("path")
+ .hasArg()
+ .desc("Path to the index folder")
+ .build());
+
+ options.addOption(Option.builder(TARGET_DIR)
+ .longOpt("destination")
+ .argName("path")
+ .hasArg()
+ .desc("Target folder")
+ .build());
+
+ options.addOption(Option.builder(REPO)
+ .longOpt("repository")
+ .argName("path")
+ .hasArg()
+ .desc("Path to the Maven repository")
+ .build());
+
+ options.addOption(Option.builder(NAME)
+ .longOpt("name")
+ .argName("string")
+ .hasArg()
+ .desc("Repository name")
+ .build());
+
+ options.addOption(Option.builder(CREATE_INCREMENTAL_CHUNKS)
+ .longOpt("chunks")
+ .desc("Create incremental chunks")
+ .build());
+
+ options.addOption(Option.builder(INCREMENTAL_CHUNK_KEEP_COUNT)
+ .longOpt("keep")
+ .argName("num")
+ .hasArg()
+ .desc("Number of incremental chunks to keep")
+ .build());
+
+ options.addOption(Option.builder(CREATE_FILE_CHECKSUMS)
+ .longOpt("checksums")
+ .desc("Create checksums for all files (sha1, md5)")
+ .build());
+
+ options.addOption(Option.builder(TYPE)
+ .longOpt("type")
+ .argName("type")
+ .hasArg()
+ .desc("Indexer type (default, min, full or comma separated list of custom types)")
+ .build());
+
+ options.addOption(Option.builder(UNPACK)
+ .longOpt("unpack")
+ .desc("Unpack an index file")
+ .build());
return options;
}
- private String[] cleanArgs( String[] args )
- {
+ private String[] cleanArgs(String[] args) {
List<String> cleaned = new ArrayList<>();
StringBuilder currentArg = null;
- for ( String arg : args )
- {
+ for (String arg : args) {
boolean addedToBuffer = false;
- if ( arg.startsWith( "\"" ) )
- {
+ if (arg.startsWith("\"")) {
// if we're in the process of building up another arg, push it and start over.
// this is for the case: "-Dfoo=bar "-Dfoo2=bar two" (note the first unterminated quote)
- if ( currentArg != null )
- {
- cleaned.add( currentArg.toString() );
+ if (currentArg != null) {
+ cleaned.add(currentArg.toString());
}
// start building an argument here.
- currentArg = new StringBuilder( arg.substring( 1 ) );
+ currentArg = new StringBuilder(arg.substring(1));
addedToBuffer = true;
}
// this has to be a separate "if" statement, to capture the case of: "-Dfoo=bar"
- if ( arg.endsWith( "\"" ) )
- {
- String cleanArgPart = arg.substring( 0, arg.length() - 1 );
+ if (arg.endsWith("\"")) {
+ String cleanArgPart = arg.substring(0, arg.length() - 1);
// if we're building an argument, keep doing so.
- if ( currentArg != null )
- {
+ if (currentArg != null) {
// if this is the case of "-Dfoo=bar", then we need to adjust the buffer.
- if ( addedToBuffer )
- {
- currentArg.setLength( currentArg.length() - 1 );
+ if (addedToBuffer) {
+ currentArg.setLength(currentArg.length() - 1);
}
// otherwise, we trim the trailing " and append to the buffer.
- else
- {
+ else {
// TODO: introducing a space here...not sure what else to do but collapse whitespace
- currentArg.append( ' ' ).append( cleanArgPart );
+ currentArg.append(' ').append(cleanArgPart);
}
// we're done with this argument, so add it.
- cleaned.add( currentArg.toString() );
- }
- else
- {
+ cleaned.add(currentArg.toString());
+ } else {
// this is a simple argument...just add it.
- cleaned.add( cleanArgPart );
+ cleaned.add(cleanArgPart);
}
// the currentArg MUST be finished when this completes.
@@ -315,141 +316,118 @@ public class NexusIndexerCli
// buffer, then append it with a preceding space...again, not sure what else to
// do other than collapse whitespace.
// NOTE: The case of a trailing quote is handled by nullifying the arg buffer.
- if ( !addedToBuffer )
- {
+ if (!addedToBuffer) {
// append to the argument we're building, collapsing whitespace to a single space.
- if ( currentArg != null )
- {
- currentArg.append( ' ' ).append( arg );
+ if (currentArg != null) {
+ currentArg.append(' ').append(arg);
}
// this is a loner, just add it directly.
- else
- {
- cleaned.add( arg );
+ else {
+ cleaned.add(arg);
}
}
}
// clean up.
- if ( currentArg != null )
- {
- cleaned.add( currentArg.toString() );
+ if (currentArg != null) {
+ cleaned.add(currentArg.toString());
}
int cleanedSz = cleaned.size();
String[] cleanArgs;
- if ( cleanedSz == 0 )
- {
+ if (cleanedSz == 0) {
// if we didn't have any arguments to clean, simply pass the original array through
cleanArgs = args;
- }
- else
- {
- cleanArgs = cleaned.toArray( new String[cleanedSz] );
+ } else {
+ cleanArgs = cleaned.toArray(new String[cleanedSz]);
}
return cleanArgs;
}
- private void displayHelp()
- {
+ private void displayHelp() {
System.out.println();
HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp( "nexus-indexer [options]", "\nOptions:", options, "\n" );
+ formatter.printHelp("nexus-indexer [options]", "\nOptions:", options, "\n");
}
- private void showVersion()
- {
+ private void showVersion() {
InputStream is;
- try
- {
+ try {
Properties properties = new Properties();
- is = getClass().getClassLoader().getResourceAsStream(
- "META-INF/maven/org.apache.maven.indexer/indexer-core/pom.properties" );
+ is = getClass()
+ .getClassLoader()
+ .getResourceAsStream("META-INF/maven/org.apache.maven.indexer/indexer-core/pom.properties");
- if ( is == null )
- {
- System.err.println( "Unable determine version from JAR file." );
+ if (is == null) {
+ System.err.println("Unable determine version from JAR file.");
return;
}
- properties.load( is );
+ properties.load(is);
- if ( properties.getProperty( "builtOn" ) != null )
- {
- System.out.println( "Version: " + properties.getProperty( "version", "unknown" )
- + " built on " + properties.getProperty( "builtOn" ) );
- }
- else
- {
- System.out.println( "Version: " + properties.getProperty( "version", "unknown" ) );
+ if (properties.getProperty("builtOn") != null) {
+ System.out.println("Version: " + properties.getProperty("version", "unknown") + " built on "
+ + properties.getProperty("builtOn"));
+ } else {
+ System.out.println("Version: " + properties.getProperty("version", "unknown"));
}
- }
- catch ( IOException e )
- {
- System.err.println( "Unable determine version from JAR file: " + e.getMessage() );
+ } catch (IOException e) {
+ System.err.println("Unable determine version from JAR file: " + e.getMessage());
}
}
- private int index( final CommandLine cli, Components components )
- throws IOException, UnsupportedExistingLuceneIndexException
- {
- String indexDirectoryName = cli.getOptionValue( INDEX );
+ private int index(final CommandLine cli, Components components)
+ throws IOException, UnsupportedExistingLuceneIndexException {
+ String indexDirectoryName = cli.getOptionValue(INDEX);
- File indexFolder = new File( indexDirectoryName );
+ File indexFolder = new File(indexDirectoryName);
- String outputDirectoryName = cli.getOptionValue( TARGET_DIR, "." );
+ String outputDirectoryName = cli.getOptionValue(TARGET_DIR, ".");
- File outputFolder = new File( outputDirectoryName );
+ File outputFolder = new File(outputDirectoryName);
- File repositoryFolder = new File( cli.getOptionValue( REPO ) );
+ File repositoryFolder = new File(cli.getOptionValue(REPO));
- String repositoryName = cli.getOptionValue( NAME, indexFolder.getName() );
+ String repositoryName = cli.getOptionValue(NAME, indexFolder.getName());
- List<IndexCreator> indexers = getIndexers( cli, components );
+ List<IndexCreator> indexers = getIndexers(cli, components);
- boolean createChecksums = cli.hasOption( CREATE_FILE_CHECKSUMS );
+ boolean createChecksums = cli.hasOption(CREATE_FILE_CHECKSUMS);
- boolean createIncrementalChunks = cli.hasOption( CREATE_INCREMENTAL_CHUNKS );
+ boolean createIncrementalChunks = cli.hasOption(CREATE_INCREMENTAL_CHUNKS);
- boolean debug = cli.hasOption( DEBUG );
+ boolean debug = cli.hasOption(DEBUG);
- boolean quiet = cli.hasOption( QUIET );
+ boolean quiet = cli.hasOption(QUIET);
- Integer chunkCount = cli.hasOption( INCREMENTAL_CHUNK_KEEP_COUNT )
- ? Integer.parseInt( cli.getOptionValue( INCREMENTAL_CHUNK_KEEP_COUNT ) )
+ Integer chunkCount = cli.hasOption(INCREMENTAL_CHUNK_KEEP_COUNT)
+ ? Integer.parseInt(cli.getOptionValue(INCREMENTAL_CHUNK_KEEP_COUNT))
: null;
- if ( !quiet )
- {
- System.err.printf( "Repository Folder: %s\n", repositoryFolder.getAbsolutePath() );
- System.err.printf( "Index Folder: %s\n", indexFolder.getAbsolutePath() );
- System.err.printf( "Output Folder: %s\n", outputFolder.getAbsolutePath() );
- System.err.printf( "Repository name: %s\n", repositoryName );
- System.err.printf( "Indexers: %s\n", indexers );
-
- if ( createChecksums )
- {
- System.err.print( "Will create checksum files for all published files (sha1, md5).\n" );
- }
- else
- {
- System.err.print( "Will not create checksum files.\n" );
+ if (!quiet) {
+ System.err.printf("Repository Folder: %s\n", repositoryFolder.getAbsolutePath());
+ System.err.printf("Index Folder: %s\n", indexFolder.getAbsolutePath());
+ System.err.printf("Output Folder: %s\n", outputFolder.getAbsolutePath());
+ System.err.printf("Repository name: %s\n", repositoryName);
+ System.err.printf("Indexers: %s\n", indexers);
+
+ if (createChecksums) {
+ System.err.print("Will create checksum files for all published files (sha1, md5).\n");
+ } else {
+ System.err.print("Will not create checksum files.\n");
}
- if ( createIncrementalChunks )
- {
- System.err.print( "Will create incremental chunks for changes, along with baseline file.\n" );
- }
- else
- {
- System.err.print( "Will create baseline file.\n" );
+ if (createIncrementalChunks) {
+ System.err.print("Will create incremental chunks for changes, along with baseline file.\n");
+ } else {
+ System.err.print("Will create baseline file.\n");
}
}
@@ -462,173 +440,136 @@ public class NexusIndexerCli
indexFolder, // index folder
null, // repositoryUrl
null, // index update url
- indexers );
+ indexers);
- try
- {
- ArtifactScanningListener listener = new IndexerListener( context, debug, quiet );
+ try {
+ ArtifactScanningListener listener = new IndexerListener(context, debug, quiet);
- components.indexer.scan( context, listener, true );
+ components.indexer.scan(context, listener, true);
IndexSearcher indexSearcher = context.acquireIndexSearcher();
- try
- {
+ try {
IndexPackingRequest request =
- new IndexPackingRequest( context, indexSearcher.getIndexReader(), outputFolder );
+ new IndexPackingRequest(context, indexSearcher.getIndexReader(), outputFolder);
- request.setCreateChecksumFiles( createChecksums );
+ request.setCreateChecksumFiles(createChecksums);
- request.setCreateIncrementalChunks( createIncrementalChunks );
+ request.setCreateIncrementalChunks(createIncrementalChunks);
- request.setFormats( List.of( IndexFormat.FORMAT_V1 ) );
+ request.setFormats(List.of(IndexFormat.FORMAT_V1));
- if ( chunkCount != null )
- {
- request.setMaxIndexChunks( chunkCount );
+ if (chunkCount != null) {
+ request.setMaxIndexChunks(chunkCount);
}
- packIndex( components.packer, request, debug, quiet );
- }
- finally
- {
- context.releaseIndexSearcher( indexSearcher );
+ packIndex(components.packer, request, debug, quiet);
+ } finally {
+ context.releaseIndexSearcher(indexSearcher);
}
- if ( !quiet )
- {
- printStats( tstart );
+ if (!quiet) {
+ printStats(tstart);
}
- }
- finally
- {
- components.indexer.removeIndexingContext( context, false );
+ } finally {
+ components.indexer.removeIndexingContext(context, false);
}
return 0;
}
- private int unpack( CommandLine cli, Components components )
- throws IOException
- {
- final String indexDirectoryName = cli.getOptionValue( INDEX, "." );
- final File indexFolder = new File( indexDirectoryName ).getCanonicalFile();
- final File indexArchive = new File( indexFolder, IndexingContext.INDEX_FILE_PREFIX + ".gz" );
-
- final String outputDirectoryName = cli.getOptionValue( TARGET_DIR, "." );
- final File outputFolder = new File( outputDirectoryName ).getCanonicalFile();
-
- final boolean quiet = cli.hasOption( QUIET );
- if ( !quiet )
- {
- System.err.printf( "Index Folder: %s\n", indexFolder.getAbsolutePath() );
- System.err.printf( "Output Folder: %s\n", outputFolder.getAbsolutePath() );
+ private int unpack(CommandLine cli, Components components) throws IOException {
+ final String indexDirectoryName = cli.getOptionValue(INDEX, ".");
+ final File indexFolder = new File(indexDirectoryName).getCanonicalFile();
+ final File indexArchive = new File(indexFolder, IndexingContext.INDEX_FILE_PREFIX + ".gz");
+
+ final String outputDirectoryName = cli.getOptionValue(TARGET_DIR, ".");
+ final File outputFolder = new File(outputDirectoryName).getCanonicalFile();
+
+ final boolean quiet = cli.hasOption(QUIET);
+ if (!quiet) {
+ System.err.printf("Index Folder: %s\n", indexFolder.getAbsolutePath());
+ System.err.printf("Output Folder: %s\n", outputFolder.getAbsolutePath());
}
long tstart = System.currentTimeMillis();
- final List<IndexCreator> indexers = getIndexers( cli, components );
-
+ final List<IndexCreator> indexers = getIndexers(cli, components);
- try ( BufferedInputStream is = new BufferedInputStream( new FileInputStream( indexArchive ) ); //
- FSDirectory directory = FSDirectory.open( outputFolder.toPath() ) )
- {
- DefaultIndexUpdater.unpackIndexData( is, 4, directory, (IndexingContext) Proxy.newProxyInstance(
- getClass().getClassLoader(), new Class[] {IndexingContext.class}, new PartialImplementation()
- {
- public List<IndexCreator> getIndexCreators()
- {
+ try (BufferedInputStream is = new BufferedInputStream(new FileInputStream(indexArchive)); //
+ FSDirectory directory = FSDirectory.open(outputFolder.toPath())) {
+ DefaultIndexUpdater.unpackIndexData(is, 4, directory, (IndexingContext) Proxy.newProxyInstance(
+ getClass().getClassLoader(), new Class[] {IndexingContext.class}, new PartialImplementation() {
+ public List<IndexCreator> getIndexCreators() {
return indexers;
}
- } )
-
- );
+ }));
}
- if ( !quiet )
- {
- printStats( tstart );
+ if (!quiet) {
+ printStats(tstart);
}
return 0;
}
- private List<IndexCreator> getIndexers( final CommandLine cli, Components components )
- {
+ private List<IndexCreator> getIndexers(final CommandLine cli, Components components) {
String type = "default";
- if ( cli.hasOption( TYPE ) )
- {
- type = cli.getOptionValue( TYPE );
+ if (cli.hasOption(TYPE)) {
+ type = cli.getOptionValue(TYPE);
}
List<IndexCreator> indexers = new ArrayList<>(); // NexusIndexer.DEFAULT_INDEX;
- if ( "default".equals( type ) )
- {
- indexers.add( requireNonNull( components.allIndexCreators.get( "min" ) ) );
- indexers.add( requireNonNull( components.allIndexCreators.get( "jarContent" ) ) );
- }
- else if ( "full".equals( type ) )
- {
- indexers.addAll( components.allIndexCreators.values() );
- }
- else
- {
- for ( String name : type.split( "," ) )
- {
- indexers.add( requireNonNull( components.allIndexCreators.get( name ) ) );
+ if ("default".equals(type)) {
+ indexers.add(requireNonNull(components.allIndexCreators.get("min")));
+ indexers.add(requireNonNull(components.allIndexCreators.get("jarContent")));
+ } else if ("full".equals(type)) {
+ indexers.addAll(components.allIndexCreators.values());
+ } else {
+ for (String name : type.split(",")) {
+ indexers.add(requireNonNull(components.allIndexCreators.get(name)));
}
}
return indexers;
}
- private void packIndex( IndexPacker packer, IndexPackingRequest request, boolean debug, boolean quiet )
- {
- try
- {
- packer.packIndex( request );
- }
- catch ( IOException e )
- {
- if ( !quiet )
- {
- System.err.printf( "Cannot zip index: %s\n", e.getMessage() );
-
- if ( debug )
- {
+ private void packIndex(IndexPacker packer, IndexPackingRequest request, boolean debug, boolean quiet) {
+ try {
+ packer.packIndex(request);
+ } catch (IOException e) {
+ if (!quiet) {
+ System.err.printf("Cannot zip index: %s\n", e.getMessage());
+
+ if (debug) {
e.printStackTrace();
}
}
}
}
- private void printStats( final long startTimeInMillis )
- {
+ private void printStats(final long startTimeInMillis) {
long t = System.currentTimeMillis() - startTimeInMillis;
- long s = TimeUnit.MILLISECONDS.toSeconds( t );
- if ( t > TimeUnit.MINUTES.toMillis( 1 ) )
- {
- long m = TimeUnit.MILLISECONDS.toMinutes( t );
+ long s = TimeUnit.MILLISECONDS.toSeconds(t);
+ if (t > TimeUnit.MINUTES.toMillis(1)) {
+ long m = TimeUnit.MILLISECONDS.toMinutes(t);
- System.err.printf( "Total time: %d min %d sec\n", m, s - ( m * 60 ) );
- }
- else
- {
- System.err.printf( "Total time: %d sec\n", s );
+ System.err.printf("Total time: %d min %d sec\n", m, s - (m * 60));
+ } else {
+ System.err.printf("Total time: %d sec\n", s);
}
Runtime r = Runtime.getRuntime();
- System.err.printf( "Final memory: %dM/%dM\n", //
- ( r.totalMemory() - r.freeMemory() ) / MB, r.totalMemory() / MB );
+ System.err.printf(
+ "Final memory: %dM/%dM\n", //
+ (r.totalMemory() - r.freeMemory()) / MB, r.totalMemory() / MB);
}
/**
* Scanner listener
*/
- private static final class IndexerListener
- implements ArtifactScanningListener
- {
+ private static final class IndexerListener implements ArtifactScanningListener {
private final IndexingContext context;
private final boolean debug;
@@ -639,55 +580,47 @@ public class NexusIndexerCli
private int count;
- IndexerListener( IndexingContext context, boolean debug, boolean quiet )
- {
+ IndexerListener(IndexingContext context, boolean debug, boolean quiet) {
this.context = context;
this.debug = debug;
this.quiet = quiet;
}
@Override
- public void scanningStarted( IndexingContext context )
- {
- if ( !quiet )
- {
- System.err.println( "Scanning started" );
+ public void scanningStarted(IndexingContext context) {
+ if (!quiet) {
+ System.err.println("Scanning started");
}
}
@Override
- public void artifactDiscovered( ArtifactContext ac )
- {
+ public void artifactDiscovered(ArtifactContext ac) {
count++;
long t = System.currentTimeMillis();
ArtifactInfo ai = ac.getArtifactInfo();
- if ( !quiet && debug && "maven-plugin".equals( ai.getPackaging() ) )
- {
- System.err.printf( "Plugin: %s:%s:%s - %s %s\n", //
- ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPrefix(), "" + ai.getGoals() );
+ if (!quiet && debug && "maven-plugin".equals(ai.getPackaging())) {
+ System.err.printf(
+ "Plugin: %s:%s:%s - %s %s\n", //
+ ai.getGroupId(), ai.getArtifactId(), ai.getVersion(), ai.getPrefix(), "" + ai.getGoals());
}
- if ( !quiet && ( debug || ( t - ts ) > 2000L ) )
- {
- System.err.printf( " %6d %s\n", count, formatFile( ac.getPom() ) );
+ if (!quiet && (debug || (t - ts) > 2000L)) {
+ System.err.printf(" %6d %s\n", count, formatFile(ac.getPom()));
ts = t;
}
}
@Override
- public void artifactError( ArtifactContext ac, Exception e )
- {
- if ( !quiet )
- {
- System.err.printf( "! %6d %s - %s\n", count, formatFile( ac.getPom() ), e.getMessage() );
+ public void artifactError(ArtifactContext ac, Exception e) {
+ if (!quiet) {
+ System.err.printf("! %6d %s - %s\n", count, formatFile(ac.getPom()), e.getMessage());
- System.err.printf( " %s\n", formatFile( ac.getArtifact() ) );
+ System.err.printf(" %s\n", formatFile(ac.getArtifact()));
- if ( debug )
- {
+ if (debug) {
e.printStackTrace();
}
}
@@ -695,25 +628,22 @@ public class NexusIndexerCli
ts = System.currentTimeMillis();
}
- private String formatFile( File file )
- {
- return file.getAbsolutePath().substring( context.getRepository().getAbsolutePath().length() + 1 );
+ private String formatFile(File file) {
+ return file.getAbsolutePath()
+ .substring(context.getRepository().getAbsolutePath().length() + 1);
}
@Override
- public void scanningFinished( IndexingContext context, ScanningResult result )
- {
- if ( !quiet )
- {
- if ( result.hasExceptions() )
- {
- System.err.printf( "Scanning errors: %s\n", result.getExceptions().size() );
+ public void scanningFinished(IndexingContext context, ScanningResult result) {
+ if (!quiet) {
+ if (result.hasExceptions()) {
+ System.err.printf(
+ "Scanning errors: %s\n", result.getExceptions().size());
}
- System.err.printf( "Artifacts added: %s\n", result.getTotalFiles() );
- System.err.printf( "Artifacts deleted: %s\n", result.getDeletedFiles() );
+ System.err.printf("Artifacts added: %s\n", result.getTotalFiles());
+ System.err.printf("Artifacts deleted: %s\n", result.getDeletedFiles());
}
}
}
-
}
diff --git a/indexer-cli/src/main/java/org/apache/maven/index/cli/PartialImplementation.java b/indexer-cli/src/main/java/org/apache/maven/index/cli/PartialImplementation.java
index 514bb63..ffbbd27 100644
--- a/indexer-cli/src/main/java/org/apache/maven/index/cli/PartialImplementation.java
+++ b/indexer-cli/src/main/java/org/apache/maven/index/cli/PartialImplementation.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index.cli;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -27,29 +26,19 @@ import java.lang.reflect.Method;
* An {@link java.lang.reflect.InvocationHandler} that can be extended with methods from the proxied interface. While
* invocation it will look for a method within itself that matches the signature of the invoked proxy method. If found
* the method will be invoked and result returned, otherwise an {@link UnsupportedOperationException} will be thrown.
- *
+ *
* @author Alin Dreghiciu
*/
-public class PartialImplementation
- implements InvocationHandler
-{
+public class PartialImplementation implements InvocationHandler {
- public Object invoke( final Object proxy, final Method method, final Object[] args )
- throws Throwable
- {
- try
- {
- final Method localMethod = getClass().getMethod( method.getName(), method.getParameterTypes() );
- return localMethod.invoke( this, args );
- }
- catch ( NoSuchMethodException | IllegalAccessException e )
- {
- throw new UnsupportedOperationException( "Method " + method.getName() + "() is not supported" );
- }
- catch ( InvocationTargetException e )
- {
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ try {
+ final Method localMethod = getClass().getMethod(method.getName(), method.getParameterTypes());
+ return localMethod.invoke(this, args);
+ } catch (NoSuchMethodException | IllegalAccessException e) {
+ throw new UnsupportedOperationException("Method " + method.getName() + "() is not supported");
+ } catch (InvocationTargetException e) {
throw e.getCause();
}
}
-
}
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
index f6d37c6..8835a34 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/AbstractNexusIndexerCliTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index.cli;
* "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
+ * 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
@@ -18,11 +16,13 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
+
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.sisu.launch.InjectedTest;
import org.junit.Test;
@@ -31,9 +31,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-public abstract class AbstractNexusIndexerCliTest
- extends InjectedTest
-{
+public abstract class AbstractNexusIndexerCliTest extends InjectedTest {
private static final long rand = new Random().nextLong();
@@ -45,147 +43,129 @@ public abstract class AbstractNexusIndexerCliTest
* new File( getBasedir(), "src/test/repo" ).getAbsolutePath();
*/
private final String DEST_DIR =
- new File( getBasedir(), "target/tests/clitest-" + rand + "/output" ).getAbsolutePath();
+ new File(getBasedir(), "target/tests/clitest-" + rand + "/output").getAbsolutePath();
private final String INDEX_DIR =
- new File( getBasedir(), "target/tests/clitest-" + rand + "/index" ).getAbsolutePath();
+ new File(getBasedir(), "target/tests/clitest-" + rand + "/index").getAbsolutePath();
private final String UNPACK_DIR =
- new File( getBasedir(), "target/tests/clitest-" + rand + "/unpack" ).getAbsolutePath();
+ new File(getBasedir(), "target/tests/clitest-" + rand + "/unpack").getAbsolutePath();
- private final String TEST_REPO = new File( getBasedir(), "src/test/repo" ).getAbsolutePath();
+ private final String TEST_REPO = new File(getBasedir(), "src/test/repo").getAbsolutePath();
protected OutputStream out;
@Override
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- out = new OutputStream()
- {
+ out = new OutputStream() {
private StringBuilder buf = new StringBuilder();
@Override
- public void write( int b )
- {
+ public void write(int b) {
byte[] bytes = new byte[1];
bytes[0] = (byte) b;
- buf.append( new String( bytes ) );
+ buf.append(new String(bytes));
}
@Override
- public String toString()
- {
+ public String toString() {
String string = buf.toString();
buf = new StringBuilder();
return string;
}
};
- FileUtils.deleteDirectory( INDEX_DIR );
- FileUtils.deleteDirectory( DEST_DIR );
- FileUtils.deleteDirectory( UNPACK_DIR );
-
+ FileUtils.deleteDirectory(INDEX_DIR);
+ FileUtils.deleteDirectory(DEST_DIR);
+ FileUtils.deleteDirectory(UNPACK_DIR);
}
@Override
- public void tearDown()
- throws Exception
- {
+ public void tearDown() throws Exception {
super.tearDown();
-
}
- protected File getTestFile( String path )
- {
- return new File( new File( getBasedir() ), path );
+ protected File getTestFile(String path) {
+ return new File(new File(getBasedir()), path);
}
@Test
- public void testNoArgs()
- {
+ public void testNoArgs() {
int code = execute();
String output = out.toString();
- assertEquals( output, 1, code );
- assertTrue( "Should print usage", output.contains( "usage: nexus-indexer [options]" ) );
+ assertEquals(output, 1, code);
+ assertTrue("Should print usage", output.contains("usage: nexus-indexer [options]"));
}
@Test
- public void testRequiredArgs()
- throws Exception
- {
- int code = execute( "--repository", TEST_REPO, "--index", INDEX_DIR, "-d", DEST_DIR );
+ public void testRequiredArgs() throws Exception {
+ int code = execute("--repository", TEST_REPO, "--index", INDEX_DIR, "-d", DEST_DIR);
String output = out.toString();
- assertEquals( output, 0, code );
+ assertEquals(output, 0, code);
}
@Test
- public void testUnpack()
- throws Exception
- {
+ public void testUnpack() throws Exception {
// first create an index, in the destination dir
- execute( "--repository", TEST_REPO, "--index", INDEX_DIR, "-d", DEST_DIR );
+ execute("--repository", TEST_REPO, "--index", INDEX_DIR, "-d", DEST_DIR);
// then unpack it
- int code = execute( "--unpack", "--index", DEST_DIR, "-d", UNPACK_DIR );
+ int code = execute("--unpack", "--index", DEST_DIR, "-d", UNPACK_DIR);
String output = out.toString();
- assertEquals( output, 0, code );
-
- //FIXME: Looks strange that a newly generated index can not be reopened.
- //assertIndexFiles( UNPACK_DIR );
+ assertEquals(output, 0, code);
+
+ // FIXME: Looks strange that a newly generated index can not be reopened.
+ // assertIndexFiles( UNPACK_DIR );
}
@Test
- public void testMissingArgs()
- throws IOException
- {
+ public void testMissingArgs() throws IOException {
String usage = "usage: nexus-indexer";
- int code = execute( "--repository", "--index", INDEX_DIR, "-d", DEST_DIR );
+ int code = execute("--repository", "--index", INDEX_DIR, "-d", DEST_DIR);
String output = out.toString();
- assertEquals( output, 1, code );
- assertTrue( "Should print bad usage", output.contains( usage ) );
+ assertEquals(output, 1, code);
+ assertTrue("Should print bad usage", output.contains(usage));
- code = execute( "--repository", TEST_REPO, "--index", "-d", DEST_DIR );
+ code = execute("--repository", TEST_REPO, "--index", "-d", DEST_DIR);
output = out.toString();
- assertEquals( output, 1, code );
- assertTrue( "Should print bad usage", output.contains( usage ) );
+ assertEquals(output, 1, code);
+ assertTrue("Should print bad usage", output.contains(usage));
- code = execute( "--repository", TEST_REPO, "--index", INDEX_DIR, "-d" );
+ code = execute("--repository", TEST_REPO, "--index", INDEX_DIR, "-d");
output = out.toString();
- assertEquals( output, 1, code );
- assertTrue( "Should print bad usage", output.contains( usage ) );
+ assertEquals(output, 1, code);
+ assertTrue("Should print bad usage", output.contains(usage));
- code = execute( "--repository", "--index", "-d" );
+ code = execute("--repository", "--index", "-d");
output = out.toString();
- assertEquals( output, 1, code );
- assertTrue( "Should print bad usage but '" + output + "'", output.contains( usage ) );
+ assertEquals(output, 1, code);
+ assertTrue("Should print bad usage but '" + output + "'", output.contains(usage));
- assertFalse( "Index file was generated", new File( INDEX_DIR ).exists() );
+ assertFalse("Index file was generated", new File(INDEX_DIR).exists());
}
@Test
- public void testAbrvsRequiredArgs()
- throws Exception
- {
- int code = execute( "-r", TEST_REPO, "-i", INDEX_DIR, "-d", DEST_DIR );
+ public void testAbrvsRequiredArgs() throws Exception {
+ int code = execute("-r", TEST_REPO, "-i", INDEX_DIR, "-d", DEST_DIR);
String output = out.toString();
- assertEquals( output, 0, code );
+ assertEquals(output, 0, code);
}
@Test
- public void testInvalidRepo()
- throws Exception
- {
- int code =
- execute( "-r", new File( "target/undexinting/repo/to/try/what/will/happen/here" ).getCanonicalPath(), "-i",
- INDEX_DIR, "-d", DEST_DIR );
+ public void testInvalidRepo() throws Exception {
+ int code = execute(
+ "-r",
+ new File("target/undexinting/repo/to/try/what/will/happen/here").getCanonicalPath(),
+ "-i",
+ INDEX_DIR,
+ "-d",
+ DEST_DIR);
String output = out.toString();
- assertEquals( output, 1, code );
+ assertEquals(output, 1, code);
}
- protected abstract int execute( String... args );
-
-}
\ No newline at end of file
+ protected abstract int execute(String... args);
+}
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
index 2fcfb8b..f8a09d2 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliIT.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index.cli;
* "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
+ * 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
@@ -18,73 +16,57 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import java.io.File;
import java.io.IOException;
+
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
import org.codehaus.plexus.util.cli.StreamConsumer;
-public class NexusIndexerCliIT
- extends AbstractNexusIndexerCliTest
-{
+public class NexusIndexerCliIT extends AbstractNexusIndexerCliTest {
private StreamConsumer sout;
@Override
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
- sout = line ->
- {
- try
- {
- out.write( line.getBytes() );
- out.write( "\n".getBytes() );
- }
- catch ( IOException e )
- {
- throw new RuntimeException( e.getMessage(), e );
+ sout = line -> {
+ try {
+ out.write(line.getBytes());
+ out.write("\n".getBytes());
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage(), e);
}
};
}
- private Commandline createCommandLine()
- {
- try
- {
+ private Commandline createCommandLine() {
+ try {
Commandline cmd = new Commandline();
- cmd.setExecutable( "java" );
- cmd.setWorkingDirectory( new File( "." ).getCanonicalFile() );
- cmd.createArg().setValue( "-jar" );
- cmd.createArg().setValue( new File( System.getProperty( "indexerJar" ) ).getCanonicalPath() );
+ cmd.setExecutable("java");
+ cmd.setWorkingDirectory(new File(".").getCanonicalFile());
+ cmd.createArg().setValue("-jar");
+ cmd.createArg().setValue(new File(System.getProperty("indexerJar")).getCanonicalPath());
return cmd;
- }
- catch ( IOException e )
- {
- throw new RuntimeException( e );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
}
@Override
- protected int execute( String... args )
- {
+ protected int execute(String... args) {
Commandline cmd = createCommandLine();
- for ( String arg : args )
- {
- cmd.createArg().setValue( arg );
+ for (String arg : args) {
+ cmd.createArg().setValue(arg);
}
- try
- {
- return CommandLineUtils.executeCommandLine( cmd, sout, sout );
- }
- catch ( CommandLineException e )
- {
+ try {
+ return CommandLineUtils.executeCommandLine(cmd, sout, sout);
+ } catch (CommandLineException e) {
return -1;
}
}
-
}
diff --git a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
index c9c0310..625fb75 100644
--- a/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
+++ b/indexer-cli/src/test/java/org/apache/maven/index/cli/NexusIndexerCliTest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index.cli;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index.cli;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index.cli;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index.cli;
import java.io.File;
import java.io.IOException;
@@ -27,90 +26,75 @@ import java.util.Comparator;
import java.util.List;
import org.apache.commons.cli.Option;
-import org.apache.maven.index.cli.NexusIndexerCli;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Test;
-public class NexusIndexerCliTest
- extends AbstractNexusIndexerCliTest
-{
+public class NexusIndexerCliTest extends AbstractNexusIndexerCliTest {
protected NexusIndexerCli cli;
@Override
- public void setUp()
- throws Exception
- {
+ public void setUp() throws Exception {
super.setUp();
cli = new NexusIndexerCli();
- System.setOut( new PrintStream( out ) );
- System.setErr( new PrintStream( out ) );
+ System.setOut(new PrintStream(out));
+ System.setErr(new PrintStream(out));
}
@Override
- protected int execute( String... args )
- {
- return cli.execute( args );
+ protected int execute(String... args) {
+ return cli.execute(args);
}
- private final static String LS = System.getProperty( "line.separator" );
+ private static final String LS = System.getProperty("line.separator");
- private static class OptionComparator
- implements Comparator<Option>
- {
- public int compare( Option opt1, Option opt2 )
- {
- return opt1.getOpt().compareToIgnoreCase( opt2.getOpt() );
+ private static class OptionComparator implements Comparator<Option> {
+ public int compare(Option opt1, Option opt2) {
+ return opt1.getOpt().compareToIgnoreCase(opt2.getOpt());
}
}
- public String getOptionsAsHtml()
- {
- List<Option> optList = new ArrayList<>( new NexusIndexerCli().buildCliOptions().getOptions() );
- optList.sort( new OptionComparator() );
+ public String getOptionsAsHtml() {
+ List<Option> optList =
+ new ArrayList<>(new NexusIndexerCli().buildCliOptions().getOptions());
+ optList.sort(new OptionComparator());
StringBuilder sb = new StringBuilder();
boolean a = true;
- sb.append( "<table border='1' class='zebra-striped'><tr class='a'><th><b>Options</b></th><th><b>Description</b></th></tr>" );
- for ( Option option : optList )
- {
+ sb.append(
+ "<table border='1' class='zebra-striped'><tr class='a'><th><b>Options</b></th><th><b>Description</b></th></tr>");
+ for (Option option : optList) {
a = !a;
- sb.append( "<tr class='" ).append( a ? 'a' : 'b' ).append( "'><td><code>-<a name='" );
- sb.append( option.getOpt() );
- sb.append( "'>" );
- sb.append( option.getOpt() );
- sb.append( "</a>,--<a name='" );
- sb.append( option.getLongOpt() );
- sb.append( "'>" );
- sb.append( option.getLongOpt() );
- sb.append( "</a>" );
- if ( option.hasArg() )
- {
- if ( option.hasArgName() )
- {
- sb.append( " <" ).append( option.getArgName() ).append( ">" );
- }
- else
- {
- sb.append( ' ' );
+ sb.append("<tr class='").append(a ? 'a' : 'b').append("'><td><code>-<a name='");
+ sb.append(option.getOpt());
+ sb.append("'>");
+ sb.append(option.getOpt());
+ sb.append("</a>,--<a name='");
+ sb.append(option.getLongOpt());
+ sb.append("'>");
+ sb.append(option.getLongOpt());
+ sb.append("</a>");
+ if (option.hasArg()) {
+ if (option.hasArgName()) {
+ sb.append(" <").append(option.getArgName()).append(">");
+ } else {
+ sb.append(' ');
}
}
- sb.append( "</code></td><td>" );
- sb.append( option.getDescription() );
- sb.append( "</td></tr>" );
- sb.append( LS );
+ sb.append("</code></td><td>");
+ sb.append(option.getDescription());
+ sb.append("</td></tr>");
+ sb.append(LS);
}
- sb.append( "</table>" );
+ sb.append("</table>");
return sb.toString();
}
@Test
- public void testOptionsAsHtml()
- throws IOException
- {
- File options = getTestFile( "target/test-classes/options.html" );
- FileUtils.fileWrite( options, "UTF-8", getOptionsAsHtml() );
+ public void testOptionsAsHtml() throws IOException {
+ File options = getTestFile("target/test-classes/options.html");
+ FileUtils.fileWrite(options, "UTF-8", getOptionsAsHtml());
}
}
diff --git a/indexer-core/pom.xml b/indexer-core/pom.xml
index 05f0bd8..2cd7bfd 100644
--- a/indexer-core/pom.xml
+++ b/indexer-core/pom.xml
@@ -29,10 +29,8 @@ under the License.
<artifactId>indexer-core</artifactId>
<name>Maven :: Indexer Core</name>
- <description>
- Indexer Core contains the core support for indexing Maven repositories, searching them, publishing and consuming remotely
- published indexes.
- </description>
+ <description>Indexer Core contains the core support for indexing Maven repositories, searching them, publishing and consuming remotely
+ published indexes.</description>
<dependencies>
<dependency>
diff --git a/indexer-core/src/main/java/org/apache/maven/index/AbstractMultiArtifactInfoFilter.java b/indexer-core/src/main/java/org/apache/maven/index/AbstractMultiArtifactInfoFilter.java
index e0e5e9a..7cb7d34 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/AbstractMultiArtifactInfoFilter.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/AbstractMultiArtifactInfoFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,40 +27,30 @@ import org.apache.maven.index.context.IndexingContext;
/**
* An abstract helper class for implementing ArtifactInfoFilter that actually aggregates multiple filters into one. It
* is up to developer to implement how will be they behave ("fail-fast", or "one-vote-enough for passing", etc).
- *
+ *
* @author cstamas
*/
-public abstract class AbstractMultiArtifactInfoFilter
- implements ArtifactInfoFilter
-{
+public abstract class AbstractMultiArtifactInfoFilter implements ArtifactInfoFilter {
private final List<ArtifactInfoFilter> filters;
- public AbstractMultiArtifactInfoFilter( final List<ArtifactInfoFilter> filters )
- {
- if ( filters == null || filters.isEmpty() )
- {
+ public AbstractMultiArtifactInfoFilter(final List<ArtifactInfoFilter> filters) {
+ if (filters == null || filters.isEmpty()) {
this.filters = null;
- }
- else
- {
- this.filters = new ArrayList<>( filters );
+ } else {
+ this.filters = new ArrayList<>(filters);
}
}
/**
* Returns an unmodifiable list of filters.
- *
+ *
* @return
*/
- public List<ArtifactInfoFilter> getFilters()
- {
- if ( filters == null )
- {
+ public List<ArtifactInfoFilter> getFilters() {
+ if (filters == null) {
return Collections.emptyList();
- }
- else
- {
- return Collections.unmodifiableList( filters );
+ } else {
+ return Collections.unmodifiableList(filters);
}
}
@@ -69,26 +58,22 @@ public abstract class AbstractMultiArtifactInfoFilter
* The filter's implementation is: if list of filters is empty, the just accept it, otherwise consult the list of
* filters.
*/
- public boolean accepts( IndexingContext ctx, ArtifactInfo ai )
- {
- if ( this.filters == null )
- {
+ public boolean accepts(IndexingContext ctx, ArtifactInfo ai) {
+ if (this.filters == null) {
return true;
- }
- else
- {
- return accepts( filters, ctx, ai );
+ } else {
+ return accepts(filters, ctx, ai);
}
}
/**
* It is left to final implementor to implement how we want to decide using filters. This method is called only if
* we _have_ filters set!
- *
+ *
* @param filters
* @param ctx
* @param ai
* @return
*/
- protected abstract boolean accepts( List<ArtifactInfoFilter> filters, IndexingContext ctx, ArtifactInfo ai );
+ protected abstract boolean accepts(List<ArtifactInfoFilter> filters, IndexingContext ctx, ArtifactInfo ai);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchPageableRequest.java b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchPageableRequest.java
index 37e0a42..fc8aecf 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchPageableRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchPageableRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.List;
@@ -27,51 +26,44 @@ import org.apache.maven.index.context.IndexingContext;
/**
* Pageable search request. Adds "start" point, to skip wanted number of records, to implement paging. Use "count" of
* AbstractSearchRequest to set page size.
- *
+ *
* @author cstamas
*/
-public class AbstractSearchPageableRequest
- extends AbstractSearchRequest
-{
+public class AbstractSearchPageableRequest extends AbstractSearchRequest {
/**
* The number of hit we want to skip from result set. Defaults to 0.
*/
private int start;
- public AbstractSearchPageableRequest( Query query )
- {
- super( query, null );
+ public AbstractSearchPageableRequest(Query query) {
+ super(query, null);
this.start = 0;
}
- public AbstractSearchPageableRequest( Query query, List<IndexingContext> contexts )
- {
- super( query, contexts );
+ public AbstractSearchPageableRequest(Query query, List<IndexingContext> contexts) {
+ super(query, contexts);
this.start = 0;
}
/**
* Returns the "start" of wanted results calculated from result set window. Simply, the count of documents to skip.
- *
+ *
* @return
*/
- public int getStart()
- {
+ public int getStart() {
return start;
}
/**
* Sets the "start" of wanted results calculated from result set window. Simply, the count of documents to skip.
- *
+ *
* @param start
*/
- public void setStart( int start )
- {
- if ( start < 0 )
- {
- throw new IllegalArgumentException( "Start cannot be less than 0!" );
+ public void setStart(int start) {
+ if (start < 0) {
+ throw new IllegalArgumentException("Start cannot be less than 0!");
}
this.start = start;
diff --git a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchRequest.java b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchRequest.java
index a93b29d..c3bd098 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.ArrayList;
import java.util.List;
@@ -25,8 +24,7 @@ import java.util.List;
import org.apache.lucene.search.Query;
import org.apache.maven.index.context.IndexingContext;
-public class AbstractSearchRequest
-{
+public class AbstractSearchRequest {
/**
* Constant for denoting undefined value for result count.
*/
@@ -65,68 +63,57 @@ public class AbstractSearchRequest
*/
private boolean luceneExplain = false;
- public AbstractSearchRequest( Query query )
- {
- this( query, null );
+ public AbstractSearchRequest(Query query) {
+ this(query, null);
}
- public AbstractSearchRequest( Query query, List<IndexingContext> contexts )
- {
+ public AbstractSearchRequest(Query query, List<IndexingContext> contexts) {
this.query = query;
- if ( contexts != null )
- {
- getContexts().addAll( contexts );
+ if (contexts != null) {
+ getContexts().addAll(contexts);
}
this.count = UNDEFINED;
}
- public Query getQuery()
- {
+ public Query getQuery() {
return query;
}
- public void setQuery( Query query )
- {
+ public void setQuery(Query query) {
this.query = query;
}
- public List<IndexingContext> getContexts()
- {
- if ( contexts == null )
- {
+ public List<IndexingContext> getContexts() {
+ if (contexts == null) {
contexts = new ArrayList<>();
}
return contexts;
}
- public void setContexts( List<IndexingContext> contexts )
- {
+ public void setContexts(List<IndexingContext> contexts) {
this.contexts = contexts;
}
/**
* Returns the "count" of wanted results. See {@link #UNDEFINED} and {@link #count}.
- *
+ *
* @return
*/
- public int getCount()
- {
+ public int getCount() {
return count;
}
/**
* Sets the "count" of wanted results. See {@link #UNDEFINED} and {@link #count}.
- *
+ *
* @param count
*/
- public void setCount( int count )
- {
- if ( UNDEFINED != count && count < 1 )
- {
- throw new IllegalArgumentException( "Count cannot be less than 1!" );
+ public void setCount(int count) {
+ if (UNDEFINED != count && count < 1) {
+ throw new IllegalArgumentException("Count cannot be less than 1!");
}
this.count = count;
@@ -134,82 +121,70 @@ public class AbstractSearchRequest
/**
* Returns true if hits are limited.
- *
+ *
* @return
* @deprecated always returns false, since 4.1.0 there is no notion of hit limit
* @see http://jira.codehaus.org/browse/MINDEXER-14
*/
- public boolean isHitLimited()
- {
+ public boolean isHitLimited() {
return false;
}
/**
* Gets the hit limit. Since 4.1.0 does nothing, always returns -1 (was "no hit limit").
- *
+ *
* @return
* @deprecated always returns -1 (no hit limit), since 4.1.0 there is no notion of hit limit
* @see http://jira.codehaus.org/browse/MINDEXER-14
*/
- public int getResultHitLimit()
- {
+ public int getResultHitLimit() {
return -1;
}
/**
* Sets the hit limit. Since 4.1.0 does nothing.
- *
+ *
* @param resultHitLimit
* @deprecated does nothing, since 4.1.0 there is no notion of hit limit
* @see http://jira.codehaus.org/browse/MINDEXER-14
*/
- public void setResultHitLimit( int resultHitLimit )
- {
+ public void setResultHitLimit(int resultHitLimit) {
// noop
}
- public ArtifactInfoFilter getArtifactInfoFilter()
- {
+ public ArtifactInfoFilter getArtifactInfoFilter() {
return artifactInfoFilter;
}
- public void setArtifactInfoFilter( ArtifactInfoFilter artifactInfoFilter )
- {
+ public void setArtifactInfoFilter(ArtifactInfoFilter artifactInfoFilter) {
this.artifactInfoFilter = artifactInfoFilter;
}
- public ArtifactInfoPostprocessor getArtifactInfoPostprocessor()
- {
+ public ArtifactInfoPostprocessor getArtifactInfoPostprocessor() {
return artifactInfoPostprocessor;
}
- public void setArtifactInfoPostprocessor( ArtifactInfoPostprocessor artifactInfoPostprocessor )
- {
+ public void setArtifactInfoPostprocessor(ArtifactInfoPostprocessor artifactInfoPostprocessor) {
this.artifactInfoPostprocessor = artifactInfoPostprocessor;
}
- public List<MatchHighlightRequest> getMatchHighlightRequests()
- {
- if ( matchHighlightRequests == null )
- {
+ public List<MatchHighlightRequest> getMatchHighlightRequests() {
+ if (matchHighlightRequests == null) {
matchHighlightRequests = new ArrayList<>();
}
return matchHighlightRequests;
}
- public void setMatchHighlightRequests( List<MatchHighlightRequest> matchHighlightRequests )
- {
+ public void setMatchHighlightRequests(List<MatchHighlightRequest> matchHighlightRequests) {
this.matchHighlightRequests = matchHighlightRequests;
}
- public boolean isLuceneExplain()
- {
+ public boolean isLuceneExplain() {
return luceneExplain;
}
- public void setLuceneExplain( boolean luceneExplain )
- {
+ public void setLuceneExplain(boolean luceneExplain) {
this.luceneExplain = luceneExplain;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchResponse.java b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchResponse.java
index 1bc06d8..53c652f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchResponse.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/AbstractSearchResponse.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,23 +16,21 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.Closeable;
import java.io.IOException;
import org.apache.lucene.search.Query;
-public class AbstractSearchResponse
- implements Closeable
-{
+public class AbstractSearchResponse implements Closeable {
private final Query query;
private final int totalHitsCount;
private final int returnedHitsCount;
- public AbstractSearchResponse( final Query query, final int totalHitsCount, final int returnedHitsCount )
- {
+ public AbstractSearchResponse(final Query query, final int totalHitsCount, final int returnedHitsCount) {
this.query = query;
this.totalHitsCount = totalHitsCount;
@@ -42,19 +38,17 @@ public class AbstractSearchResponse
this.returnedHitsCount = returnedHitsCount;
}
- public Query getQuery()
- {
+ public Query getQuery() {
return query;
}
/**
* Returns the number of total hits found. This may be different that actual hits returned (is usually more).
- *
+ *
* @return
* @deprecated use {@link #getTotalHitsCount()} instead.
*/
- public int getTotalHits()
- {
+ public int getTotalHits() {
return getTotalHitsCount();
}
@@ -62,11 +56,10 @@ public class AbstractSearchResponse
* Returns the number of total hits found by this query (total number of potential hits as reported by Lucene
* index). This is the number of existing AIs matching your query, and does not represent the count of hits
* delivered, which is returned by {@link #getReturnedHitsCount()}.
- *
+ *
* @return
*/
- public int getTotalHitsCount()
- {
+ public int getTotalHitsCount() {
return totalHitsCount;
}
@@ -75,35 +68,31 @@ public class AbstractSearchResponse
* (like count set on request) and filtering, paging, etc. Warning: this number's meaning depends on actual search
* response (for flat response number of actual AIs, for grouped response number of actual groups), and also, might
* be not precise at all (see {@link IteratorSearchResponse}).
- *
+ *
* @return
*/
- public int getReturnedHitsCount()
- {
+ public int getReturnedHitsCount() {
return returnedHitsCount;
}
/**
* Returns true if hit limit exceeded.
- *
+ *
* @return
* @deprecated always returns false, since 4.1.0 there is no notion of hit limit
* @see http://jira.codehaus.org/browse/MINDEXER-14
*/
- public boolean isHitLimitExceeded()
- {
+ public boolean isHitLimitExceeded() {
return false;
}
/**
* Frees any resource associated with this response. Should be called as last method on this response, when it's not
* used anymore.
- *
+ *
* @throws IOException
*/
- public void close()
- throws IOException
- {
+ public void close() throws IOException {
// noop
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/AndMultiArtifactInfoFilter.java b/indexer-core/src/main/java/org/apache/maven/index/AndMultiArtifactInfoFilter.java
index 775077c..3b68795 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/AndMultiArtifactInfoFilter.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/AndMultiArtifactInfoFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.List;
@@ -27,27 +26,20 @@ import org.apache.maven.index.context.IndexingContext;
* This is a aggregated artifact info filter that performs AND operation (all filter has to accept the artifact info, if
* one rejects, results is reject). It is implemented in "fail fast" way, as soon as some member ArtifactFilter rejects,
* it will be rejected.
- *
+ *
* @author cstamas
*/
-public class AndMultiArtifactInfoFilter
- extends AbstractMultiArtifactInfoFilter
-{
- public AndMultiArtifactInfoFilter( List<ArtifactInfoFilter> filters )
- {
- super( filters );
+public class AndMultiArtifactInfoFilter extends AbstractMultiArtifactInfoFilter {
+ public AndMultiArtifactInfoFilter(List<ArtifactInfoFilter> filters) {
+ super(filters);
}
@Override
- protected boolean accepts( List<ArtifactInfoFilter> filters, IndexingContext ctx, ArtifactInfo ai )
- {
- for ( ArtifactInfoFilter filter : filters )
- {
- if ( !filter.accepts( ctx, ai ) )
- {
+ protected boolean accepts(List<ArtifactInfoFilter> filters, IndexingContext ctx, ArtifactInfo ai) {
+ for (ArtifactInfoFilter filter : filters) {
+ if (!filter.accepts(ctx, ai)) {
return false;
}
-
}
return true;
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactAvailability.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactAvailability.java
index 60af75c..811399b 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactAvailability.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactAvailability.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,46 +16,41 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
/**
* Enumeration provides values indicating artifact availability
*/
-public enum ArtifactAvailability
-{
+public enum ArtifactAvailability {
/**
* Artifact is not present locally
*/
- NOT_PRESENT( 0 ),
+ NOT_PRESENT(0),
/**
* Artifact is present locally
*/
- PRESENT( 1 ),
+ PRESENT(1),
/**
* Artifact is not available
*/
- NOT_AVAILABLE( 2 );
+ NOT_AVAILABLE(2);
private final int n;
- ArtifactAvailability( int n )
- {
+ ArtifactAvailability(int n) {
this.n = n;
}
@Override
- public String toString()
- {
- return Integer.toString( n );
+ public String toString() {
+ return Integer.toString(n);
}
- public static ArtifactAvailability fromString( String s )
- {
- try
- {
- switch ( Integer.parseInt( s ) )
- {
+ public static ArtifactAvailability fromString(String s) {
+ try {
+ switch (Integer.parseInt(s)) {
case 1:
return PRESENT;
case 2:
@@ -65,9 +58,7 @@ public enum ArtifactAvailability
default:
return NOT_PRESENT;
}
- }
- catch ( NumberFormatException ex )
- {
+ } catch (NumberFormatException ex) {
return NOT_PRESENT;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java
index 8803654..93888c0 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
@@ -43,15 +42,14 @@ import org.slf4j.LoggerFactory;
/**
* An artifact context used to provide information about artifact during scanning. It is passed to the
* {@link IndexCreator}, which can populate {@link ArtifactInfo} for the given artifact.
- *
+ *
* @see IndexCreator#populateArtifactInfo(ArtifactContext)
* @author Jason van Zyl
* @author Tamas Cservenak
*/
-public class ArtifactContext
-{
+public class ArtifactContext {
- private static final Logger LOGGER = LoggerFactory.getLogger( ArtifactContext.class );
+ private static final Logger LOGGER = LoggerFactory.getLogger(ArtifactContext.class);
private final File pom;
@@ -65,12 +63,10 @@ public class ArtifactContext
private final List<Exception> errors = new ArrayList<>();
- public ArtifactContext( File pom, File artifact, File metadata, ArtifactInfo artifactInfo, Gav gav )
- throws IllegalArgumentException
- {
- if ( artifactInfo == null )
- {
- throw new IllegalArgumentException( "Parameter artifactInfo must not be null." );
+ public ArtifactContext(File pom, File artifact, File metadata, ArtifactInfo artifactInfo, Gav gav)
+ throws IllegalArgumentException {
+ if (artifactInfo == null) {
+ throw new IllegalArgumentException("Parameter artifactInfo must not be null.");
}
this.pom = pom;
@@ -80,112 +76,89 @@ public class ArtifactContext
this.gav = gav == null ? artifactInfo.calculateGav() : gav;
}
- public File getPom()
- {
+ public File getPom() {
return pom;
}
- public Model getPomModel()
- {
+ public Model getPomModel() {
// First check for local pom file
File pom = getPom();
- if ( pom != null && pom.isFile() )
- {
- try ( InputStream inputStream = Files.newInputStream( pom.toPath() ) )
- {
- return new MavenXpp3Reader().read( inputStream, false );
- }
- catch ( IOException | XmlPullParserException e )
- {
- LOGGER.warn( "skip error reading pom: " + pom, e );
+ if (pom != null && pom.isFile()) {
+ try (InputStream inputStream = Files.newInputStream(pom.toPath())) {
+ return new MavenXpp3Reader().read(inputStream, false);
+ } catch (IOException | XmlPullParserException e) {
+ LOGGER.warn("skip error reading pom: " + pom, e);
}
}
// Otherwise, check for pom contained in maven generated artifact
- else if ( getArtifact() != null && getArtifact().isFile() )
- {
- try ( ZipFile zipFile = new ZipFile( artifact ) )
- {
+ else if (getArtifact() != null && getArtifact().isFile()) {
+ try (ZipFile zipFile = new ZipFile(artifact)) {
final String embeddedPomPath =
- "META-INF/maven/" + getGav().getGroupId() + "/" + getGav().getArtifactId() + "/pom.xml";
+ "META-INF/maven/" + getGav().getGroupId() + "/" + getGav().getArtifactId() + "/pom.xml";
- ZipEntry zipEntry = zipFile.getEntry( embeddedPomPath );
+ ZipEntry zipEntry = zipFile.getEntry(embeddedPomPath);
- if ( zipEntry != null )
- {
- try ( InputStream inputStream = zipFile.getInputStream( zipEntry ) )
- {
- return new MavenXpp3Reader().read( inputStream, false );
+ if (zipEntry != null) {
+ try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
+ return new MavenXpp3Reader().read(inputStream, false);
}
}
- }
- catch ( IOException | XmlPullParserException e )
- {
- LOGGER.warn( "skip error reading pom withing artifact:" + artifact, e );
+ } catch (IOException | XmlPullParserException e) {
+ LOGGER.warn("skip error reading pom withing artifact:" + artifact, e);
}
}
return null;
}
- public File getArtifact()
- {
+ public File getArtifact() {
return artifact;
}
- public File getMetadata()
- {
+ public File getMetadata() {
return metadata;
}
- public ArtifactInfo getArtifactInfo()
- {
+ public ArtifactInfo getArtifactInfo() {
return artifactInfo;
}
- public Gav getGav()
- {
+ public Gav getGav() {
return gav;
}
- public List<Exception> getErrors()
- {
+ public List<Exception> getErrors() {
return errors;
}
- public void addError( Exception e )
- {
- errors.add( e );
+ public void addError(Exception e) {
+ errors.add(e);
}
/**
* Creates Lucene Document using {@link IndexCreator}s from the given {@link IndexingContext}.
*/
- public Document createDocument( IndexingContext context )
- {
+ public Document createDocument(IndexingContext context) {
Document doc = new Document();
// unique key
- doc.add( new Field( ArtifactInfo.UINFO, getArtifactInfo().getUinfo(), IndexerField.KEYWORD_STORED ) );
+ doc.add(new Field(ArtifactInfo.UINFO, getArtifactInfo().getUinfo(), IndexerField.KEYWORD_STORED));
- doc.add( new StoredField( ArtifactInfo.LAST_MODIFIED, //
- Long.toString( System.currentTimeMillis() ) ) );
+ doc.add(new StoredField(
+ ArtifactInfo.LAST_MODIFIED, //
+ Long.toString(System.currentTimeMillis())));
- for ( IndexCreator indexCreator : context.getIndexCreators() )
- {
- try
- {
- indexCreator.populateArtifactInfo( this );
- }
- catch ( IOException ex )
- {
- addError( ex );
+ for (IndexCreator indexCreator : context.getIndexCreators()) {
+ try {
+ indexCreator.populateArtifactInfo(this);
+ } catch (IOException ex) {
+ addError(ex);
}
}
// need a second pass in case index creators updated document attributes
- for ( IndexCreator indexCreator : context.getIndexCreators() )
- {
- indexCreator.updateDocument( getArtifactInfo(), doc );
+ for (IndexCreator indexCreator : context.getIndexCreators()) {
+ indexCreator.updateDocument(getArtifactInfo(), doc);
}
return doc;
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContextProducer.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContextProducer.java
index 2647b09..c87d37c 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactContextProducer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactContextProducer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.File;
@@ -25,10 +24,9 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A producer that creates {@link ArtifactContext} from POM and from other available files.
- *
+ *
* @author Tamas Cservenak
*/
-public interface ArtifactContextProducer
-{
- ArtifactContext getArtifactContext( IndexingContext context, File file );
+public interface ArtifactContextProducer {
+ ArtifactContext getArtifactContext(IndexingContext context, File file);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactDiscoveryListener.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactDiscoveryListener.java
index 4c4b765..9e35d5f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactDiscoveryListener.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactDiscoveryListener.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,13 +16,13 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
/**
* A listener notified upon artifact discovery.
- *
+ *
* @author Tamas Cservenak
*/
-public interface ArtifactDiscoveryListener
-{
- void artifactDiscovered( ArtifactContext ac );
+public interface ArtifactDiscoveryListener {
+ void artifactDiscovered(ArtifactContext ac);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
index 490c02f..2300153 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfo.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,13 +39,11 @@ import org.eclipse.aether.version.VersionScheme;
/**
* ArtifactInfo holds the values known about an repository artifact. This is a simple Value Object kind of stuff.
* Phasing out.
- *
+ *
* @author Jason van Zyl
* @author Eugene Kuleshov
*/
-public class ArtifactInfo
- extends ArtifactInfoRecord
-{
+public class ArtifactInfo extends ArtifactInfoRecord {
private static final long serialVersionUID = 6028843453477511105L;
// --
@@ -140,7 +137,6 @@ public class ArtifactInfo
*/
public static final String PLUGIN_GOALS = MavenPluginArtifactInfoIndexCreator.FLD_PLUGIN_GOALS.getKey();
-
/**
* @since 1.4.2
*/
@@ -169,6 +165,7 @@ public class ArtifactInfo
*/
public static final String BUNDLE_REQUIRE_CAPABILITY =
OsgiArtifactIndexCreator.FLD_BUNDLE_REQUIRE_CAPABILITY.getKey();
+
public static final Comparator<ArtifactInfo> VERSION_COMPARATOR = new VersionComparator();
public static final Comparator<ArtifactInfo> REPOSITORY_VERSION_COMPARATOR = new RepositoryVersionComparator();
@@ -294,7 +291,6 @@ public class ArtifactInfo
*/
private String bundleRequireBundle;
-
/**
* contains osgi metadata Provide-Capability if available
*
@@ -320,7 +316,6 @@ public class ArtifactInfo
*/
private String bundleFragmentHost;
-
/**
* bundle required execution environment
*
@@ -334,14 +329,12 @@ public class ArtifactInfo
private final transient VersionScheme versionScheme;
- public ArtifactInfo()
- {
+ public ArtifactInfo() {
versionScheme = new GenericVersionScheme();
}
- public ArtifactInfo( String repository, String groupId, String artifactId, String version, String classifier,
- String extension )
- {
+ public ArtifactInfo(
+ String repository, String groupId, String artifactId, String version, String classifier, String extension) {
this();
this.repository = repository;
this.groupId = groupId;
@@ -351,16 +344,11 @@ public class ArtifactInfo
this.fileExtension = extension;
}
- public Version getArtifactVersion()
- {
- if ( artifactVersion == null )
- {
- try
- {
- artifactVersion = versionScheme.parseVersion( version );
- }
- catch ( InvalidVersionSpecificationException e )
- {
+ public Version getArtifactVersion() {
+ if (artifactVersion == null) {
+ try {
+ artifactVersion = versionScheme.parseVersion(version);
+ } catch (InvalidVersionSpecificationException e) {
// will not happen, only with version ranges but we should not have those
// we handle POM versions here, not dependency versions
}
@@ -369,90 +357,84 @@ public class ArtifactInfo
return artifactVersion;
}
- public float getLuceneScore()
- {
+ public float getLuceneScore() {
return luceneScore;
}
- public void setLuceneScore( float score )
- {
+ public void setLuceneScore(float score) {
this.luceneScore = score;
}
- public String getUinfo()
- {
- return groupId + FS + artifactId + FS + version + FS + nvl( classifier ) + FS + fileExtension;
+ public String getUinfo() {
+ return groupId + FS + artifactId + FS + version + FS + nvl(classifier) + FS + fileExtension;
// extension is stored in the packaging field when classifier is not used
// .append( StringUtils.isEmpty( classifier ) || StringUtils.isEmpty( packaging ) ? "" : FS + packaging ) //
}
- public String getRootGroup()
- {
- int n = groupId.indexOf( '.' );
- if ( n > -1 )
- {
- return groupId.substring( 0, n );
+ public String getRootGroup() {
+ int n = groupId.indexOf('.');
+ if (n > -1) {
+ return groupId.substring(0, n);
}
return groupId;
}
- public Gav calculateGav()
- {
- return new Gav( groupId, artifactId, version, classifier, fileExtension, null, // snapshotBuildNumber
- null, // snapshotTimeStamp
- fileName, // name
- false, // hash
- null, // hashType
- false, // signature
- null ); // signatureType
+ public Gav calculateGav() {
+ return new Gav(
+ groupId,
+ artifactId,
+ version,
+ classifier,
+ fileExtension,
+ null, // snapshotBuildNumber
+ null, // snapshotTimeStamp
+ fileName, // name
+ false, // hash
+ null, // hashType
+ false, // signature
+ null); // signatureType
}
- public Map<String, String> getAttributes()
- {
+ public Map<String, String> getAttributes() {
return attributes;
}
- public List<MatchHighlight> getMatchHighlights()
- {
+ public List<MatchHighlight> getMatchHighlights() {
return matchHighlights;
}
@Override
- public String toString()
- {
- final StringBuilder result = new StringBuilder( getUinfo() );
+ public String toString() {
+ final StringBuilder result = new StringBuilder(getUinfo());
String packaging = getPackaging();
- if ( packaging != null && !getPackaging().isEmpty() )
- {
- result.append( "[" ).append( getPackaging() ).append( "]" );
+ if (packaging != null && !getPackaging().isEmpty()) {
+ result.append("[").append(getPackaging()).append("]");
}
return result.toString();
}
private static final List<Field> DEFAULT_FIELDS = new ArrayList<>();
- static
- {
- DEFAULT_FIELDS.add( MAVEN.GROUP_ID );
- DEFAULT_FIELDS.add( MAVEN.ARTIFACT_ID );
- DEFAULT_FIELDS.add( MAVEN.VERSION );
- DEFAULT_FIELDS.add( MAVEN.PACKAGING );
- DEFAULT_FIELDS.add( MAVEN.CLASSIFIER );
- DEFAULT_FIELDS.add( MAVEN.SHA1 );
- DEFAULT_FIELDS.add( MAVEN.NAME );
- DEFAULT_FIELDS.add( MAVEN.DESCRIPTION );
- DEFAULT_FIELDS.add( MAVEN.CLASSNAMES );
- DEFAULT_FIELDS.add( MAVEN.REPOSITORY_ID );
+
+ static {
+ DEFAULT_FIELDS.add(MAVEN.GROUP_ID);
+ DEFAULT_FIELDS.add(MAVEN.ARTIFACT_ID);
+ DEFAULT_FIELDS.add(MAVEN.VERSION);
+ DEFAULT_FIELDS.add(MAVEN.PACKAGING);
+ DEFAULT_FIELDS.add(MAVEN.CLASSIFIER);
+ DEFAULT_FIELDS.add(MAVEN.SHA1);
+ DEFAULT_FIELDS.add(MAVEN.NAME);
+ DEFAULT_FIELDS.add(MAVEN.DESCRIPTION);
+ DEFAULT_FIELDS.add(MAVEN.CLASSNAMES);
+ DEFAULT_FIELDS.add(MAVEN.REPOSITORY_ID);
}
private List<Field> fields;
- public Collection<Field> getFields()
- {
- if ( fields == null )
- {
- fields = new ArrayList<>( DEFAULT_FIELDS.size() );
+ public Collection<Field> getFields() {
+ if (fields == null) {
+ fields = new ArrayList<>(DEFAULT_FIELDS.size());
- fields.addAll( DEFAULT_FIELDS );
+ fields.addAll(DEFAULT_FIELDS);
}
return fields;
@@ -460,50 +442,30 @@ public class ArtifactInfo
/**
* This method will disappear, once we drop ArtifactInfo.
- *
+ *
* @param field
* @return
*/
- public String getFieldValue( Field field )
- {
- if ( MAVEN.GROUP_ID.equals( field ) )
- {
+ public String getFieldValue(Field field) {
+ if (MAVEN.GROUP_ID.equals(field)) {
return groupId;
- }
- else if ( MAVEN.ARTIFACT_ID.equals( field ) )
- {
+ } else if (MAVEN.ARTIFACT_ID.equals(field)) {
return artifactId;
- }
- else if ( MAVEN.VERSION.equals( field ) )
- {
+ } else if (MAVEN.VERSION.equals(field)) {
return version;
- }
- else if ( MAVEN.PACKAGING.equals( field ) )
- {
+ } else if (MAVEN.PACKAGING.equals(field)) {
return packaging;
- }
- else if ( MAVEN.CLASSIFIER.equals( field ) )
- {
+ } else if (MAVEN.CLASSIFIER.equals(field)) {
return classifier;
- }
- else if ( MAVEN.SHA1.equals( field ) )
- {
+ } else if (MAVEN.SHA1.equals(field)) {
return sha1;
- }
- else if ( MAVEN.NAME.equals( field ) )
- {
+ } else if (MAVEN.NAME.equals(field)) {
return name;
- }
- else if ( MAVEN.DESCRIPTION.equals( field ) )
- {
+ } else if (MAVEN.DESCRIPTION.equals(field)) {
return description;
- }
- else if ( MAVEN.CLASSNAMES.equals( field ) )
- {
+ } else if (MAVEN.CLASSNAMES.equals(field)) {
return classNames;
- }
- else if ( MAVEN.REPOSITORY_ID.equals( field ) )
- {
+ } else if (MAVEN.REPOSITORY_ID.equals(field)) {
return repository;
}
@@ -511,46 +473,26 @@ public class ArtifactInfo
return null;
}
- public ArtifactInfo setFieldValue( Field field, String value )
- {
- if ( MAVEN.GROUP_ID.equals( field ) )
- {
+ public ArtifactInfo setFieldValue(Field field, String value) {
+ if (MAVEN.GROUP_ID.equals(field)) {
groupId = value;
- }
- else if ( MAVEN.ARTIFACT_ID.equals( field ) )
- {
+ } else if (MAVEN.ARTIFACT_ID.equals(field)) {
artifactId = value;
- }
- else if ( MAVEN.VERSION.equals( field ) )
- {
+ } else if (MAVEN.VERSION.equals(field)) {
version = value;
- }
- else if ( MAVEN.PACKAGING.equals( field ) )
- {
+ } else if (MAVEN.PACKAGING.equals(field)) {
packaging = value;
- }
- else if ( MAVEN.CLASSIFIER.equals( field ) )
- {
+ } else if (MAVEN.CLASSIFIER.equals(field)) {
classifier = value;
- }
- else if ( MAVEN.SHA1.equals( field ) )
- {
+ } else if (MAVEN.SHA1.equals(field)) {
sha1 = value;
- }
- else if ( MAVEN.NAME.equals( field ) )
- {
+ } else if (MAVEN.NAME.equals(field)) {
name = value;
- }
- else if ( MAVEN.DESCRIPTION.equals( field ) )
- {
+ } else if (MAVEN.DESCRIPTION.equals(field)) {
description = value;
- }
- else if ( MAVEN.CLASSNAMES.equals( field ) )
- {
+ } else if (MAVEN.CLASSNAMES.equals(field)) {
classNames = value;
- }
- else if ( MAVEN.REPOSITORY_ID.equals( field ) )
- {
+ } else if (MAVEN.REPOSITORY_ID.equals(field)) {
repository = value;
}
@@ -562,77 +504,60 @@ public class ArtifactInfo
// Utils
// ----------------------------------------------------------------------------
- public static String nvl( String v )
- {
+ public static String nvl(String v) {
return v == null ? NA : v;
}
- public static String renvl( String v )
- {
- return NA.equals( v ) ? null : v;
+ public static String renvl(String v) {
+ return NA.equals(v) ? null : v;
}
- public static String lst2str( Collection<String> list )
- {
+ public static String lst2str(Collection<String> list) {
StringBuilder sb = new StringBuilder();
- for ( String s : list )
- {
- sb.append( s ).append( ArtifactInfo.FS );
+ for (String s : list) {
+ sb.append(s).append(ArtifactInfo.FS);
}
- return sb.length() == 0 ? sb.toString() : sb.substring( 0, sb.length() - 1 );
+ return sb.length() == 0 ? sb.toString() : sb.substring(0, sb.length() - 1);
}
- public static List<String> str2lst( String str )
- {
- return Arrays.asList( ArtifactInfo.FS_PATTERN.split( str ) );
+ public static List<String> str2lst(String str) {
+ return Arrays.asList(ArtifactInfo.FS_PATTERN.split(str));
}
/**
* A version comparator
*/
- static class VersionComparator
- implements Comparator<ArtifactInfo>
- {
- public int compare( final ArtifactInfo f1, final ArtifactInfo f2 )
- {
- int n = f1.groupId.compareTo( f2.groupId );
- if ( n != 0 )
- {
+ static class VersionComparator implements Comparator<ArtifactInfo> {
+ public int compare(final ArtifactInfo f1, final ArtifactInfo f2) {
+ int n = f1.groupId.compareTo(f2.groupId);
+ if (n != 0) {
return n;
}
- n = f1.artifactId.compareTo( f2.artifactId );
- if ( n != 0 )
- {
+ n = f1.artifactId.compareTo(f2.artifactId);
+ if (n != 0) {
return n;
}
- n = -f1.getArtifactVersion().compareTo( f2.getArtifactVersion() );
- if ( n != 0 )
- {
+ n = -f1.getArtifactVersion().compareTo(f2.getArtifactVersion());
+ if (n != 0) {
return n;
}
{
final String c1 = f1.classifier;
final String c2 = f2.classifier;
- if ( c1 == null )
- {
- if ( c2 != null )
- {
+ if (c1 == null) {
+ if (c2 != null) {
return -1;
}
- }
- else
- {
- if ( c2 == null )
- {
+ } else {
+ if (c2 == null) {
return 1;
}
- n = c1.compareTo( c2 );
- if ( n != 0 )
- {
+ n = c1.compareTo(c2);
+ if (n != 0) {
return n;
}
}
@@ -641,13 +566,10 @@ public class ArtifactInfo
{
final String p1 = f1.packaging;
final String p2 = f2.packaging;
- if ( p1 == null )
- {
+ if (p1 == null) {
return p2 == null ? 0 : -1;
- }
- else
- {
- return p2 == null ? 1 : p1.compareTo( p2 );
+ } else {
+ return p2 == null ? 1 : p1.compareTo(p2);
}
}
}
@@ -656,452 +578,358 @@ public class ArtifactInfo
/**
* A repository and version comparator
*/
- static class RepositoryVersionComparator
- extends VersionComparator
- {
+ static class RepositoryVersionComparator extends VersionComparator {
@Override
- public int compare( final ArtifactInfo f1, final ArtifactInfo f2 )
- {
- final int n = super.compare( f1, f2 );
- if ( n != 0 )
- {
+ public int compare(final ArtifactInfo f1, final ArtifactInfo f2) {
+ final int n = super.compare(f1, f2);
+ if (n != 0) {
return n;
}
final String r1 = f1.repository;
final String r2 = f2.repository;
- if ( r1 == null )
- {
+ if (r1 == null) {
return r2 == null ? 0 : -1;
- }
- else
- {
- return r2 == null ? 1 : r1.compareTo( r2 );
+ } else {
+ return r2 == null ? 1 : r1.compareTo(r2);
}
}
}
-
+
/**
* A context and version comparator
*/
- static class ContextVersionComparator
- extends VersionComparator
- {
+ static class ContextVersionComparator extends VersionComparator {
@Override
- public int compare( final ArtifactInfo f1, final ArtifactInfo f2 )
- {
- final int n = super.compare( f1, f2 );
- if ( n != 0 )
- {
+ public int compare(final ArtifactInfo f1, final ArtifactInfo f2) {
+ final int n = super.compare(f1, f2);
+ if (n != 0) {
return n;
}
final String r1 = f1.context;
final String r2 = f2.context;
- if ( r1 == null )
- {
+ if (r1 == null) {
return r2 == null ? 0 : -1;
- }
- else
- {
- return r2 == null ? 1 : r1.compareTo( r2 );
+ } else {
+ return r2 == null ? 1 : r1.compareTo(r2);
}
}
}
- public String getFileName( )
- {
+ public String getFileName() {
return fileName;
}
- public void setFileName( String fileName )
- {
+ public void setFileName(String fileName) {
this.fileName = fileName;
}
- public String getFileExtension( )
- {
+ public String getFileExtension() {
return fileExtension;
}
- public void setFileExtension( String fileExtension )
- {
+ public void setFileExtension(String fileExtension) {
this.fileExtension = fileExtension;
}
- public String getGroupId( )
- {
+ public String getGroupId() {
return groupId;
}
- public void setGroupId( String groupId )
- {
+ public void setGroupId(String groupId) {
this.groupId = groupId;
}
- public String getArtifactId( )
- {
+ public String getArtifactId() {
return artifactId;
}
- public void setArtifactId( String artifactId )
- {
+ public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
- public String getVersion( )
- {
+ public String getVersion() {
return version;
}
- public void setVersion( String version )
- {
+ public void setVersion(String version) {
this.version = version;
}
- public void setArtifactVersion( Version artifactVersion )
- {
+ public void setArtifactVersion(Version artifactVersion) {
this.artifactVersion = artifactVersion;
}
- public String getClassifier( )
- {
+ public String getClassifier() {
return classifier;
}
- public void setClassifier( String classifier )
- {
+ public void setClassifier(String classifier) {
this.classifier = classifier;
}
- public String getPackaging( )
- {
+ public String getPackaging() {
return packaging;
}
- public void setPackaging( String packaging )
- {
+ public void setPackaging(String packaging) {
this.packaging = packaging;
}
- public String getName( )
- {
+ public String getName() {
return name;
}
- public void setName( String name )
- {
+ public void setName(String name) {
this.name = name;
}
- public String getDescription( )
- {
+ public String getDescription() {
return description;
}
- public void setDescription( String description )
- {
+ public void setDescription(String description) {
this.description = description;
}
- public long getLastModified( )
- {
+ public long getLastModified() {
return lastModified;
}
- public void setLastModified( long lastModified )
- {
+ public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
- public long getSize( )
- {
+ public long getSize() {
return size;
}
- public void setSize( long size )
- {
+ public void setSize(long size) {
this.size = size;
}
- public String getMd5( )
- {
+ public String getMd5() {
return md5;
}
- public void setMd5( String md5 )
- {
+ public void setMd5(String md5) {
this.md5 = md5;
}
- public String getSha1( )
- {
+ public String getSha1() {
return sha1;
}
- public void setSha1( String sha1 )
- {
+ public void setSha1(String sha1) {
this.sha1 = sha1;
}
- public ArtifactAvailability getSourcesExists( )
- {
+ public ArtifactAvailability getSourcesExists() {
return sourcesExists;
}
- public void setSourcesExists( ArtifactAvailability sourcesExists )
- {
+ public void setSourcesExists(ArtifactAvailability sourcesExists) {
this.sourcesExists = sourcesExists;
}
- public ArtifactAvailability getJavadocExists( )
- {
+ public ArtifactAvailability getJavadocExists() {
return javadocExists;
}
- public void setJavadocExists( ArtifactAvailability javadocExists )
- {
+ public void setJavadocExists(ArtifactAvailability javadocExists) {
this.javadocExists = javadocExists;
}
- public ArtifactAvailability getSignatureExists( )
- {
+ public ArtifactAvailability getSignatureExists() {
return signatureExists;
}
- public void setSignatureExists( ArtifactAvailability signatureExists )
- {
+ public void setSignatureExists(ArtifactAvailability signatureExists) {
this.signatureExists = signatureExists;
}
- public String getClassNames( )
- {
+ public String getClassNames() {
return classNames;
}
- public void setClassNames( String classNames )
- {
+ public void setClassNames(String classNames) {
this.classNames = classNames;
}
- public String getRepository( )
- {
+ public String getRepository() {
return repository;
}
- public void setRepository( String repository )
- {
+ public void setRepository(String repository) {
this.repository = repository;
}
- public String getPath( )
- {
+ public String getPath() {
return path;
}
- public void setPath( String path )
- {
+ public void setPath(String path) {
this.path = path;
}
- public String getRemoteUrl( )
- {
+ public String getRemoteUrl() {
return remoteUrl;
}
- public void setRemoteUrl( String remoteUrl )
- {
+ public void setRemoteUrl(String remoteUrl) {
this.remoteUrl = remoteUrl;
}
- public String getContext( )
- {
+ public String getContext() {
return context;
}
- public void setContext( String context )
- {
+ public void setContext(String context) {
this.context = context;
}
- public String getPrefix( )
- {
+ public String getPrefix() {
return prefix;
}
- public void setPrefix( String prefix )
- {
+ public void setPrefix(String prefix) {
this.prefix = prefix;
}
- public List<String> getGoals( )
- {
+ public List<String> getGoals() {
return goals;
}
- public void setGoals( List<String> goals )
- {
+ public void setGoals(List<String> goals) {
this.goals = goals;
}
- public String getBundleVersion( )
- {
+ public String getBundleVersion() {
return bundleVersion;
}
- public void setBundleVersion( String bundleVersion )
- {
+ public void setBundleVersion(String bundleVersion) {
this.bundleVersion = bundleVersion;
}
- public String getBundleSymbolicName( )
- {
+ public String getBundleSymbolicName() {
return bundleSymbolicName;
}
- public void setBundleSymbolicName( String bundleSymbolicName )
- {
+ public void setBundleSymbolicName(String bundleSymbolicName) {
this.bundleSymbolicName = bundleSymbolicName;
}
- public String getBundleExportPackage( )
- {
+ public String getBundleExportPackage() {
return bundleExportPackage;
}
- public void setBundleExportPackage( String bundleExportPackage )
- {
+ public void setBundleExportPackage(String bundleExportPackage) {
this.bundleExportPackage = bundleExportPackage;
}
- public String getBundleExportService( )
- {
+ public String getBundleExportService() {
return bundleExportService;
}
- public void setBundleExportService( String bundleExportService )
- {
+ public void setBundleExportService(String bundleExportService) {
this.bundleExportService = bundleExportService;
}
- public String getBundleDescription( )
- {
+ public String getBundleDescription() {
return bundleDescription;
}
- public void setBundleDescription( String bundleDescription )
- {
+ public void setBundleDescription(String bundleDescription) {
this.bundleDescription = bundleDescription;
}
- public String getBundleName( )
- {
+ public String getBundleName() {
return bundleName;
}
- public void setBundleName( String bundleName )
- {
+ public void setBundleName(String bundleName) {
this.bundleName = bundleName;
}
- public String getBundleLicense( )
- {
+ public String getBundleLicense() {
return bundleLicense;
}
- public void setBundleLicense( String bundleLicense )
- {
+ public void setBundleLicense(String bundleLicense) {
this.bundleLicense = bundleLicense;
}
- public String getBundleDocUrl( )
- {
+ public String getBundleDocUrl() {
return bundleDocUrl;
}
- public void setBundleDocUrl( String bundleDocUrl )
- {
+ public void setBundleDocUrl(String bundleDocUrl) {
this.bundleDocUrl = bundleDocUrl;
}
- public String getBundleImportPackage( )
- {
+ public String getBundleImportPackage() {
return bundleImportPackage;
}
- public void setBundleImportPackage( String bundleImportPackage )
- {
+ public void setBundleImportPackage(String bundleImportPackage) {
this.bundleImportPackage = bundleImportPackage;
}
- public String getBundleRequireBundle( )
- {
+ public String getBundleRequireBundle() {
return bundleRequireBundle;
}
- public void setBundleRequireBundle( String bundleRequireBundle )
- {
+ public void setBundleRequireBundle(String bundleRequireBundle) {
this.bundleRequireBundle = bundleRequireBundle;
}
- public VersionScheme getVersionScheme( )
- {
+ public VersionScheme getVersionScheme() {
return versionScheme;
}
- public void setFields( List<Field> fields )
- {
+ public void setFields(List<Field> fields) {
this.fields = fields;
}
- public String getBundleProvideCapability()
- {
+ public String getBundleProvideCapability() {
return bundleProvideCapability;
}
- public void setBundleProvideCapability( String bundleProvideCapability )
- {
+ public void setBundleProvideCapability(String bundleProvideCapability) {
this.bundleProvideCapability = bundleProvideCapability;
}
- public String getBundleRequireCapability()
- {
+ public String getBundleRequireCapability() {
return bundleRequireCapability;
}
- public void setBundleRequireCapability( String bundleRequireCapability )
- {
+ public void setBundleRequireCapability(String bundleRequireCapability) {
this.bundleRequireCapability = bundleRequireCapability;
}
- public String getSha256()
- {
+ public String getSha256() {
return sha256;
}
- public void setSha256( String sha256 )
- {
+ public void setSha256(String sha256) {
this.sha256 = sha256;
}
- public String getBundleFragmentHost()
- {
+ public String getBundleFragmentHost() {
return bundleFragmentHost;
}
- public void setBundleFragmentHost( String bundleFragmentHost )
- {
+ public void setBundleFragmentHost(String bundleFragmentHost) {
this.bundleFragmentHost = bundleFragmentHost;
}
- public String getBundleRequiredExecutionEnvironment()
- {
+ public String getBundleRequiredExecutionEnvironment() {
return bundleRequiredExecutionEnvironment;
}
- public void setBundleRequiredExecutionEnvironment( String bundleRequiredExecutionEnvironment )
- {
+ public void setBundleRequiredExecutionEnvironment(String bundleRequiredExecutionEnvironment) {
this.bundleRequiredExecutionEnvironment = bundleRequiredExecutionEnvironment;
}
-
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoFilter.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoFilter.java
index 24f66b7..4e2b33f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoFilter.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoFilter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,17 +16,17 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.maven.index.context.IndexingContext;
/**
* ArtifactInfoFilter is used to filter out components before they are handed over to searcher (and well before paging
* is implemented). One can use it for: permission-based filtering, collapsing result sets, etc.
- *
+ *
* @author cstamas
* @see AndMultiArtifactInfoFilter
*/
-public interface ArtifactInfoFilter
-{
- boolean accepts( IndexingContext ctx, ArtifactInfo ai );
+public interface ArtifactInfoFilter {
+ boolean accepts(IndexingContext ctx, ArtifactInfo ai);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoGroup.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoGroup.java
index c7881aa..c5e06f7 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoGroup.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoGroup.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Comparator;
import java.util.Set;
@@ -25,46 +24,38 @@ import java.util.TreeSet;
/**
* An object that holds grouped sets of {@link ArtifactInfo} in case of grouped search.
- *
+ *
* @author Tamas Cservenak
*/
-public class ArtifactInfoGroup
-{
+public class ArtifactInfoGroup {
private String groupKey;
private final Set<ArtifactInfo> artifactInfos;
- public ArtifactInfoGroup( String groupKey )
- {
- this( groupKey, ArtifactInfo.VERSION_COMPARATOR );
+ public ArtifactInfoGroup(String groupKey) {
+ this(groupKey, ArtifactInfo.VERSION_COMPARATOR);
}
- public ArtifactInfoGroup( String groupKey, Comparator<ArtifactInfo> comparator )
- {
+ public ArtifactInfoGroup(String groupKey, Comparator<ArtifactInfo> comparator) {
this.groupKey = groupKey;
- this.artifactInfos = new TreeSet<>( comparator );
+ this.artifactInfos = new TreeSet<>(comparator);
}
- public String getGroupKey()
- {
+ public String getGroupKey() {
return groupKey;
}
- public boolean addArtifactInfo( ArtifactInfo artifactInfo )
- {
- return artifactInfos.add( artifactInfo );
+ public boolean addArtifactInfo(ArtifactInfo artifactInfo) {
+ return artifactInfos.add(artifactInfo);
}
- public Set<ArtifactInfo> getArtifactInfos()
- {
+ public Set<ArtifactInfo> getArtifactInfos() {
return artifactInfos;
}
@Override
- public String toString()
- {
+ public String toString() {
return groupKey + "=" + artifactInfos;
}
-
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoPostprocessor.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoPostprocessor.java
index 54675e1..c059a5f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoPostprocessor.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoPostprocessor.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.maven.index.context.IndexingContext;
@@ -25,10 +24,9 @@ import org.apache.maven.index.context.IndexingContext;
* ArtifactInfoPostprocessor is used to postprocess the ArtifactInfo, after it passed filtering and paging but before it
* is handed over to client performing search. Use is typically like adding some "calculated field", or formatting, and
* such.
- *
+ *
* @author cstamas
*/
-public interface ArtifactInfoPostprocessor
-{
- void postprocess( IndexingContext ctx, ArtifactInfo ai );
+public interface ArtifactInfoPostprocessor {
+ void postprocess(IndexingContext ctx, ArtifactInfo ai);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoRecord.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoRecord.java
index f1bfe85..f51a7d0 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoRecord.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactInfoRecord.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.Serializable;
import java.util.regex.Pattern;
@@ -26,18 +25,16 @@ import org.apache.lucene.document.StoredField;
/**
* Pulling out ArtifactInfo, clearing up. TBD. This gonna be extensible "map-like" class with fields.
- *
+ *
* @author cstamas
*/
-public class ArtifactInfoRecord
- implements Serializable
-{
+public class ArtifactInfoRecord implements Serializable {
private static final long serialVersionUID = -4577081994768263824L;
/** Field separator */
public static final String FS = "|";
- public static final Pattern FS_PATTERN = Pattern.compile( Pattern.quote( FS ) );
+ public static final Pattern FS_PATTERN = Pattern.compile(Pattern.quote(FS));
/** Non available value */
public static final String NA = "NA";
@@ -51,14 +48,21 @@ public class ArtifactInfoRecord
/**
* Unique groupId, artifactId, version, classifier, extension (or packaging). Stored, indexed untokenized
*/
- public static final IndexerField FLD_UINFO = new IndexerField( NEXUS.UINFO, IndexerFieldVersion.V1, "u",
- "Artifact UINFO (as keyword, stored)", IndexerField.KEYWORD_STORED );
+ public static final IndexerField FLD_UINFO = new IndexerField(
+ NEXUS.UINFO,
+ IndexerFieldVersion.V1,
+ "u",
+ "Artifact UINFO (as keyword, stored)",
+ IndexerField.KEYWORD_STORED);
/**
* Del: contains UINFO to mark record as deleted (needed for incremental updates!). The original document IS
* removed, but this marker stays on index to note that fact.
*/
- public static final IndexerField FLD_DELETED = new IndexerField( NEXUS.DELETED, IndexerFieldVersion.V1, "del",
- "Deleted field, will contain UINFO if document is deleted from index (not indexed, stored)", StoredField.TYPE );
-
+ public static final IndexerField FLD_DELETED = new IndexerField(
+ NEXUS.DELETED,
+ IndexerFieldVersion.V1,
+ "del",
+ "Deleted field, will contain UINFO if document is deleted from index (not indexed, stored)",
+ StoredField.TYPE);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/ArtifactScanningListener.java b/indexer-core/src/main/java/org/apache/maven/index/ArtifactScanningListener.java
index cb92c54..af320be 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/ArtifactScanningListener.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/ArtifactScanningListener.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,21 +16,19 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.maven.index.context.IndexingContext;
/**
* A listener notified during repository scan process to track progress, collect results, etc.
- *
+ *
* @author Jason van Zyl
*/
-public interface ArtifactScanningListener
- extends ArtifactDiscoveryListener
-{
- void scanningStarted( IndexingContext ctx );
-
- void scanningFinished( IndexingContext ctx, ScanningResult result );
+public interface ArtifactScanningListener extends ArtifactDiscoveryListener {
+ void scanningStarted(IndexingContext ctx);
- void artifactError( ArtifactContext ac, Exception e );
+ void scanningFinished(IndexingContext ctx, ScanningResult result);
+ void artifactError(ArtifactContext ac, Exception e);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/CleaningEncoder.java b/indexer-core/src/main/java/org/apache/maven/index/CleaningEncoder.java
index edc2707..4b4c133 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/CleaningEncoder.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/CleaningEncoder.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,14 +16,12 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.lucene.search.highlight.Encoder;
-public class CleaningEncoder
- implements Encoder
-{
- public String encodeText( String originalText )
- {
- return originalText.replace( "\n", "" );
+public class CleaningEncoder implements Encoder {
+ public String encodeText(String originalText) {
+ return originalText.replace("\n", "");
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultArtifactContextProducer.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultArtifactContextProducer.java
index 737e51b..1944758 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultArtifactContextProducer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultArtifactContextProducer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,10 +16,12 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.File;
import org.apache.maven.index.artifact.ArtifactPackagingMapper;
@@ -36,15 +36,13 @@ import org.codehaus.plexus.util.StringUtils;
/**
* A default implementation of the {@link ArtifactContextProducer}.
- *
+ *
* @author Tamas Cservenak
* @author Eugene Kuleshov
*/
@Singleton
@Named
-public class DefaultArtifactContextProducer
- implements ArtifactContextProducer
-{
+public class DefaultArtifactContextProducer implements ArtifactContextProducer {
private final ArtifactPackagingMapper mapper;
@@ -52,61 +50,51 @@ public class DefaultArtifactContextProducer
private Locator ml = new MetadataLocator();
-
@Inject
- public DefaultArtifactContextProducer( ArtifactPackagingMapper mapper )
- {
+ public DefaultArtifactContextProducer(ArtifactPackagingMapper mapper) {
this.mapper = mapper;
}
/**
* Get ArtifactContext for given pom or artifact (jar, war, etc). A file can be
*/
- public ArtifactContext getArtifactContext( IndexingContext context, File file )
- {
+ public ArtifactContext getArtifactContext(IndexingContext context, File file) {
// TODO shouldn't this use repository layout instead?
String repositoryPath = context.getRepository().getAbsolutePath();
String artifactPath = file.getAbsolutePath();
// protection from IndexOutOfBounds
- if ( artifactPath.length() <= repositoryPath.length() )
- {
+ if (artifactPath.length() <= repositoryPath.length()) {
return null; // not an artifact
}
- if ( !isIndexable( file ) )
- {
+ if (!isIndexable(file)) {
return null; // skipped
}
- Gav gav = getGavFromPath( context, repositoryPath, artifactPath );
+ Gav gav = getGavFromPath(context, repositoryPath, artifactPath);
- if ( gav == null )
- {
+ if (gav == null) {
return null; // not an artifact, but rather metadata
}
File pom;
File artifact;
- if ( file.getName().endsWith( ".pom" ) )
- {
- ArtifactLocator al = new ArtifactLocator( mapper );
- artifact = al.locate( file, context.getGavCalculator(), gav );
+ if (file.getName().endsWith(".pom")) {
+ ArtifactLocator al = new ArtifactLocator(mapper);
+ artifact = al.locate(file, context.getGavCalculator(), gav);
// If we found the matching artifact, switch over to indexing that, instead of the pom
- if ( artifact != null )
- {
- gav = getGavFromPath( context, repositoryPath, artifact.getAbsolutePath() );
+ if (artifact != null) {
+ gav = getGavFromPath(context, repositoryPath, artifact.getAbsolutePath());
}
pom = file;
- }
- else
- {
+ } else {
artifact = file;
- pom = pl.locate( file, context.getGavCalculator(), gav );
+ pom = pl.locate(file, context.getGavCalculator(), gav);
}
String groupId = gav.getGroupId();
@@ -117,48 +105,45 @@ public class DefaultArtifactContextProducer
String classifier = gav.getClassifier();
- ArtifactInfo ai =
- new ArtifactInfo( context.getRepositoryId(), groupId, artifactId, version, classifier, gav.getExtension() );
+ ArtifactInfo ai = new ArtifactInfo(
+ context.getRepositoryId(), groupId, artifactId, version, classifier, gav.getExtension());
// store extension if classifier is not empty
- if ( !StringUtils.isEmpty( ai.getClassifier() ) )
- {
- ai.setPackaging( gav.getExtension() );
+ if (!StringUtils.isEmpty(ai.getClassifier())) {
+ ai.setPackaging(gav.getExtension());
}
- ai.setFileName( file.getName() );
- ai.setFileExtension( gav.getExtension() );
+ ai.setFileName(file.getName());
+ ai.setFileExtension(gav.getExtension());
- File metadata = ml.locate( pom );
+ File metadata = ml.locate(pom);
- return new ArtifactContext( pom, artifact, metadata, ai, gav );
+ return new ArtifactContext(pom, artifact, metadata, ai, gav);
}
- protected boolean isIndexable( File file )
- {
- if ( file == null )
- {
+ protected boolean isIndexable(File file) {
+ if (file == null) {
return false;
}
String filename = file.getName();
- return !filename.equals( "maven-metadata.xml" )
- && !( filename.startsWith( "maven-metadata-" ) && filename.endsWith( ".xml" ) )
- && !( filename.startsWith( "_" ) && filename.endsWith( ".repositories" ) )
+ return !filename.equals("maven-metadata.xml")
+ && !(filename.startsWith("maven-metadata-") && filename.endsWith(".xml"))
+ && !(filename.startsWith("_") && filename.endsWith(".repositories"))
// || filename.endsWith( "-javadoc.jar" )
// || filename.endsWith( "-javadocs.jar" )
// || filename.endsWith( "-sources.jar" )
- && !filename.endsWith( ".properties" )
+ && !filename.endsWith(".properties")
// || filename.endsWith( ".xml" ) // NEXUS-3029
- && !filename.endsWith( ".asc" ) && !filename.endsWith( ".md5" ) && !filename.endsWith( ".sha1" );
+ && !filename.endsWith(".asc")
+ && !filename.endsWith(".md5")
+ && !filename.endsWith(".sha1");
}
- protected Gav getGavFromPath( IndexingContext context, String repositoryPath, String artifactPath )
- {
- String path = artifactPath.substring( repositoryPath.length() + 1 ).replace( '\\', '/' );
+ protected Gav getGavFromPath(IndexingContext context, String repositoryPath, String artifactPath) {
+ String path = artifactPath.substring(repositoryPath.length() + 1).replace('\\', '/');
- return context.getGavCalculator().pathToGav( path );
+ return context.getGavCalculator().pathToGav(path);
}
-
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java
index 9590fa2..771cf03 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,10 +16,12 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.maven.index.context.ContextMemberProvider;
@@ -46,14 +47,12 @@ import org.apache.maven.index.util.IndexCreatorSorter;
/**
* A default {@link Indexer} implementation.
- *
+ *
* @author Tamas Cservenak
*/
@Singleton
@Named
-public class DefaultIndexer
- implements Indexer
-{
+public class DefaultIndexer implements Indexer {
private final SearchEngine searcher;
@@ -61,12 +60,8 @@ public class DefaultIndexer
private final QueryCreator queryCreator;
-
@Inject
- public DefaultIndexer( SearchEngine searcher,
- IndexerEngine indexerEngine,
- QueryCreator queryCreator )
- {
+ public DefaultIndexer(SearchEngine searcher, IndexerEngine indexerEngine, QueryCreator queryCreator) {
this.searcher = searcher;
this.indexerEngine = indexerEngine;
this.queryCreator = queryCreator;
@@ -76,71 +71,73 @@ public class DefaultIndexer
// Contexts
// ----------------------------------------------------------------------------
- public IndexingContext createIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- String repositoryUrl, String indexUpdateUrl, boolean searchable,
- boolean reclaim, List<? extends IndexCreator> indexers )
- throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException
- {
- final IndexingContext context =
- new DefaultIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
- IndexCreatorSorter.sort( indexers ), reclaim );
- context.setSearchable( searchable );
+ public IndexingContext createIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ boolean searchable,
+ boolean reclaim,
+ List<? extends IndexCreator> indexers)
+ throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException {
+ final IndexingContext context = new DefaultIndexingContext(
+ id,
+ repositoryId,
+ repository,
+ indexDirectory,
+ repositoryUrl,
+ indexUpdateUrl,
+ IndexCreatorSorter.sort(indexers),
+ reclaim);
+ context.setSearchable(searchable);
return context;
}
- public IndexingContext createMergedIndexingContext( String id, String repositoryId, File repository,
- File indexDirectory, boolean searchable,
- ContextMemberProvider membersProvider )
- throws IOException
- {
+ public IndexingContext createMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException {
IndexingContext context =
- new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
+ new MergedIndexingContext(id, repositoryId, repository, indexDirectory, searchable, membersProvider);
return context;
}
- public void closeIndexingContext( IndexingContext context, boolean deleteFiles )
- throws IOException
- {
- context.close( deleteFiles );
+ public void closeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException {
+ context.close(deleteFiles);
}
// ----------------------------------------------------------------------------
// Modifying
// ----------------------------------------------------------------------------
- public void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
- throws IOException
- {
- if ( ac != null )
- {
- indexerEngine.update( context, ac );
+ public void addArtifactToIndex(ArtifactContext ac, IndexingContext context) throws IOException {
+ if (ac != null) {
+ indexerEngine.update(context, ac);
context.commit();
}
}
- public void addArtifactsToIndex( Collection<ArtifactContext> ac, IndexingContext context )
- throws IOException
- {
- if ( ac != null && !ac.isEmpty() )
- {
- for ( ArtifactContext actx : ac )
- {
- indexerEngine.update( context, actx );
+ public void addArtifactsToIndex(Collection<ArtifactContext> ac, IndexingContext context) throws IOException {
+ if (ac != null && !ac.isEmpty()) {
+ for (ArtifactContext actx : ac) {
+ indexerEngine.update(context, actx);
}
context.commit();
}
}
- public void deleteArtifactsFromIndex( Collection<ArtifactContext> ac, IndexingContext context )
- throws IOException
- {
- if ( ac != null && !ac.isEmpty() )
- {
- for ( ArtifactContext actx : ac )
- {
- indexerEngine.remove( context, actx );
+ public void deleteArtifactsFromIndex(Collection<ArtifactContext> ac, IndexingContext context) throws IOException {
+ if (ac != null && !ac.isEmpty()) {
+ for (ArtifactContext actx : ac) {
+ indexerEngine.remove(context, actx);
context.commit();
}
@@ -151,43 +148,28 @@ public class DefaultIndexer
// Searching
// ----------------------------------------------------------------------------
- public FlatSearchResponse searchFlat( FlatSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- return new FlatSearchResponse( request.getQuery(), 0, Collections.emptySet() );
- }
- else
- {
- return searcher.forceSearchFlatPaged( request, request.getContexts() );
+ public FlatSearchResponse searchFlat(FlatSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ return new FlatSearchResponse(request.getQuery(), 0, Collections.emptySet());
+ } else {
+ return searcher.forceSearchFlatPaged(request, request.getContexts());
}
}
- public IteratorSearchResponse searchIterator( IteratorSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- return IteratorSearchResponse.empty( request.getQuery() );
- }
- else
- {
- return searcher.forceSearchIteratorPaged( request, request.getContexts() );
+ public IteratorSearchResponse searchIterator(IteratorSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ return IteratorSearchResponse.empty(request.getQuery());
+ } else {
+ return searcher.forceSearchIteratorPaged(request, request.getContexts());
}
}
- public GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- return new GroupedSearchResponse( request.getQuery(), 0, Collections.emptyMap() );
- }
- else
- {
+ public GroupedSearchResponse searchGrouped(GroupedSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ return new GroupedSearchResponse(request.getQuery(), 0, Collections.emptyMap());
+ } else {
// search targeted
- return searcher.forceSearchGrouped( request, request.getContexts() );
+ return searcher.forceSearchGrouped(request, request.getContexts());
}
}
@@ -195,37 +177,27 @@ public class DefaultIndexer
// Identification
// ----------------------------------------------------------------------------
- public Collection<ArtifactInfo> identify( final File artifact, final Collection<IndexingContext> contexts )
- throws IOException
- {
- try ( FileInputStream is = new FileInputStream( artifact ) )
- {
- final MessageDigest sha1 = MessageDigest.getInstance( "SHA-1" );
+ public Collection<ArtifactInfo> identify(final File artifact, final Collection<IndexingContext> contexts)
+ throws IOException {
+ try (FileInputStream is = new FileInputStream(artifact)) {
+ final MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
final byte[] buff = new byte[4096];
int n;
- while ( ( n = is.read( buff ) ) > -1 )
- {
- sha1.update( buff, 0, n );
+ while ((n = is.read(buff)) > -1) {
+ sha1.update(buff, 0, n);
}
byte[] digest = sha1.digest();
- return identify( constructQuery( MAVEN.SHA1, new SourcedSearchExpression( encode( digest ) ) ), contexts );
- }
- catch ( NoSuchAlgorithmException ex )
- {
- throw new IOException( "Unable to calculate digest", ex );
+ return identify(constructQuery(MAVEN.SHA1, new SourcedSearchExpression(encode(digest))), contexts);
+ } catch (NoSuchAlgorithmException ex) {
+ throw new IOException("Unable to calculate digest", ex);
}
}
- public Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
- throws IOException
- {
- try ( IteratorSearchResponse result = searcher.searchIteratorPaged(
- new IteratorSearchRequest( query ), contexts ) )
- {
- final List<ArtifactInfo> ais = new ArrayList<>( result.getTotalHitsCount() );
- for ( ArtifactInfo ai : result )
- {
- ais.add( ai );
+ public Collection<ArtifactInfo> identify(Query query, Collection<IndexingContext> contexts) throws IOException {
+ try (IteratorSearchResponse result = searcher.searchIteratorPaged(new IteratorSearchRequest(query), contexts)) {
+ final List<ArtifactInfo> ais = new ArrayList<>(result.getTotalHitsCount());
+ for (ArtifactInfo ai : result) {
+ ais.add(ai);
}
return ais;
}
@@ -235,40 +207,31 @@ public class DefaultIndexer
// Query construction
// ----------------------------------------------------------------------------
- public Query constructQuery( Field field, SearchExpression expression )
- throws IllegalArgumentException
- {
- try
- {
- return queryCreator.constructQuery( field, expression );
- }
- catch ( ParseException e )
- {
- throw new IllegalArgumentException( e );
+ public Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException {
+ try {
+ return queryCreator.constructQuery(field, expression);
+ } catch (ParseException e) {
+ throw new IllegalArgumentException(e);
}
}
- public Query constructQuery( Field field, String expression, SearchType searchType )
- throws IllegalArgumentException
- {
- return constructQuery( field, new SearchTypedStringSearchExpression( expression, searchType ) );
+ public Query constructQuery(Field field, String expression, SearchType searchType) throws IllegalArgumentException {
+ return constructQuery(field, new SearchTypedStringSearchExpression(expression, searchType));
}
// ==
private static final char[] DIGITS = "0123456789abcdef".toCharArray();
- private static String encode( byte[] digest )
- {
+ private static String encode(byte[] digest) {
char[] buff = new char[digest.length * 2];
int n = 0;
- for ( byte b : digest )
- {
- buff[n++] = DIGITS[( 0xF0 & b ) >> 4];
+ for (byte b : digest) {
+ buff[n++] = DIGITS[(0xF0 & b) >> 4];
buff[n++] = DIGITS[0x0F & b];
}
- return new String( buff );
+ return new String(buff);
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java
index 46965f0..5127a2a 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultIndexerEngine.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,9 +16,11 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@@ -39,50 +39,40 @@ import org.apache.maven.index.creator.MinimalArtifactInfoIndexCreator;
/**
* A default {@link IndexerEngine} implementation.
- *
+ *
* @author Tamas Cservenak
*/
@Singleton
@Named
-public class DefaultIndexerEngine
- implements IndexerEngine
-{
+public class DefaultIndexerEngine implements IndexerEngine {
- public void index( IndexingContext context, ArtifactContext ac )
- throws IOException
- {
+ public void index(IndexingContext context, ArtifactContext ac) throws IOException {
// skip artifacts not obeying repository layout (whether m1 or m2)
- if ( ac != null && ac.getGav() != null )
- {
- Document d = ac.createDocument( context );
+ if (ac != null && ac.getGav() != null) {
+ Document d = ac.createDocument(context);
- if ( d != null )
- {
- context.getIndexWriter().addDocument( d );
+ if (d != null) {
+ context.getIndexWriter().addDocument(d);
context.updateTimestamp();
}
}
}
- public void update( IndexingContext context, ArtifactContext ac )
- throws IOException
- {
- if ( ac != null && ac.getGav() != null )
- {
- Document d = ac.createDocument( context );
+ public void update(IndexingContext context, ArtifactContext ac) throws IOException {
+ if (ac != null && ac.getGav() != null) {
+ Document d = ac.createDocument(context);
- if ( d != null )
- {
- Document old = getOldDocument( context, ac );
+ if (d != null) {
+ Document old = getOldDocument(context, ac);
- if ( !equals( d, old ) )
- {
+ if (!equals(d, old)) {
IndexWriter w = context.getIndexWriter();
- w.updateDocument( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ), d );
+ w.updateDocument(
+ new Term(ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo()), d);
- updateGroups( context, ac );
+ updateGroups(context, ac);
context.updateTimestamp();
}
@@ -90,110 +80,91 @@ public class DefaultIndexerEngine
}
}
- public void remove( IndexingContext context, ArtifactContext ac )
- throws IOException
- {
- if ( ac != null )
- {
+ public void remove(IndexingContext context, ArtifactContext ac) throws IOException {
+ if (ac != null) {
final String uinfo = ac.getArtifactInfo().getUinfo();
// add artifact deletion marker
final Document doc = new Document();
- doc.add( new StoredField( ArtifactInfo.DELETED, uinfo ) );
- doc.add( new StoredField( ArtifactInfo.LAST_MODIFIED, //
- Long.toString( System.currentTimeMillis() ) ) );
+ doc.add(new StoredField(ArtifactInfo.DELETED, uinfo));
+ doc.add(new StoredField(
+ ArtifactInfo.LAST_MODIFIED, //
+ Long.toString(System.currentTimeMillis())));
IndexWriter w = context.getIndexWriter();
- w.addDocument( doc );
- w.deleteDocuments( new Term( ArtifactInfo.UINFO, uinfo ) );
+ w.addDocument(doc);
+ w.deleteDocuments(new Term(ArtifactInfo.UINFO, uinfo));
context.updateTimestamp();
}
}
// ==
- private boolean equals( final Document d1, final Document d2 )
- {
- if ( d1 == null && d2 == null )
- {
+ private boolean equals(final Document d1, final Document d2) {
+ if (d1 == null && d2 == null) {
return true;
}
- if ( d1 == null || d2 == null )
- {
+ if (d1 == null || d2 == null) {
return false;
}
- final Map<String, String> m1 = toMap( d1 );
- final Map<String, String> m2 = toMap( d2 );
+ final Map<String, String> m1 = toMap(d1);
+ final Map<String, String> m2 = toMap(d2);
- m1.remove( MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey() );
- m2.remove( MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey() );
+ m1.remove(MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey());
+ m2.remove(MinimalArtifactInfoIndexCreator.FLD_LAST_MODIFIED.getKey());
- return m1.equals( m2 );
+ return m1.equals(m2);
}
- private Map<String, String> toMap( Document d )
- {
+ private Map<String, String> toMap(Document d) {
final HashMap<String, String> result = new HashMap<>();
- for ( Object o : d.getFields() )
- {
+ for (Object o : d.getFields()) {
IndexableField f = (IndexableField) o;
- if ( f.fieldType().stored() )
- {
- result.put( f.name(), f.stringValue() );
+ if (f.fieldType().stored()) {
+ result.put(f.name(), f.stringValue());
}
}
return result;
}
- private Document getOldDocument( IndexingContext context, ArtifactContext ac )
- {
- try
- {
+ private Document getOldDocument(IndexingContext context, ArtifactContext ac) {
+ try {
final IndexSearcher indexSearcher = context.acquireIndexSearcher();
- try
- {
- TopDocs result =
- indexSearcher.search(
- new TermQuery( new Term( ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo() ) ), 2 );
-
- if ( result.totalHits.value == 1 )
- {
- return indexSearcher.doc( result.scoreDocs[0].doc );
+ try {
+ TopDocs result = indexSearcher.search(
+ new TermQuery(new Term(
+ ArtifactInfo.UINFO, ac.getArtifactInfo().getUinfo())),
+ 2);
+
+ if (result.totalHits.value == 1) {
+ return indexSearcher.doc(result.scoreDocs[0].doc);
}
+ } finally {
+ context.releaseIndexSearcher(indexSearcher);
}
- finally
- {
- context.releaseIndexSearcher( indexSearcher );
- }
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// huh?
- throw new IllegalStateException( e );
+ throw new IllegalStateException(e);
}
return null;
}
- private void updateGroups( IndexingContext context, ArtifactContext ac )
- throws IOException
- {
+ private void updateGroups(IndexingContext context, ArtifactContext ac) throws IOException {
String rootGroup = ac.getArtifactInfo().getRootGroup();
Set<String> rootGroups = context.getRootGroups();
- if ( !rootGroups.contains( rootGroup ) )
- {
- rootGroups.add( rootGroup );
- context.setRootGroups( rootGroups );
+ if (!rootGroups.contains(rootGroup)) {
+ rootGroups.add(rootGroup);
+ context.setRootGroups(rootGroups);
}
Set<String> allGroups = context.getAllGroups();
- if ( !allGroups.contains( ac.getArtifactInfo().getGroupId() ) )
- {
- allGroups.add( ac.getArtifactInfo().getGroupId() );
- context.setAllGroups( allGroups );
+ if (!allGroups.contains(ac.getArtifactInfo().getGroupId())) {
+ allGroups.add(ac.getArtifactInfo().getGroupId());
+ context.setAllGroups(allGroups);
}
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultIteratorResultSet.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultIteratorResultSet.java
index 65ea55d..5ca4b42 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultIteratorResultSet.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultIteratorResultSet.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,14 +16,15 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CachingTokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
@@ -46,12 +45,10 @@ import org.apache.maven.index.creator.JarFileContentsIndexCreator;
/**
* Default implementation of IteratorResultSet. TODO: there is too much of logic, refactor this!
- *
+ *
* @author cstamas
*/
-public class DefaultIteratorResultSet
- implements IteratorResultSet
-{
+public class DefaultIteratorResultSet implements IteratorResultSet {
private final IteratorSearchRequest searchRequest;
private final NexusIndexMultiSearcher indexSearcher;
@@ -80,11 +77,12 @@ public class DefaultIteratorResultSet
private ArtifactInfo ai;
- protected DefaultIteratorResultSet( final IteratorSearchRequest request,
- final NexusIndexMultiSearcher indexSearcher,
- final List<IndexingContext> contexts, final TopDocs hits )
- throws IOException
- {
+ protected DefaultIteratorResultSet(
+ final IteratorSearchRequest request,
+ final NexusIndexMultiSearcher indexSearcher,
+ final List<IndexingContext> contexts,
+ final TopDocs hits)
+ throws IOException {
this.searchRequest = request;
this.indexSearcher = indexSearcher;
@@ -97,11 +95,10 @@ public class DefaultIteratorResultSet
// this is good to do as we have NexusIndexMultiSearcher passed in contructor, so it is already open, hence
// #acquire() already invoked on underlying NexusIndexMultiReader
final List<IndexSearcher> acquiredSearchers =
- indexSearcher.getNexusIndexMultiReader().getAcquiredSearchers();
- for ( int i = 0; i < contexts.size(); i++ )
- {
+ indexSearcher.getNexusIndexMultiReader().getAcquiredSearchers();
+ for (int i = 0; i < contexts.size(); i++) {
starts[i] = maxDoc;
- maxDoc += acquiredSearchers.get( i ).getIndexReader().maxDoc(); // compute maxDocs
+ maxDoc += acquiredSearchers.get(i).getIndexReader().maxDoc(); // compute maxDocs
}
starts[contexts.size()] = maxDoc;
}
@@ -113,20 +110,18 @@ public class DefaultIteratorResultSet
this.matchHighlightRequests = request.getMatchHighlightRequests();
List<MatchHighlightRequest> matchHighlightRequests = new ArrayList<>();
- for ( MatchHighlightRequest hr : request.getMatchHighlightRequests() )
- {
- Query rewrittenQuery = hr.getQuery().rewrite( indexSearcher.getIndexReader() );
- matchHighlightRequests.add( new MatchHighlightRequest( hr.getField(), rewrittenQuery,
- hr.getHighlightMode() ) );
+ for (MatchHighlightRequest hr : request.getMatchHighlightRequests()) {
+ Query rewrittenQuery = hr.getQuery().rewrite(indexSearcher.getIndexReader());
+ matchHighlightRequests.add(new MatchHighlightRequest(hr.getField(), rewrittenQuery, hr.getHighlightMode()));
}
this.hits = hits;
this.from = request.getStart();
- this.count =
- ( request.getCount() == AbstractSearchRequest.UNDEFINED ? hits.scoreDocs.length : Math.min(
- request.getCount(), hits.scoreDocs.length ) );
+ this.count = (request.getCount() == AbstractSearchRequest.UNDEFINED
+ ? hits.scoreDocs.length
+ : Math.min(request.getCount(), hits.scoreDocs.length));
this.pointer = from;
@@ -136,35 +131,26 @@ public class DefaultIteratorResultSet
ai = createNextAi();
- if ( ai == null )
- {
+ if (ai == null) {
cleanUp();
}
}
- public boolean hasNext()
- {
+ public boolean hasNext() {
return ai != null;
}
- public ArtifactInfo next()
- {
+ public ArtifactInfo next() {
ArtifactInfo result = ai;
- try
- {
+ try {
ai = createNextAi();
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
ai = null;
- throw new IllegalStateException( "Cannot fetch next ArtifactInfo!", e );
- }
- finally
- {
- if ( ai == null )
- {
+ throw new IllegalStateException("Cannot fetch next ArtifactInfo!", e);
+ } finally {
+ if (ai == null) {
cleanUp();
}
}
@@ -172,36 +158,30 @@ public class DefaultIteratorResultSet
return result;
}
- public void remove()
- {
- throw new UnsupportedOperationException( "Method not supported on " + getClass().getName() );
+ public void remove() {
+ throw new UnsupportedOperationException(
+ "Method not supported on " + getClass().getName());
}
- public Iterator<ArtifactInfo> iterator()
- {
+ public Iterator<ArtifactInfo> iterator() {
return this;
}
- public void close()
- {
+ public void close() {
cleanUp();
}
- public int getTotalProcessedArtifactInfoCount()
- {
+ public int getTotalProcessedArtifactInfoCount() {
return processedArtifactInfoCount;
}
@Override
- public void finalize()
- throws Throwable
- {
+ public void finalize() throws Throwable {
super.finalize();
- if ( !cleanedUp )
- {
- System.err.println( "#WARNING: Lock leaking from " + getClass().getName() + " for query "
- + searchRequest.getQuery().toString() );
+ if (!cleanedUp) {
+ System.err.println("#WARNING: Lock leaking from " + getClass().getName() + " for query "
+ + searchRequest.getQuery().toString());
cleanUp();
}
@@ -209,9 +189,7 @@ public class DefaultIteratorResultSet
// ==
- protected ArtifactInfo createNextAi()
- throws IOException
- {
+ protected ArtifactInfo createNextAi() throws IOException {
ArtifactInfo result = null;
// we should stop if:
@@ -219,46 +197,43 @@ public class DefaultIteratorResultSet
// b) pointer advanced over more documents that user requested
// c) pointer advanced over more documents that hits has
// or we found what we need
- while ( ( result == null ) && ( pointer < maxRecPointer ) && ( pointer < hits.scoreDocs.length ) )
- {
- Document doc = indexSearcher.doc( hits.scoreDocs[pointer].doc );
+ while ((result == null) && (pointer < maxRecPointer) && (pointer < hits.scoreDocs.length)) {
+ Document doc = indexSearcher.doc(hits.scoreDocs[pointer].doc);
- IndexingContext context = getIndexingContextForPointer( doc, hits.scoreDocs[pointer].doc );
+ IndexingContext context = getIndexingContextForPointer(doc, hits.scoreDocs[pointer].doc);
- result = IndexUtils.constructArtifactInfo( doc, context );
+ result = IndexUtils.constructArtifactInfo(doc, context);
- if ( result != null )
- {
+ if (result != null) {
// WARNING: NOT FOR PRODUCTION SYSTEMS, THIS IS VERY COSTLY OPERATION
// For debugging only!!!
- if ( searchRequest.isLuceneExplain() )
- {
- result.getAttributes().put( Explanation.class.getName(),
- indexSearcher.explain( searchRequest.getQuery(), hits.scoreDocs[pointer].doc ).toString() );
+ if (searchRequest.isLuceneExplain()) {
+ result.getAttributes()
+ .put(
+ Explanation.class.getName(),
+ indexSearcher
+ .explain(searchRequest.getQuery(), hits.scoreDocs[pointer].doc)
+ .toString());
}
- result.setLuceneScore( hits.scoreDocs[pointer].score );
+ result.setLuceneScore(hits.scoreDocs[pointer].score);
- result.setRepository( context.getRepositoryId() );
+ result.setRepository(context.getRepositoryId());
- result.setContext( context.getId() );
+ result.setContext(context.getId());
- if ( filter != null )
- {
- if ( !filter.accepts( context, result ) )
- {
+ if (filter != null) {
+ if (!filter.accepts(context, result)) {
result = null;
}
}
- if ( result != null && postprocessor != null )
- {
- postprocessor.postprocess( context, result );
+ if (result != null && postprocessor != null) {
+ postprocessor.postprocess(context, result);
}
- if ( result != null && matchHighlightRequests.size() > 0 )
- {
- calculateHighlights( context, doc, result );
+ if (result != null && matchHighlightRequests.size() > 0) {
+ calculateHighlights(context, doc, result);
}
}
@@ -271,20 +246,15 @@ public class DefaultIteratorResultSet
private volatile boolean cleanedUp = false;
- protected synchronized void cleanUp()
- {
- if ( cleanedUp )
- {
+ protected synchronized void cleanUp() {
+ if (cleanedUp) {
return;
}
- try
- {
+ try {
indexSearcher.release();
- }
- catch ( IOException e )
- {
- throw new IllegalStateException( e );
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
}
this.cleanedUp = true;
@@ -292,37 +262,31 @@ public class DefaultIteratorResultSet
/**
* Creates the MatchHighlights and adds them to ArtifactInfo if found/can.
- *
+ *
* @param context
* @param d
* @param ai
*/
- protected void calculateHighlights( IndexingContext context, Document d, ArtifactInfo ai )
- throws IOException
- {
+ protected void calculateHighlights(IndexingContext context, Document d, ArtifactInfo ai) throws IOException {
IndexerField field;
String text;
List<String> highlightFragment;
- for ( MatchHighlightRequest hr : matchHighlightRequests )
- {
- field = selectStoredIndexerField( hr.getField() );
+ for (MatchHighlightRequest hr : matchHighlightRequests) {
+ field = selectStoredIndexerField(hr.getField());
- if ( field != null )
- {
- text = ai.getFieldValue( field.getOntology() );
+ if (field != null) {
+ text = ai.getFieldValue(field.getOntology());
- if ( text != null )
- {
- highlightFragment = highlightField( context, hr, field, text );
+ if (text != null) {
+ highlightFragment = highlightField(context, hr, field, text);
- if ( highlightFragment != null && highlightFragment.size() > 0 )
- {
- MatchHighlight matchHighlight = new MatchHighlight( hr.getField(), highlightFragment );
+ if (highlightFragment != null && highlightFragment.size() > 0) {
+ MatchHighlight matchHighlight = new MatchHighlight(hr.getField(), highlightFragment);
- ai.getMatchHighlights().add( matchHighlight );
+ ai.getMatchHighlights().add(matchHighlight);
}
}
}
@@ -331,26 +295,24 @@ public class DefaultIteratorResultSet
/**
* Select a STORED IndexerField assigned to passed in Field.
- *
+ *
* @param field
* @return
*/
- protected IndexerField selectStoredIndexerField( Field field )
- {
+ protected IndexerField selectStoredIndexerField(Field field) {
// hack here
- if ( MAVEN.CLASSNAMES.equals( field ) )
- {
+ if (MAVEN.CLASSNAMES.equals(field)) {
return JarFileContentsIndexCreator.FLD_CLASSNAMES;
- }
- else
- {
- return field.getIndexerFields().isEmpty() ? null : field.getIndexerFields().iterator().next();
+ } else {
+ return field.getIndexerFields().isEmpty()
+ ? null
+ : field.getIndexerFields().iterator().next();
}
}
/**
* Returns a string that contains match fragment highlighted in style as user requested.
- *
+ *
* @param context
* @param hr
* @param field
@@ -358,101 +320,80 @@ public class DefaultIteratorResultSet
* @return
* @throws IOException
*/
- protected List<String> highlightField( IndexingContext context, MatchHighlightRequest hr, IndexerField field,
- String text )
- throws IOException
- {
+ protected List<String> highlightField(
+ IndexingContext context, MatchHighlightRequest hr, IndexerField field, String text) throws IOException {
// exception with classnames
- if ( MAVEN.CLASSNAMES.equals( field.getOntology() ) )
- {
- text = text.replace( '/', '.' ).replaceAll( "^\\.", "" ).replaceAll( "\n\\.", "\n" );
+ if (MAVEN.CLASSNAMES.equals(field.getOntology())) {
+ text = text.replace('/', '.').replaceAll("^\\.", "").replaceAll("\n\\.", "\n");
}
-
+
Analyzer analyzer = context.getAnalyzer();
- TokenStream baseTokenStream = analyzer.tokenStream( field.getKey(), new StringReader( text ) );
-
- CachingTokenFilter tokenStream = new CachingTokenFilter( baseTokenStream );
+ TokenStream baseTokenStream = analyzer.tokenStream(field.getKey(), new StringReader(text));
+
+ CachingTokenFilter tokenStream = new CachingTokenFilter(baseTokenStream);
Formatter formatter;
- if ( MatchHighlightMode.HTML.equals( hr.getHighlightMode() ) )
- {
+ if (MatchHighlightMode.HTML.equals(hr.getHighlightMode())) {
formatter = new SimpleHTMLFormatter();
- }
- else
- {
+ } else {
tokenStream.reset();
tokenStream.end();
tokenStream.close();
- throw new UnsupportedOperationException( "Hightlight more \"" + hr.getHighlightMode().toString()
- + "\" is not supported!" );
+ throw new UnsupportedOperationException(
+ "Hightlight more \"" + hr.getHighlightMode().toString() + "\" is not supported!");
}
- List<String> bestFragments = getBestFragments( hr.getQuery(), formatter, tokenStream, text, 3 );
-
+ List<String> bestFragments = getBestFragments(hr.getQuery(), formatter, tokenStream, text, 3);
+
return bestFragments;
}
- protected final List<String> getBestFragments( Query query, Formatter formatter, TokenStream tokenStream,
- String text, int maxNumFragments )
- throws IOException
- {
- Highlighter highlighter = new Highlighter( formatter, new CleaningEncoder(), new QueryScorer( query ) );
+ protected final List<String> getBestFragments(
+ Query query, Formatter formatter, TokenStream tokenStream, String text, int maxNumFragments)
+ throws IOException {
+ Highlighter highlighter = new Highlighter(formatter, new CleaningEncoder(), new QueryScorer(query));
- highlighter.setTextFragmenter( new OneLineFragmenter() );
+ highlighter.setTextFragmenter(new OneLineFragmenter());
- maxNumFragments = Math.max( 1, maxNumFragments ); // sanity check
+ maxNumFragments = Math.max(1, maxNumFragments); // sanity check
TextFragment[] frag;
// Get text
- ArrayList<String> fragTexts = new ArrayList<>( maxNumFragments );
+ ArrayList<String> fragTexts = new ArrayList<>(maxNumFragments);
- try
- {
- frag = highlighter.getBestTextFragments( tokenStream, text, false, maxNumFragments );
+ try {
+ frag = highlighter.getBestTextFragments(tokenStream, text, false, maxNumFragments);
- for ( TextFragment textFragment : frag )
- {
- if ( ( textFragment != null ) && ( textFragment.getScore() > 0 ) )
- {
- fragTexts.add( textFragment.toString() );
+ for (TextFragment textFragment : frag) {
+ if ((textFragment != null) && (textFragment.getScore() > 0)) {
+ fragTexts.add(textFragment.toString());
}
}
- }
- catch ( InvalidTokenOffsetsException e )
- {
+ } catch (InvalidTokenOffsetsException e) {
// empty?
}
return fragTexts;
}
- protected IndexingContext getIndexingContextForPointer( Document doc, int docPtr )
- {
- return contexts.get( readerIndex( docPtr, this.starts, this.contexts.size() ) );
+ protected IndexingContext getIndexingContextForPointer(Document doc, int docPtr) {
+ return contexts.get(readerIndex(docPtr, this.starts, this.contexts.size()));
}
- private static int readerIndex( int n, int[] starts, int numSubReaders )
- { // find reader for doc n:
+ private static int readerIndex(int n, int[] starts, int numSubReaders) { // find reader for doc n:
int lo = 0; // search starts array
int hi = numSubReaders - 1; // for first element less
- while ( hi >= lo )
- {
- int mid = ( lo + hi ) >>> 1;
+ while (hi >= lo) {
+ int mid = (lo + hi) >>> 1;
int midValue = starts[mid];
- if ( n < midValue )
- {
+ if (n < midValue) {
hi = mid - 1;
- }
- else if ( n > midValue )
- {
+ } else if (n > midValue) {
lo = mid + 1;
- }
- else
- { // found a match
- while ( mid + 1 < numSubReaders && starts[mid + 1] == midValue )
- {
+ } else { // found a match
+ while (mid + 1 < numSubReaders && starts[mid + 1] == midValue) {
mid++; // scan to last match
}
return mid;
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
index 8efd5be..bfda57d 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,10 +16,12 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
@@ -30,6 +30,7 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.lucene.store.Directory;
@@ -60,9 +61,7 @@ import org.codehaus.plexus.util.FileUtils;
@Deprecated
@Singleton
@Named
-public class DefaultNexusIndexer
- implements NexusIndexer
-{
+public class DefaultNexusIndexer implements NexusIndexer {
private final Indexer indexer;
@@ -74,13 +73,9 @@ public class DefaultNexusIndexer
private final Map<String, IndexingContext> indexingContexts = new ConcurrentHashMap<>();
-
@Inject
- public DefaultNexusIndexer( Indexer indexer,
- Scanner scanner,
- IndexerEngine indexerEngine,
- QueryCreator queryCreator )
- {
+ public DefaultNexusIndexer(
+ Indexer indexer, Scanner scanner, IndexerEngine indexerEngine, QueryCreator queryCreator) {
this.indexer = indexer;
this.scanner = scanner;
this.indexerEngine = indexerEngine;
@@ -91,158 +86,176 @@ public class DefaultNexusIndexer
// Contexts
// ----------------------------------------------------------------------------
- public void addIndexingContext( IndexingContext context )
- {
- indexingContexts.put( context.getId(), context );
- }
-
- public IndexingContext addIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException, UnsupportedExistingLuceneIndexException
- {
- try
- {
- IndexingContext context =
- indexer.createIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl,
- indexUpdateUrl, true, false, indexers );
- indexingContexts.put( context.getId(), context );
+ public void addIndexingContext(IndexingContext context) {
+ indexingContexts.put(context.getId(), context);
+ }
+
+ public IndexingContext addIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException, UnsupportedExistingLuceneIndexException {
+ try {
+ IndexingContext context = indexer.createIndexingContext(
+ id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl, true, false, indexers);
+ indexingContexts.put(context.getId(), context);
return context;
- }
- catch ( ExistingLuceneIndexMismatchException e )
- {
- throw new UnsupportedExistingLuceneIndexException( e.getMessage(), e );
+ } catch (ExistingLuceneIndexMismatchException e) {
+ throw new UnsupportedExistingLuceneIndexException(e.getMessage(), e);
}
}
- public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
- File indexDirectory, String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException
- {
- IndexingContext context =
- indexer.createIndexingContext( id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl,
- true, true, indexers );
- indexingContexts.put( context.getId(), context );
+ public IndexingContext addIndexingContextForced(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException {
+ IndexingContext context = indexer.createIndexingContext(
+ id, repositoryId, repository, indexDirectory, repositoryUrl, indexUpdateUrl, true, true, indexers);
+ indexingContexts.put(context.getId(), context);
return context;
}
- public IndexingContext addIndexingContext( String id, String repositoryId, File repository, Directory directory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException, UnsupportedExistingLuceneIndexException
- {
- try
- {
- IndexingContext context =
- new DefaultIndexingContext( id, repositoryId, repository, directory, repositoryUrl, indexUpdateUrl,
- IndexCreatorSorter.sort( indexers ), false );
- indexingContexts.put( context.getId(), context );
+ public IndexingContext addIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory directory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException, UnsupportedExistingLuceneIndexException {
+ try {
+ IndexingContext context = new DefaultIndexingContext(
+ id,
+ repositoryId,
+ repository,
+ directory,
+ repositoryUrl,
+ indexUpdateUrl,
+ IndexCreatorSorter.sort(indexers),
+ false);
+ indexingContexts.put(context.getId(), context);
return context;
- }
- catch ( ExistingLuceneIndexMismatchException e )
- {
- throw new UnsupportedExistingLuceneIndexException( e.getMessage(), e );
+ } catch (ExistingLuceneIndexMismatchException e) {
+ throw new UnsupportedExistingLuceneIndexException(e.getMessage(), e);
}
}
- public IndexingContext addIndexingContextForced( String id, String repositoryId, File repository,
- Directory directory, String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException
- {
- IndexingContext context =
- new DefaultIndexingContext( id, repositoryId, repository, directory, repositoryUrl, indexUpdateUrl,
- IndexCreatorSorter.sort( indexers ), true );
- indexingContexts.put( context.getId(), context );
+ public IndexingContext addIndexingContextForced(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory directory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException {
+ IndexingContext context = new DefaultIndexingContext(
+ id,
+ repositoryId,
+ repository,
+ directory,
+ repositoryUrl,
+ indexUpdateUrl,
+ IndexCreatorSorter.sort(indexers),
+ true);
+ indexingContexts.put(context.getId(), context);
return context;
}
- public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- File indexDirectory, boolean searchable,
- Collection<IndexingContext> contexts )
- throws IOException
- {
- return addMergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
- new StaticContextMemberProvider( contexts ) );
- }
-
- public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- File indexDirectory, boolean searchable,
- ContextMemberProvider membersProvider )
- throws IOException
- {
- IndexingContext context =
- indexer.createMergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
- membersProvider );
- indexingContexts.put( context.getId(), context );
+ public IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ Collection<IndexingContext> contexts)
+ throws IOException {
+ return addMergedIndexingContext(
+ id, repositoryId, repository, indexDirectory, searchable, new StaticContextMemberProvider(contexts));
+ }
+
+ public IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException {
+ IndexingContext context = indexer.createMergedIndexingContext(
+ id, repositoryId, repository, indexDirectory, searchable, membersProvider);
+ indexingContexts.put(context.getId(), context);
return context;
}
- public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- Directory indexDirectory, boolean searchable,
- Collection<IndexingContext> contexts )
- throws IOException
- {
- IndexingContext context =
- new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable,
- new StaticContextMemberProvider( contexts ) );
- indexingContexts.put( context.getId(), context );
+ public IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory indexDirectory,
+ boolean searchable,
+ Collection<IndexingContext> contexts)
+ throws IOException {
+ IndexingContext context = new MergedIndexingContext(
+ id, repositoryId, repository, indexDirectory, searchable, new StaticContextMemberProvider(contexts));
+ indexingContexts.put(context.getId(), context);
return context;
}
- public IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- Directory indexDirectory, boolean searchable,
- ContextMemberProvider membersProvider )
- throws IOException
- {
+ public IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException {
IndexingContext context =
- new MergedIndexingContext( id, repositoryId, repository, indexDirectory, searchable, membersProvider );
- indexingContexts.put( context.getId(), context );
+ new MergedIndexingContext(id, repositoryId, repository, indexDirectory, searchable, membersProvider);
+ indexingContexts.put(context.getId(), context);
return context;
}
- public void removeIndexingContext( IndexingContext context, boolean deleteFiles )
- throws IOException
- {
- if ( indexingContexts.containsKey( context.getId() ) )
- {
- indexingContexts.remove( context.getId() );
- indexer.closeIndexingContext( context, deleteFiles );
+ public void removeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException {
+ if (indexingContexts.containsKey(context.getId())) {
+ indexingContexts.remove(context.getId());
+ indexer.closeIndexingContext(context, deleteFiles);
}
}
- public Map<String, IndexingContext> getIndexingContexts()
- {
- return Collections.unmodifiableMap( indexingContexts );
+ public Map<String, IndexingContext> getIndexingContexts() {
+ return Collections.unmodifiableMap(indexingContexts);
}
// ----------------------------------------------------------------------------
// Scanning
// ----------------------------------------------------------------------------
- public void scan( final IndexingContext context )
- throws IOException
- {
- scan( context, null );
+ public void scan(final IndexingContext context) throws IOException {
+ scan(context, null);
}
- public void scan( final IndexingContext context, boolean update )
- throws IOException
- {
- scan( context, null, update );
+ public void scan(final IndexingContext context, boolean update) throws IOException {
+ scan(context, null, update);
}
- public void scan( final IndexingContext context, final ArtifactScanningListener listener )
- throws IOException
- {
- scan( context, listener, false );
+ public void scan(final IndexingContext context, final ArtifactScanningListener listener) throws IOException {
+ scan(context, listener, false);
}
- public void scan( final IndexingContext context, final ArtifactScanningListener listener, final boolean update )
- throws IOException
- {
- scan( context, null, listener, update );
+ public void scan(final IndexingContext context, final ArtifactScanningListener listener, final boolean update)
+ throws IOException {
+ scan(context, null, listener, update);
}
/**
@@ -253,72 +266,66 @@ public class DefaultNexusIndexer
* @see DefaultScannerListener
* @see #artifactDiscovered(ArtifactContext, IndexingContext)
*/
- public void scan( final IndexingContext context, final String fromPath, final ArtifactScanningListener listener,
- final boolean update )
- throws IOException
- {
+ public void scan(
+ final IndexingContext context,
+ final String fromPath,
+ final ArtifactScanningListener listener,
+ final boolean update)
+ throws IOException {
final File repositoryDirectory = context.getRepository();
- if ( repositoryDirectory == null )
- {
+ if (repositoryDirectory == null) {
// nothing to scan
return;
}
- if ( !repositoryDirectory.exists() )
- {
- throw new IOException( "Repository directory " + repositoryDirectory + " does not exist" );
+ if (!repositoryDirectory.exists()) {
+ throw new IOException("Repository directory " + repositoryDirectory + " does not exist");
}
// always use temporary context when reindexing
- final File tmpDir = Files.createTempDirectory( context.getId() + "-tmp" ).toFile();
+ final File tmpDir = Files.createTempDirectory(context.getId() + "-tmp").toFile();
IndexingContext tmpContext = null;
- try
- {
- final FSDirectory directory = FSDirectory.open( tmpDir.toPath() );
- if ( update )
- {
- IndexUtils.copyDirectory( context.getIndexDirectory(), directory );
+ try {
+ final FSDirectory directory = FSDirectory.open(tmpDir.toPath());
+ if (update) {
+ IndexUtils.copyDirectory(context.getIndexDirectory(), directory);
}
- tmpContext = new DefaultIndexingContext( context.getId() + "-tmp", //
- context.getRepositoryId(), //
- context.getRepository(), //
- directory, //
- context.getRepositoryUrl(), //
- context.getIndexUpdateUrl(), //
- context.getIndexCreators(), //
- true );
-
- scanner.scan( new ScanningRequest( tmpContext, //
- new DefaultScannerListener( tmpContext, indexerEngine,
- update, listener ), fromPath ) );
-
- tmpContext.updateTimestamp( true );
- context.replace( tmpContext.getIndexDirectory() );
- }
- catch ( Exception ex )
- {
- throw new IOException( "Error scanning context " + context.getId() + ": " + ex, ex );
- }
- finally
- {
- if ( tmpContext != null )
- {
- tmpContext.close( true );
+ tmpContext = new DefaultIndexingContext(
+ context.getId() + "-tmp", //
+ context.getRepositoryId(), //
+ context.getRepository(), //
+ directory, //
+ context.getRepositoryUrl(), //
+ context.getIndexUpdateUrl(), //
+ context.getIndexCreators(), //
+ true);
+
+ scanner.scan(new ScanningRequest(
+ tmpContext, //
+ new DefaultScannerListener(
+ tmpContext, indexerEngine,
+ update, listener),
+ fromPath));
+
+ tmpContext.updateTimestamp(true);
+ context.replace(tmpContext.getIndexDirectory());
+ } catch (Exception ex) {
+ throw new IOException("Error scanning context " + context.getId() + ": " + ex, ex);
+ } finally {
+ if (tmpContext != null) {
+ tmpContext.close(true);
}
- FileUtils.deleteDirectory( tmpDir );
+ FileUtils.deleteDirectory(tmpDir);
}
}
/**
* Delegates to the {@link IndexerEngine} to add a new artifact to the index
*/
- public void artifactDiscovered( ArtifactContext ac, IndexingContext context )
- throws IOException
- {
- if ( ac != null )
- {
- indexerEngine.index( context, ac );
+ public void artifactDiscovered(ArtifactContext ac, IndexingContext context) throws IOException {
+ if (ac != null) {
+ indexerEngine.index(context, ac);
}
}
@@ -329,65 +336,48 @@ public class DefaultNexusIndexer
/**
* Delegates to the {@link IndexerEngine} to update artifact to the index
*/
- public void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
- throws IOException
- {
- indexer.addArtifactsToIndex( Collections.singleton( ac ), context );
+ public void addArtifactToIndex(ArtifactContext ac, IndexingContext context) throws IOException {
+ indexer.addArtifactsToIndex(Collections.singleton(ac), context);
}
- public void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException
- {
- indexer.addArtifactsToIndex( acs, context );
+ public void addArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException {
+ indexer.addArtifactsToIndex(acs, context);
}
/**
* Delegates to the {@link IndexerEngine} to remove artifact from the index
*/
- public void deleteArtifactFromIndex( ArtifactContext ac, IndexingContext context )
- throws IOException
- {
- indexer.deleteArtifactsFromIndex( Collections.singleton( ac ), context );
+ public void deleteArtifactFromIndex(ArtifactContext ac, IndexingContext context) throws IOException {
+ indexer.deleteArtifactsFromIndex(Collections.singleton(ac), context);
}
- public void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException
- {
- indexer.deleteArtifactsFromIndex( acs, context );
+ public void deleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException {
+ indexer.deleteArtifactsFromIndex(acs, context);
}
// ----------------------------------------------------------------------------
// Searching
// ----------------------------------------------------------------------------
- public FlatSearchResponse searchFlat( FlatSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- request.getContexts().addAll( getIndexingContexts().values() );
+ public FlatSearchResponse searchFlat(FlatSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ request.getContexts().addAll(getIndexingContexts().values());
}
- return indexer.searchFlat( request );
+ return indexer.searchFlat(request);
}
- public IteratorSearchResponse searchIterator( IteratorSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- request.getContexts().addAll( getIndexingContexts().values() );
+ public IteratorSearchResponse searchIterator(IteratorSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ request.getContexts().addAll(getIndexingContexts().values());
}
- return indexer.searchIterator( request );
+ return indexer.searchIterator(request);
}
- public GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
- throws IOException
- {
- if ( request.getContexts().isEmpty() )
- {
- request.getContexts().addAll( getIndexingContexts().values() );
+ public GroupedSearchResponse searchGrouped(GroupedSearchRequest request) throws IOException {
+ if (request.getContexts().isEmpty()) {
+ request.getContexts().addAll(getIndexingContexts().values());
}
- return indexer.searchGrouped( request );
+ return indexer.searchGrouped(request);
}
// ----------------------------------------------------------------------------
@@ -395,56 +385,39 @@ public class DefaultNexusIndexer
// ----------------------------------------------------------------------------
@Deprecated
- public Query constructQuery( Field field, String query, SearchType type )
- throws IllegalArgumentException
- {
- try
- {
- return queryCreator.constructQuery( field, query, type );
- }
- catch ( ParseException e )
- {
- throw new IllegalArgumentException( e );
+ public Query constructQuery(Field field, String query, SearchType type) throws IllegalArgumentException {
+ try {
+ return queryCreator.constructQuery(field, query, type);
+ } catch (ParseException e) {
+ throw new IllegalArgumentException(e);
}
}
- public Query constructQuery( Field field, SearchExpression expression )
- throws IllegalArgumentException
- {
- return indexer.constructQuery( field, expression );
+ public Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException {
+ return indexer.constructQuery(field, expression);
}
// ----------------------------------------------------------------------------
// Identification
// ----------------------------------------------------------------------------
- public Collection<ArtifactInfo> identify( Field field, String query )
- throws IllegalArgumentException, IOException
- {
- return identify( constructQuery( field, query, SearchType.EXACT ) );
+ public Collection<ArtifactInfo> identify(Field field, String query) throws IllegalArgumentException, IOException {
+ return identify(constructQuery(field, query, SearchType.EXACT));
}
- public Collection<ArtifactInfo> identify( File artifact )
- throws IOException
- {
- return identify( artifact, indexingContexts.values() );
+ public Collection<ArtifactInfo> identify(File artifact) throws IOException {
+ return identify(artifact, indexingContexts.values());
}
- public Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
- throws IOException
- {
- return indexer.identify( artifact, contexts );
+ public Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException {
+ return indexer.identify(artifact, contexts);
}
- public Collection<ArtifactInfo> identify( Query query )
- throws IOException
- {
- return identify( query, indexingContexts.values() );
+ public Collection<ArtifactInfo> identify(Query query) throws IOException {
+ return identify(query, indexingContexts.values());
}
- public Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
- throws IOException
- {
- return indexer.identify( query, contexts );
+ public Collection<ArtifactInfo> identify(Query query, Collection<IndexingContext> contexts) throws IOException {
+ return indexer.identify(query, contexts);
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
index e1dfe4a..642f98e 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultQueryCreator.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,11 +16,14 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.IOException;
import java.io.StringReader;
+
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.index.Term;
import org.apache.lucene.queryparser.classic.ParseException;
@@ -60,34 +61,28 @@ import org.slf4j.LoggerFactory;
* <li>*junit - matches junit, junit-foo and foo-junit</li>
* <li>^junit$ - matches junit, but not junit-foo, nor foo-junit</li>
* </ul>
- *
+ *
* @author Eugene Kuleshov
*/
@Singleton
@Named
-public class DefaultQueryCreator
- implements QueryCreator
-{
+public class DefaultQueryCreator implements QueryCreator {
- private final Logger logger = LoggerFactory.getLogger( getClass() );
+ private final Logger logger = LoggerFactory.getLogger(getClass());
- protected Logger getLogger()
- {
+ protected Logger getLogger() {
return logger;
}
// ==
- public IndexerField selectIndexerField( final Field field, final SearchType type )
- {
+ public IndexerField selectIndexerField(final Field field, final SearchType type) {
IndexerField lastField = null;
- for ( IndexerField indexerField : field.getIndexerFields() )
- {
+ for (IndexerField indexerField : field.getIndexerFields()) {
lastField = indexerField;
- if ( type.matchesIndexerField( indexerField ) )
- {
+ if (type.matchesIndexerField(indexerField)) {
return indexerField;
}
}
@@ -95,82 +90,66 @@ public class DefaultQueryCreator
return lastField;
}
- public Query constructQuery( final Field field, final SearchExpression expression )
- throws ParseException
- {
+ public Query constructQuery(final Field field, final SearchExpression expression) throws ParseException {
SearchType searchType = SearchType.SCORED;
- if ( expression instanceof SearchTyped )
- {
- searchType = ( (SearchTyped) expression ).getSearchType();
+ if (expression instanceof SearchTyped) {
+ searchType = ((SearchTyped) expression).getSearchType();
}
- return constructQuery( field, expression.getStringValue(), searchType );
+ return constructQuery(field, expression.getStringValue(), searchType);
}
- public Query constructQuery( final Field field, final String query, final SearchType type )
- throws ParseException
- {
- if ( type == null )
- {
- throw new NullPointerException( "Cannot construct query with type of \"null\"!" );
+ public Query constructQuery(final Field field, final String query, final SearchType type) throws ParseException {
+ if (type == null) {
+ throw new NullPointerException("Cannot construct query with type of \"null\"!");
}
- if ( field == null )
- {
- throw new NullPointerException( "Cannot construct query for field \"null\"!" );
- }
- else
- {
- return constructQuery( field, selectIndexerField( field, type ), query, type );
+ if (field == null) {
+ throw new NullPointerException("Cannot construct query for field \"null\"!");
+ } else {
+ return constructQuery(field, selectIndexerField(field, type), query, type);
}
}
@Deprecated
- public Query constructQuery( String field, String query )
- {
+ public Query constructQuery(String field, String query) {
Query result;
- if ( MinimalArtifactInfoIndexCreator.FLD_GROUP_ID_KW.getKey().equals( field )
- || MinimalArtifactInfoIndexCreator.FLD_ARTIFACT_ID_KW.getKey().equals( field )
- || MinimalArtifactInfoIndexCreator.FLD_VERSION_KW.getKey().equals( field )
- || JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.getKey().equals( field ) )
- {
+ if (MinimalArtifactInfoIndexCreator.FLD_GROUP_ID_KW.getKey().equals(field)
+ || MinimalArtifactInfoIndexCreator.FLD_ARTIFACT_ID_KW.getKey().equals(field)
+ || MinimalArtifactInfoIndexCreator.FLD_VERSION_KW.getKey().equals(field)
+ || JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.getKey().equals(field)) {
// these are special untokenized fields, kept for use cases like TreeView is (exact matching).
- result = legacyConstructQuery( field, query );
- }
- else
- {
- QueryParser qp = new QueryParser( field, new NexusAnalyzer() );
+ result = legacyConstructQuery(field, query);
+ } else {
+ QueryParser qp = new QueryParser(field, new NexusAnalyzer());
// small cheap trick
// if a query is not "expert" (does not contain field:val kind of expression)
// but it contains star and/or punctuation chars, example: "common-log*"
- if ( !query.contains( ":" ) )
- {
- if ( query.contains( "*" ) && query.matches( ".*(\\.|-|_).*" ) )
- {
- query = query.toLowerCase().replaceAll( "\\*", "X" ).replaceAll( "\\.|-|_", " " ).replaceAll( "X",
- "*" );
+ if (!query.contains(":")) {
+ if (query.contains("*") && query.matches(".*(\\.|-|_).*")) {
+ query = query.toLowerCase()
+ .replaceAll("\\*", "X")
+ .replaceAll("\\.|-|_", " ")
+ .replaceAll("X", "*");
}
}
- try
- {
- result = qp.parse( query );
- }
- catch ( ParseException e )
- {
- getLogger().debug(
- "Query parsing with \"legacy\" method, we got ParseException from QueryParser: " + e.getMessage() );
+ try {
+ result = qp.parse(query);
+ } catch (ParseException e) {
+ getLogger()
+ .debug("Query parsing with \"legacy\" method, we got ParseException from QueryParser: "
+ + e.getMessage());
- result = legacyConstructQuery( field, query );
+ result = legacyConstructQuery(field, query);
}
}
- if ( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "Query parsed as: " + result.toString() );
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Query parsed as: " + result.toString());
}
return result;
@@ -178,124 +157,96 @@ public class DefaultQueryCreator
// ==
- public Query constructQuery( final Field field, final IndexerField indexerField, final String query,
- final SearchType type )
- throws ParseException
- {
- if ( indexerField == null )
- {
- getLogger().warn( "Querying for field \"" + field.toString() + "\" without any indexer field was tried. "
- + "Please review your code, and consider adding this field to index!" );
+ public Query constructQuery(
+ final Field field, final IndexerField indexerField, final String query, final SearchType type)
+ throws ParseException {
+ if (indexerField == null) {
+ getLogger()
+ .warn("Querying for field \"" + field.toString() + "\" without any indexer field was tried. "
+ + "Please review your code, and consider adding this field to index!");
return null;
}
- if ( !indexerField.isIndexed() )
- {
- getLogger().warn(
- "Querying for non-indexed field " + field.toString()
- + " was tried. Please review your code or consider adding this field to index!" );
+ if (!indexerField.isIndexed()) {
+ getLogger()
+ .warn("Querying for non-indexed field " + field.toString()
+ + " was tried. Please review your code or consider adding this field to index!");
return null;
}
- if ( Field.NOT_PRESENT.equals( query ) )
- {
- return new WildcardQuery( new Term( indexerField.getKey(), "*" ) );
+ if (Field.NOT_PRESENT.equals(query)) {
+ return new WildcardQuery(new Term(indexerField.getKey(), "*"));
}
- if ( SearchType.EXACT.equals( type ) )
- {
- if ( indexerField.isKeyword() )
- {
+ if (SearchType.EXACT.equals(type)) {
+ if (indexerField.isKeyword()) {
// no tokenization should happen against the field!
- if ( query.contains( "*" ) || query.contains( "?" ) )
- {
- return new WildcardQuery( new Term( indexerField.getKey(), query ) );
- }
- else
- {
+ if (query.contains("*") || query.contains("?")) {
+ return new WildcardQuery(new Term(indexerField.getKey(), query));
+ } else {
// exactly what callee wants
- return new TermQuery( new Term( indexerField.getKey(), query ) );
+ return new TermQuery(new Term(indexerField.getKey(), query));
}
- }
- else if ( !indexerField.isKeyword() && indexerField.isStored() )
- {
+ } else if (!indexerField.isKeyword() && indexerField.isStored()) {
// TODO: resolve this better! Decouple QueryCreator and IndexCreators!
// This is a hack/workaround here
- if ( JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.equals( indexerField ) )
- {
- if ( query.startsWith( "/" ) )
- {
- return new TermQuery( new Term( indexerField.getKey(), query.toLowerCase().replaceAll( "\\.",
- "/" ) ) );
- }
- else
- {
- return new TermQuery( new Term( indexerField.getKey(), "/"
- + query.toLowerCase().replaceAll( "\\.", "/" ) ) );
+ if (JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.equals(indexerField)) {
+ if (query.startsWith("/")) {
+ return new TermQuery(new Term(
+ indexerField.getKey(), query.toLowerCase().replaceAll("\\.", "/")));
+ } else {
+ return new TermQuery(new Term(
+ indexerField.getKey(), "/" + query.toLowerCase().replaceAll("\\.", "/")));
}
- }
- else
- {
- getLogger().warn(
- type.toString()
- + " type of querying for non-keyword (but stored) field "
- + indexerField.getOntology().toString()
- + " was tried. Please review your code, or indexCreator involved, "
- + "since this type of querying of this field is currently unsupported." );
+ } else {
+ getLogger()
+ .warn(type.toString()
+ + " type of querying for non-keyword (but stored) field "
+ + indexerField.getOntology().toString()
+ + " was tried. Please review your code, or indexCreator involved, "
+ + "since this type of querying of this field is currently unsupported.");
// will never succeed (unless we supply him "filter" too, but that would kill performance)
// and is possible with stored fields only
return null;
}
- }
- else
- {
- getLogger().warn(
- type.toString()
- + " type of querying for non-keyword (and not stored) field "
- + indexerField.getOntology().toString()
- + " was tried. Please review your code, or indexCreator involved, "
- + "since this type of querying of this field is impossible." );
+ } else {
+ getLogger()
+ .warn(type.toString()
+ + " type of querying for non-keyword (and not stored) field "
+ + indexerField.getOntology().toString()
+ + " was tried. Please review your code, or indexCreator involved, "
+ + "since this type of querying of this field is impossible.");
// not a keyword indexerField, nor stored. No hope at all. Impossible even with "filtering"
return null;
}
- }
- else if ( SearchType.SCORED.equals( type ) )
- {
- if ( JarFileContentsIndexCreator.FLD_CLASSNAMES.equals( indexerField ) )
- {
- String qpQuery = query.toLowerCase().replaceAll( "\\.", " " ).replaceAll( "/", " " );
+ } else if (SearchType.SCORED.equals(type)) {
+ if (JarFileContentsIndexCreator.FLD_CLASSNAMES.equals(indexerField)) {
+ String qpQuery = query.toLowerCase().replaceAll("\\.", " ").replaceAll("/", " ");
// tokenization should happen against the field!
- QueryParser qp = new QueryParser( indexerField.getKey(), new NexusAnalyzer() );
- qp.setDefaultOperator( Operator.AND );
- return qp.parse( qpQuery );
- }
- else if ( indexerField.isKeyword() )
- {
+ QueryParser qp = new QueryParser(indexerField.getKey(), new NexusAnalyzer());
+ qp.setDefaultOperator(Operator.AND);
+ return qp.parse(qpQuery);
+ } else if (indexerField.isKeyword()) {
// no tokenization should happen against the field!
- if ( query.contains( "*" ) || query.contains( "?" ) )
- {
- return new WildcardQuery( new Term( indexerField.getKey(), query ) );
- }
- else
- {
- Term t = new Term( indexerField.getKey(), query );
+ if (query.contains("*") || query.contains("?")) {
+ return new WildcardQuery(new Term(indexerField.getKey(), query));
+ } else {
+ Term t = new Term(indexerField.getKey(), query);
return new BooleanQuery.Builder()
- .add( new TermQuery( t ), Occur.SHOULD )
- .add( new BoostQuery( new PrefixQuery( t ), 0.8f ), Occur.SHOULD )
- .build();
- }
- }
- else
- {
+ .add(new TermQuery(t), Occur.SHOULD)
+ .add(new BoostQuery(new PrefixQuery(t), 0.8f), Occur.SHOULD)
+ .build();
+ }
+ } else {
// to save "original" query
String qpQuery = query;
// tokenization should happen against the field!
- QueryParser qp = new QueryParser( indexerField.getKey(), new NexusAnalyzer() );
- qp.setDefaultOperator( Operator.AND );
+ QueryParser qp = new QueryParser(indexerField.getKey(), new NexusAnalyzer());
+ qp.setDefaultOperator(Operator.AND);
// small cheap trick
// if a query is not "expert" (does not contain field:val kind of expression)
@@ -303,62 +254,54 @@ public class DefaultQueryCreator
// since Lucene does not support multi-terms WITH wildcards.
// So, here, we "mimic" NexusAnalyzer (this should be fixed!)
// but do this with PRESERVING original query!
- if ( qpQuery.matches( ".*(\\.|-|_|/).*" ) )
- {
- qpQuery =
- qpQuery.toLowerCase().replaceAll( "\\*", "X" ).replaceAll( "\\.|-|_|/", " " ).replaceAll( "X",
- "*" ).replaceAll( " \\* ", "" ).replaceAll( "^\\* ", "" ).replaceAll( " \\*$", "" );
+ if (qpQuery.matches(".*(\\.|-|_|/).*")) {
+ qpQuery = qpQuery.toLowerCase()
+ .replaceAll("\\*", "X")
+ .replaceAll("\\.|-|_|/", " ")
+ .replaceAll("X", "*")
+ .replaceAll(" \\* ", "")
+ .replaceAll("^\\* ", "")
+ .replaceAll(" \\*$", "");
}
// "fix" it with trailing "*" if not there, but only if it not ends with a space
- if ( !qpQuery.endsWith( "*" ) && !qpQuery.endsWith( " " ) )
- {
+ if (!qpQuery.endsWith("*") && !qpQuery.endsWith(" ")) {
qpQuery += "*";
}
- try
- {
+ try {
// qpQuery = "\"" + qpQuery + "\"";
- BooleanQuery.Builder q1b = new BooleanQuery.Builder()
- .add( qp.parse( qpQuery ), Occur.SHOULD );
+ BooleanQuery.Builder q1b = new BooleanQuery.Builder().add(qp.parse(qpQuery), Occur.SHOULD);
- if ( qpQuery.contains( " " ) )
- {
- q1b.add( qp.parse( "\"" + qpQuery + "\"" ), Occur.SHOULD );
+ if (qpQuery.contains(" ")) {
+ q1b.add(qp.parse("\"" + qpQuery + "\""), Occur.SHOULD);
}
Query q2 = null;
- int termCount = countTerms( indexerField, query );
+ int termCount = countTerms(indexerField, query);
// try with KW only if the processed query in qpQuery does not have spaces!
- if ( !query.contains( " " ) && termCount > 1 )
- {
+ if (!query.contains(" ") && termCount > 1) {
// get the KW field
- IndexerField keywordField = selectIndexerField( indexerField.getOntology(), SearchType.EXACT );
+ IndexerField keywordField = selectIndexerField(indexerField.getOntology(), SearchType.EXACT);
- if ( keywordField.isKeyword() )
- {
- q2 = constructQuery( indexerField.getOntology(), keywordField, query, type );
+ if (keywordField.isKeyword()) {
+ q2 = constructQuery(indexerField.getOntology(), keywordField, query, type);
}
}
- if ( q2 == null )
- {
+ if (q2 == null) {
return q1b.build();
- }
- else
- {
+ } else {
return new BooleanQuery.Builder()
- // trick with order
- .add( q2, Occur.SHOULD )
- .add( q1b.build(), Occur.SHOULD )
- .build();
+ // trick with order
+ .add(q2, Occur.SHOULD)
+ .add(q1b.build(), Occur.SHOULD)
+ .build();
}
- }
- catch ( ParseException e )
- {
+ } catch (ParseException e) {
// TODO: we are not falling back anymore to legacy!
throw e;
@@ -369,107 +312,82 @@ public class DefaultQueryCreator
// return legacyConstructQuery( indexerField.getKey(), query );
}
}
- }
- else
- {
+ } else {
// what search type is this?
return null;
}
}
- public Query legacyConstructQuery( String field, String query )
- {
- if ( query == null || query.length() == 0 )
- {
- getLogger().info( "Empty or null query for field:" + field );
+ public Query legacyConstructQuery(String field, String query) {
+ if (query == null || query.length() == 0) {
+ getLogger().info("Empty or null query for field:" + field);
return null;
}
String q = query.toLowerCase();
- char h = query.charAt( 0 );
+ char h = query.charAt(0);
- if ( JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.getKey().equals( field )
- || JarFileContentsIndexCreator.FLD_CLASSNAMES.getKey().equals( field ) )
- {
- q = q.replaceAll( "\\.", "/" );
+ if (JarFileContentsIndexCreator.FLD_CLASSNAMES_KW.getKey().equals(field)
+ || JarFileContentsIndexCreator.FLD_CLASSNAMES.getKey().equals(field)) {
+ q = q.replaceAll("\\.", "/");
- if ( h == '^' )
- {
- q = q.substring( 1 );
+ if (h == '^') {
+ q = q.substring(1);
- if ( q.charAt( 0 ) != '/' )
- {
+ if (q.charAt(0) != '/') {
q = '/' + q;
}
- }
- else if ( h != '*' )
- {
+ } else if (h != '*') {
q = "*/" + q;
}
- }
- else
- {
- if ( h == '^' )
- {
- q = q.substring( 1 );
- }
- else if ( h != '*' )
- {
+ } else {
+ if (h == '^') {
+ q = q.substring(1);
+ } else if (h != '*') {
q = "*" + q;
}
}
int l = q.length() - 1;
- char c = q.charAt( l );
- if ( c == ' ' || c == '<' || c == '$' )
- {
- q = q.substring( 0, q.length() - 1 );
- }
- else if ( c != '*' )
- {
+ char c = q.charAt(l);
+ if (c == ' ' || c == '<' || c == '$') {
+ q = q.substring(0, q.length() - 1);
+ } else if (c != '*') {
q += "*";
}
- int n = q.indexOf( '*' );
- if ( n == -1 )
- {
- return new TermQuery( new Term( field, q ) );
- }
- else if ( n > 0 && n == q.length() - 1 )
- {
- return new PrefixQuery( new Term( field, q.substring( 0, q.length() - 1 ) ) );
+ int n = q.indexOf('*');
+ if (n == -1) {
+ return new TermQuery(new Term(field, q));
+ } else if (n > 0 && n == q.length() - 1) {
+ return new PrefixQuery(new Term(field, q.substring(0, q.length() - 1)));
}
- return new WildcardQuery( new Term( field, q ) );
+ return new WildcardQuery(new Term(field, q));
}
// ==
private NexusAnalyzer nexusAnalyzer = new NexusAnalyzer();
- protected int countTerms( final IndexerField indexerField, final String query )
- {
- try
- {
- TokenStream ts = nexusAnalyzer.tokenStream( indexerField.getKey(), new StringReader( query ) );
+ protected int countTerms(final IndexerField indexerField, final String query) {
+ try {
+ TokenStream ts = nexusAnalyzer.tokenStream(indexerField.getKey(), new StringReader(query));
ts.reset();
int result = 0;
- while ( ts.incrementToken() )
- {
+ while (ts.incrementToken()) {
result++;
}
-
+
ts.end();
ts.close();
return result;
- }
- catch ( IOException e )
- {
+ } catch (IOException e) {
// will not happen
return 1;
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java
index 442f77d..a6fa49a 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultScanner.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,10 +16,12 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.File;
import java.util.Arrays;
import java.util.Comparator;
@@ -32,85 +32,71 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A default repository scanner for Maven 2 repository.
- *
+ *
* @author Jason Van Zyl
* @author Tamas Cservenak
*/
@Singleton
@Named
-public class DefaultScanner
- implements Scanner
-{
+public class DefaultScanner implements Scanner {
private final ArtifactContextProducer artifactContextProducer;
-
@Inject
- public DefaultScanner( ArtifactContextProducer artifactContextProducer )
- {
+ public DefaultScanner(ArtifactContextProducer artifactContextProducer) {
this.artifactContextProducer = artifactContextProducer;
}
- public ScanningResult scan( ScanningRequest request )
- {
- request.getArtifactScanningListener().scanningStarted( request.getIndexingContext() );
+ public ScanningResult scan(ScanningRequest request) {
+ request.getArtifactScanningListener().scanningStarted(request.getIndexingContext());
- ScanningResult result = new ScanningResult( request );
+ ScanningResult result = new ScanningResult(request);
- scanDirectory( request.getStartingDirectory(), request );
+ scanDirectory(request.getStartingDirectory(), request);
- request.getArtifactScanningListener().scanningFinished( request.getIndexingContext(), result );
+ request.getArtifactScanningListener().scanningFinished(request.getIndexingContext(), result);
return result;
}
- private void scanDirectory( File dir, ScanningRequest request )
- {
- if ( dir == null )
- {
+ private void scanDirectory(File dir, ScanningRequest request) {
+ if (dir == null) {
return;
}
File[] fileArray = dir.listFiles();
- if ( fileArray != null )
- {
- Set<File> files = new TreeSet<>( new ScannerFileComparator() );
+ if (fileArray != null) {
+ Set<File> files = new TreeSet<>(new ScannerFileComparator());
- files.addAll( Arrays.asList( fileArray ) );
+ files.addAll(Arrays.asList(fileArray));
- for ( File f : files )
- {
- if ( f.getName().startsWith( "." ) )
- {
+ for (File f : files) {
+ if (f.getName().startsWith(".")) {
continue; // skip all hidden files and directories
}
- if ( f.isDirectory() )
- {
- scanDirectory( f, request );
+ if (f.isDirectory()) {
+ scanDirectory(f, request);
}
// else if ( !AbstractIndexCreator.isIndexable( f ) )
// {
// continue; // skip non-indexable files
// }
- else
- {
- processFile( f, request );
+ else {
+ processFile(f, request);
}
}
}
}
- private void processFile( File file, ScanningRequest request )
- {
+ private void processFile(File file, ScanningRequest request) {
IndexingContext context = request.getIndexingContext();
- ArtifactContext ac = artifactContextProducer.getArtifactContext( context, file );
+ ArtifactContext ac = artifactContextProducer.getArtifactContext(context, file);
- if ( ac != null )
- {
- request.getArtifactScanningListener().artifactDiscovered( ac );
+ if (ac != null) {
+ request.getArtifactScanningListener().artifactDiscovered(ac);
}
}
@@ -123,28 +109,19 @@ public class DefaultScanner
* direction of discovery is not trivial at all (pom read -> packaging -> extension -> artifact file). The artifact
* -> POM direction is trivial.
*/
- private static class ScannerFileComparator
- implements Comparator<File>
- {
- public int compare( File o1, File o2 )
- {
- if ( o1.getName().endsWith( ".pom" ) && !o2.getName().endsWith( ".pom" ) )
- {
+ private static class ScannerFileComparator implements Comparator<File> {
+ public int compare(File o1, File o2) {
+ if (o1.getName().endsWith(".pom") && !o2.getName().endsWith(".pom")) {
// 1st is pom, 2nd is not
return 1;
- }
- else if ( !o1.getName().endsWith( ".pom" ) && o2.getName().endsWith( ".pom" ) )
- {
+ } else if (!o1.getName().endsWith(".pom") && o2.getName().endsWith(".pom")) {
// 2nd is pom, 1st is not
return -1;
- }
- else
- {
+ } else {
// both are "same" (pom or not pom)
// Use reverse order so that timestamped snapshots
// use latest - not first
- return o2.getName().compareTo( o1.getName() );
-
+ return o2.getName().compareTo(o1.getName());
}
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
index 2d0c8ca..2d79561 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultScannerListener.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.IOException;
import java.util.ArrayList;
@@ -38,12 +37,10 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A default scanning listener
- *
+ *
* @author Eugene Kuleshov
*/
-public class DefaultScannerListener
- implements ArtifactScanningListener
-{
+public class DefaultScannerListener implements ArtifactScanningListener {
private final IndexingContext context;
private final IndexerEngine indexerEngine;
@@ -64,258 +61,210 @@ public class DefaultScannerListener
private int count = 0;
- public DefaultScannerListener( IndexingContext context, //
- IndexerEngine indexerEngine, boolean update, //
- ArtifactScanningListener listener )
- {
+ public DefaultScannerListener(
+ IndexingContext context, //
+ IndexerEngine indexerEngine,
+ boolean update, //
+ ArtifactScanningListener listener) {
this.context = context;
this.indexerEngine = indexerEngine;
this.update = update;
this.listener = listener;
}
- public void scanningStarted( IndexingContext ctx )
- {
- try
- {
- if ( update )
- {
- initialize( ctx );
+ public void scanningStarted(IndexingContext ctx) {
+ try {
+ if (update) {
+ initialize(ctx);
}
- }
- catch ( IOException ex )
- {
- exceptions.add( ex );
+ } catch (IOException ex) {
+ exceptions.add(ex);
}
- if ( listener != null )
- {
- listener.scanningStarted( ctx );
+ if (listener != null) {
+ listener.scanningStarted(ctx);
}
}
- public void artifactDiscovered( ArtifactContext ac )
- {
+ public void artifactDiscovered(ArtifactContext ac) {
String uinfo = ac.getArtifactInfo().getUinfo();
// TODO: scattered across commented out changes while I was fixing NEXUS-2712, cstamas
// These changes should be applied by borks too much the fragile indexer
// if ( VersionUtils.isSnapshot( ac.getArtifactInfo().version ) && processedUinfos.contains( uinfo ) )
- if ( processedUinfos.contains( uinfo ) )
- {
+ if (processedUinfos.contains(uinfo)) {
return; // skip individual snapshots
}
- boolean adding = processedUinfos.add( uinfo );
+ boolean adding = processedUinfos.add(uinfo);
- if ( uinfos.contains( uinfo ) )
- {
+ if (uinfos.contains(uinfo)) {
// already indexed
- uinfos.remove( uinfo );
+ uinfos.remove(uinfo);
return;
}
- try
- {
- if ( listener != null )
- {
- listener.artifactDiscovered( ac );
+ try {
+ if (listener != null) {
+ listener.artifactDiscovered(ac);
}
- if ( adding )
- {
- indexerEngine.index( context, ac );
- }
- else
- {
- indexerEngine.update( context, ac );
+ if (adding) {
+ indexerEngine.index(context, ac);
+ } else {
+ indexerEngine.update(context, ac);
}
- for ( Exception e : ac.getErrors() )
- {
- artifactError( ac, e );
+ for (Exception e : ac.getErrors()) {
+ artifactError(ac, e);
}
- groups.add( ac.getArtifactInfo().getRootGroup() );
- allGroups.add( ac.getArtifactInfo().getGroupId() );
+ groups.add(ac.getArtifactInfo().getRootGroup());
+ allGroups.add(ac.getArtifactInfo().getGroupId());
count++;
- }
- catch ( IOException ex )
- {
- artifactError( ac, ex );
+ } catch (IOException ex) {
+ artifactError(ac, ex);
}
}
- public void scanningFinished( IndexingContext ctx, ScanningResult result )
- {
- result.setTotalFiles( count );
+ public void scanningFinished(IndexingContext ctx, ScanningResult result) {
+ result.setTotalFiles(count);
- for ( Exception ex : exceptions )
- {
- result.addException( ex );
+ for (Exception ex : exceptions) {
+ result.addException(ex);
}
- try
- {
+ try {
context.optimize();
- context.setRootGroups( groups );
+ context.setRootGroups(groups);
- context.setAllGroups( allGroups );
+ context.setAllGroups(allGroups);
- if ( update && !context.isReceivingUpdates() )
- {
- removeDeletedArtifacts( context, result, result.getRequest().getStartingPath() );
+ if (update && !context.isReceivingUpdates()) {
+ removeDeletedArtifacts(context, result, result.getRequest().getStartingPath());
}
- }
- catch ( IOException ex )
- {
- result.addException( ex );
+ } catch (IOException ex) {
+ result.addException(ex);
}
- if ( listener != null )
- {
- listener.scanningFinished( ctx, result );
+ if (listener != null) {
+ listener.scanningFinished(ctx, result);
}
- if ( result.getDeletedFiles() > 0 || result.getTotalFiles() > 0 )
- {
- try
- {
- context.updateTimestamp( true );
+ if (result.getDeletedFiles() > 0 || result.getTotalFiles() > 0) {
+ try {
+ context.updateTimestamp(true);
context.optimize();
- }
- catch ( Exception ex )
- {
- result.addException( ex );
+ } catch (Exception ex) {
+ result.addException(ex);
}
}
}
- public void artifactError( ArtifactContext ac, Exception e )
- {
- exceptions.add( e );
+ public void artifactError(ArtifactContext ac, Exception e) {
+ exceptions.add(e);
- if ( listener != null )
- {
- listener.artifactError( ac, e );
+ if (listener != null) {
+ listener.artifactError(ac, e);
}
}
- private void initialize( IndexingContext ctx )
- throws IOException, CorruptIndexException
- {
+ private void initialize(IndexingContext ctx) throws IOException, CorruptIndexException {
final IndexSearcher indexSearcher = ctx.acquireIndexSearcher();
- try
- {
+ try {
final IndexReader r = indexSearcher.getIndexReader();
- Bits liveDocs = MultiBits.getLiveDocs( r );
+ Bits liveDocs = MultiBits.getLiveDocs(r);
- for ( int i = 0; i < r.maxDoc(); i++ )
- {
- if ( liveDocs == null || liveDocs.get( i ) )
- {
- Document d = r.document( i );
+ for (int i = 0; i < r.maxDoc(); i++) {
+ if (liveDocs == null || liveDocs.get(i)) {
+ Document d = r.document(i);
- String uinfo = d.get( ArtifactInfo.UINFO );
+ String uinfo = d.get(ArtifactInfo.UINFO);
- if ( uinfo != null )
- {
+ if (uinfo != null) {
// if ctx is receiving updates (in other words, is a proxy),
// there is no need to build a huge Set of strings with all uinfo's
// as deletion detection in those cases have no effect. Also, the
// removeDeletedArtifacts() method, that uses info gathered in this set
// is invoked with same condition. As indexes of Central are getting huge,
// the set grows enormously too, but is actually not used
- if ( !ctx.isReceivingUpdates() )
- {
- uinfos.add( uinfo );
+ if (!ctx.isReceivingUpdates()) {
+ uinfos.add(uinfo);
}
// add all existing groupIds to the lists, as they will
// not be "discovered" and would be missing from the new list..
- String groupId = uinfo.substring( 0, uinfo.indexOf( '|' ) );
- int n = groupId.indexOf( '.' );
- groups.add( n == -1 ? groupId : groupId.substring( 0, n ) );
- allGroups.add( groupId );
+ String groupId = uinfo.substring(0, uinfo.indexOf('|'));
+ int n = groupId.indexOf('.');
+ groups.add(n == -1 ? groupId : groupId.substring(0, n));
+ allGroups.add(groupId);
}
}
}
- }
- finally
- {
- ctx.releaseIndexSearcher( indexSearcher );
+ } finally {
+ ctx.releaseIndexSearcher(indexSearcher);
}
}
- private void removeDeletedArtifacts( IndexingContext context, ScanningResult result, String contextPath )
- throws IOException
- {
+ private void removeDeletedArtifacts(IndexingContext context, ScanningResult result, String contextPath)
+ throws IOException {
int deleted = 0;
final IndexSearcher indexSearcher = context.acquireIndexSearcher();
- try
- {
- for ( String uinfo : uinfos )
- {
- TopScoreDocCollector collector = TopScoreDocCollector.create( 1, Integer.MAX_VALUE );
+ try {
+ for (String uinfo : uinfos) {
+ TopScoreDocCollector collector = TopScoreDocCollector.create(1, Integer.MAX_VALUE);
- indexSearcher.search( new TermQuery( new Term( ArtifactInfo.UINFO, uinfo ) ), collector );
+ indexSearcher.search(new TermQuery(new Term(ArtifactInfo.UINFO, uinfo)), collector);
- if ( collector.getTotalHits() > 0 )
- {
- String[] ra = ArtifactInfo.FS_PATTERN.split( uinfo );
+ if (collector.getTotalHits() > 0) {
+ String[] ra = ArtifactInfo.FS_PATTERN.split(uinfo);
ArtifactInfo ai = new ArtifactInfo();
- ai.setRepository( context.getRepositoryId() );
+ ai.setRepository(context.getRepositoryId());
- ai.setGroupId( ra[0] );
+ ai.setGroupId(ra[0]);
- ai.setArtifactId( ra[1] );
+ ai.setArtifactId(ra[1]);
- ai.setVersion( ra[2] );
+ ai.setVersion(ra[2]);
- if ( ra.length > 3 )
- {
- ai.setClassifier( ArtifactInfo.renvl( ra[3] ) );
+ if (ra.length > 3) {
+ ai.setClassifier(ArtifactInfo.renvl(ra[3]));
}
- if ( ra.length > 4 )
- {
- ai.setPackaging( ArtifactInfo.renvl( ra[4] ) );
+ if (ra.length > 4) {
+ ai.setPackaging(ArtifactInfo.renvl(ra[4]));
}
// minimal ArtifactContext for removal
- ArtifactContext ac = new ArtifactContext( null, null, null, ai, ai.calculateGav() );
-
- for ( int i = 0; i < collector.getTotalHits(); i++ )
- {
- if ( contextPath == null
- || context.getGavCalculator().gavToPath( ac.getGav() ).startsWith( contextPath ) )
- {
- indexerEngine.remove( context, ac );
+ ArtifactContext ac = new ArtifactContext(null, null, null, ai, ai.calculateGav());
+
+ for (int i = 0; i < collector.getTotalHits(); i++) {
+ if (contextPath == null
+ || context.getGavCalculator()
+ .gavToPath(ac.getGav())
+ .startsWith(contextPath)) {
+ indexerEngine.remove(context, ac);
}
deleted++;
}
}
}
- }
- finally
- {
- context.releaseIndexSearcher( indexSearcher );
+ } finally {
+ context.releaseIndexSearcher(indexSearcher);
}
- if ( deleted > 0 )
- {
+ if (deleted > 0) {
context.commit();
}
- result.setDeletedFiles( deleted );
+ result.setDeletedFiles(deleted);
}
-
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/DefaultSearchEngine.java b/indexer-core/src/main/java/org/apache/maven/index/DefaultSearchEngine.java
index b52b870..8e8df22 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/DefaultSearchEngine.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/DefaultSearchEngine.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,9 +16,11 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import javax.inject.Named;
import javax.inject.Singleton;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -46,108 +46,99 @@ import org.slf4j.LoggerFactory;
/**
* A default search engine implementation
- *
+ *
* @author Eugene Kuleshov
* @author Tamas Cservenak
*/
@Singleton
@Named
-public class DefaultSearchEngine
- implements SearchEngine
-{
+public class DefaultSearchEngine implements SearchEngine {
- private final Logger logger = LoggerFactory.getLogger( getClass() );
+ private final Logger logger = LoggerFactory.getLogger(getClass());
- protected Logger getLogger()
- {
+ protected Logger getLogger() {
return logger;
}
@Deprecated
- public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator,
- IndexingContext indexingContext, Query query )
- throws IOException
- {
- return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator, indexingContext ),
- Arrays.asList( indexingContext ), true ).getResults();
+ public Set<ArtifactInfo> searchFlat(
+ Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext indexingContext, Query query)
+ throws IOException {
+ return searchFlatPaged(
+ new FlatSearchRequest(query, artifactInfoComparator, indexingContext),
+ Arrays.asList(indexingContext),
+ true)
+ .getResults();
}
@Deprecated
- public Set<ArtifactInfo> searchFlat( Comparator<ArtifactInfo> artifactInfoComparator,
- Collection<IndexingContext> indexingContexts, Query query )
- throws IOException
- {
- return searchFlatPaged( new FlatSearchRequest( query, artifactInfoComparator ), indexingContexts ).getResults();
+ public Set<ArtifactInfo> searchFlat(
+ Comparator<ArtifactInfo> artifactInfoComparator, Collection<IndexingContext> indexingContexts, Query query)
+ throws IOException {
+ return searchFlatPaged(new FlatSearchRequest(query, artifactInfoComparator), indexingContexts)
+ .getResults();
}
- public FlatSearchResponse searchFlatPaged( FlatSearchRequest request, Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchFlatPaged( request, indexingContexts, false );
+ public FlatSearchResponse searchFlatPaged(FlatSearchRequest request, Collection<IndexingContext> indexingContexts)
+ throws IOException {
+ return searchFlatPaged(request, indexingContexts, false);
}
- public FlatSearchResponse forceSearchFlatPaged( FlatSearchRequest request,
- Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchFlatPaged( request, indexingContexts, true );
+ public FlatSearchResponse forceSearchFlatPaged(
+ FlatSearchRequest request, Collection<IndexingContext> indexingContexts) throws IOException {
+ return searchFlatPaged(request, indexingContexts, true);
}
- protected FlatSearchResponse searchFlatPaged( FlatSearchRequest request,
- Collection<IndexingContext> indexingContexts, boolean ignoreContext )
- throws IOException
- {
- List<IndexingContext> contexts = getParticipatingContexts( indexingContexts, ignoreContext );
+ protected FlatSearchResponse searchFlatPaged(
+ FlatSearchRequest request, Collection<IndexingContext> indexingContexts, boolean ignoreContext)
+ throws IOException {
+ List<IndexingContext> contexts = getParticipatingContexts(indexingContexts, ignoreContext);
- final TreeSet<ArtifactInfo> result = new TreeSet<>( request.getArtifactInfoComparator() );
- return new FlatSearchResponse( request.getQuery(), searchFlat( request, result, contexts, request.getQuery() ),
- result );
+ final TreeSet<ArtifactInfo> result = new TreeSet<>(request.getArtifactInfoComparator());
+ return new FlatSearchResponse(
+ request.getQuery(), searchFlat(request, result, contexts, request.getQuery()), result);
}
// ==
- public GroupedSearchResponse searchGrouped( GroupedSearchRequest request,
- Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchGrouped( request, indexingContexts, false );
+ public GroupedSearchResponse searchGrouped(
+ GroupedSearchRequest request, Collection<IndexingContext> indexingContexts) throws IOException {
+ return searchGrouped(request, indexingContexts, false);
}
- public GroupedSearchResponse forceSearchGrouped( GroupedSearchRequest request,
- Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchGrouped( request, indexingContexts, true );
+ public GroupedSearchResponse forceSearchGrouped(
+ GroupedSearchRequest request, Collection<IndexingContext> indexingContexts) throws IOException {
+ return searchGrouped(request, indexingContexts, true);
}
- protected GroupedSearchResponse searchGrouped( GroupedSearchRequest request,
- Collection<IndexingContext> indexingContexts, boolean ignoreContext )
- throws IOException
- {
- List<IndexingContext> contexts = getParticipatingContexts( indexingContexts, ignoreContext );
+ protected GroupedSearchResponse searchGrouped(
+ GroupedSearchRequest request, Collection<IndexingContext> indexingContexts, boolean ignoreContext)
+ throws IOException {
+ List<IndexingContext> contexts = getParticipatingContexts(indexingContexts, ignoreContext);
- final TreeMap<String, ArtifactInfoGroup> result = new TreeMap<>( request.getGroupKeyComparator() );
+ final TreeMap<String, ArtifactInfoGroup> result = new TreeMap<>(request.getGroupKeyComparator());
- return new GroupedSearchResponse( request.getQuery(), searchGrouped( request, result, request.getGrouping(),
- contexts, request.getQuery() ), result );
+ return new GroupedSearchResponse(
+ request.getQuery(),
+ searchGrouped(request, result, request.getGrouping(), contexts, request.getQuery()),
+ result);
}
// ===
- protected int searchFlat( FlatSearchRequest req, Collection<ArtifactInfo> result,
- List<IndexingContext> participatingContexts, Query query )
- throws IOException
- {
+ protected int searchFlat(
+ FlatSearchRequest req,
+ Collection<ArtifactInfo> result,
+ List<IndexingContext> participatingContexts,
+ Query query)
+ throws IOException {
int hitCount = 0;
- for ( IndexingContext context : participatingContexts )
- {
+ for (IndexingContext context : participatingContexts) {
final IndexSearcher indexSearcher = context.acquireIndexSearcher();
- try
- {
- final TopScoreDocCollector collector = doSearchWithCeiling( req, indexSearcher, query );
+ try {
+ final TopScoreDocCollector collector = doSearchWithCeiling(req, indexSearcher, query);
- if ( collector.getTotalHits() == 0 )
- {
+ if (collector.getTotalHits() == 0) {
// context has no hits, just continue to next one
continue;
}
@@ -161,96 +152,81 @@ public class DefaultSearchEngine
int start = 0; // from == FlatSearchRequest.UNDEFINED ? 0 : from;
// we have to pack the results as long: a) we have found aiCount ones b) we depleted hits
- for ( int i = start; i < scoreDocs.length; i++ )
- {
- Document doc = indexSearcher.doc( scoreDocs[i].doc );
+ for (int i = start; i < scoreDocs.length; i++) {
+ Document doc = indexSearcher.doc(scoreDocs[i].doc);
- ArtifactInfo artifactInfo = IndexUtils.constructArtifactInfo( doc, context );
+ ArtifactInfo artifactInfo = IndexUtils.constructArtifactInfo(doc, context);
- if ( artifactInfo != null )
- {
- artifactInfo.setRepository( context.getRepositoryId() );
- artifactInfo.setContext( context.getId() );
+ if (artifactInfo != null) {
+ artifactInfo.setRepository(context.getRepositoryId());
+ artifactInfo.setContext(context.getId());
- if ( req.getArtifactInfoFilter() != null )
- {
- if ( !req.getArtifactInfoFilter().accepts( context, artifactInfo ) )
- {
+ if (req.getArtifactInfoFilter() != null) {
+ if (!req.getArtifactInfoFilter().accepts(context, artifactInfo)) {
continue;
}
}
- if ( req.getArtifactInfoPostprocessor() != null )
- {
- req.getArtifactInfoPostprocessor().postprocess( context, artifactInfo );
+ if (req.getArtifactInfoPostprocessor() != null) {
+ req.getArtifactInfoPostprocessor().postprocess(context, artifactInfo);
}
- result.add( artifactInfo );
+ result.add(artifactInfo);
}
}
- }
- finally
- {
- context.releaseIndexSearcher( indexSearcher );
+ } finally {
+ context.releaseIndexSearcher(indexSearcher);
}
}
return hitCount;
}
- protected int searchGrouped( GroupedSearchRequest req, Map<String, ArtifactInfoGroup> result, Grouping grouping,
- List<IndexingContext> participatingContexts, Query query )
- throws IOException
- {
+ protected int searchGrouped(
+ GroupedSearchRequest req,
+ Map<String, ArtifactInfoGroup> result,
+ Grouping grouping,
+ List<IndexingContext> participatingContexts,
+ Query query)
+ throws IOException {
int hitCount = 0;
- for ( IndexingContext context : participatingContexts )
- {
+ for (IndexingContext context : participatingContexts) {
final IndexSearcher indexSearcher = context.acquireIndexSearcher();
- try
- {
- final TopScoreDocCollector collector = doSearchWithCeiling( req, indexSearcher, query );
+ try {
+ final TopScoreDocCollector collector = doSearchWithCeiling(req, indexSearcher, query);
- if ( collector.getTotalHits() > 0 )
- {
+ if (collector.getTotalHits() > 0) {
ScoreDoc[] scoreDocs = collector.topDocs().scoreDocs;
hitCount += collector.getTotalHits();
- for ( ScoreDoc scoreDoc : scoreDocs )
- {
- Document doc = indexSearcher.doc( scoreDoc.doc );
+ for (ScoreDoc scoreDoc : scoreDocs) {
+ Document doc = indexSearcher.doc(scoreDoc.doc);
- ArtifactInfo artifactInfo = IndexUtils.constructArtifactInfo( doc, context );
+ ArtifactInfo artifactInfo = IndexUtils.constructArtifactInfo(doc, context);
- if ( artifactInfo != null )
- {
- artifactInfo.setRepository( context.getRepositoryId() );
- artifactInfo.setContext( context.getId() );
+ if (artifactInfo != null) {
+ artifactInfo.setRepository(context.getRepositoryId());
+ artifactInfo.setContext(context.getId());
- if ( req.getArtifactInfoFilter() != null )
- {
- if ( !req.getArtifactInfoFilter().accepts( context, artifactInfo ) )
- {
+ if (req.getArtifactInfoFilter() != null) {
+ if (!req.getArtifactInfoFilter().accepts(context, artifactInfo)) {
continue;
}
}
- if ( req.getArtifactInfoPostprocessor() != null )
- {
- req.getArtifactInfoPostprocessor().postprocess( context, artifactInfo );
+ if (req.getArtifactInfoPostprocessor() != null) {
+ req.getArtifactInfoPostprocessor().postprocess(context, artifactInfo);
}
- if ( !grouping.addArtifactInfo( result, artifactInfo ) )
- {
+ if (!grouping.addArtifactInfo(result, artifactInfo)) {
// fix the hitCount accordingly
hitCount--;
}
}
}
}
- }
- finally
- {
- context.releaseIndexSearcher( indexSearcher );
+ } finally {
+ context.releaseIndexSearcher(indexSearcher);
}
}
@@ -259,47 +235,36 @@ public class DefaultSearchEngine
// == NG Search
- public IteratorSearchResponse searchIteratorPaged( IteratorSearchRequest request,
- Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchIteratorPaged( request, indexingContexts, false );
+ public IteratorSearchResponse searchIteratorPaged(
+ IteratorSearchRequest request, Collection<IndexingContext> indexingContexts) throws IOException {
+ return searchIteratorPaged(request, indexingContexts, false);
}
- public IteratorSearchResponse forceSearchIteratorPaged( IteratorSearchRequest request,
- Collection<IndexingContext> indexingContexts )
- throws IOException
- {
- return searchIteratorPaged( request, indexingContexts, true );
+ public IteratorSearchResponse forceSearchIteratorPaged(
+ IteratorSearchRequest request, Collection<IndexingContext> indexingContexts) throws IOException {
+ return searchIteratorPaged(request, indexingContexts, true);
}
- private IteratorSearchResponse searchIteratorPaged( IteratorSearchRequest request,
- Collection<IndexingContext> indexingContexts,
- boolean ignoreContext )
- throws IOException
- {
- List<IndexingContext> contexts = getParticipatingContexts( indexingContexts, ignoreContext );
+ private IteratorSearchResponse searchIteratorPaged(
+ IteratorSearchRequest request, Collection<IndexingContext> indexingContexts, boolean ignoreContext)
+ throws IOException {
+ List<IndexingContext> contexts = getParticipatingContexts(indexingContexts, ignoreContext);
- NexusIndexMultiReader multiReader = getMergedIndexReader( indexingContexts, ignoreContext );
+ NexusIndexMultiReader multiReader = getMergedIndexReader(indexingContexts, ignoreContext);
- NexusIndexMultiSearcher indexSearcher = new NexusIndexMultiSearcher( multiReader );
+ NexusIndexMultiSearcher indexSearcher = new NexusIndexMultiSearcher(multiReader);
- try
- {
- TopScoreDocCollector hits = doSearchWithCeiling( request, indexSearcher, request.getQuery() );
+ try {
+ TopScoreDocCollector hits = doSearchWithCeiling(request, indexSearcher, request.getQuery());
- return new IteratorSearchResponse( request.getQuery(), hits.getTotalHits(),
- new DefaultIteratorResultSet( request, indexSearcher, contexts,
- hits.topDocs() ) );
- }
- catch ( IOException | RuntimeException e )
- {
- try
- {
+ return new IteratorSearchResponse(
+ request.getQuery(),
+ hits.getTotalHits(),
+ new DefaultIteratorResultSet(request, indexSearcher, contexts, hits.topDocs()));
+ } catch (IOException | RuntimeException e) {
+ try {
indexSearcher.release();
- }
- catch ( Exception secondary )
- {
+ } catch (Exception secondary) {
// do not mask original exception
}
throw e;
@@ -308,48 +273,42 @@ public class DefaultSearchEngine
// ==
- protected TopScoreDocCollector doSearchWithCeiling( final AbstractSearchRequest request,
- final IndexSearcher indexSearcher, final Query query )
- throws IOException
- {
- int topHitCount = getTopDocsCollectorHitNum( request, AbstractSearchRequest.UNDEFINED );
+ protected TopScoreDocCollector doSearchWithCeiling(
+ final AbstractSearchRequest request, final IndexSearcher indexSearcher, final Query query)
+ throws IOException {
+ int topHitCount = getTopDocsCollectorHitNum(request, AbstractSearchRequest.UNDEFINED);
- if ( AbstractSearchRequest.UNDEFINED != topHitCount )
- {
+ if (AbstractSearchRequest.UNDEFINED != topHitCount) {
// count is set, simply just execute it as-is
- final TopScoreDocCollector hits = TopScoreDocCollector.create( topHitCount, Integer.MAX_VALUE );
+ final TopScoreDocCollector hits = TopScoreDocCollector.create(topHitCount, Integer.MAX_VALUE);
- indexSearcher.search( query, hits );
+ indexSearcher.search(query, hits);
return hits;
- }
- else
- {
+ } else {
// set something reasonable as 1k
topHitCount = 1000;
// perform search
- TopScoreDocCollector hits = TopScoreDocCollector.create( topHitCount, Integer.MAX_VALUE );
- indexSearcher.search( query, hits );
+ TopScoreDocCollector hits = TopScoreDocCollector.create(topHitCount, Integer.MAX_VALUE);
+ indexSearcher.search(query, hits);
// check total hits against, does it fit?
- if ( topHitCount < hits.getTotalHits() )
- {
+ if (topHitCount < hits.getTotalHits()) {
topHitCount = hits.getTotalHits();
- if ( getLogger().isDebugEnabled() )
- {
+ if (getLogger().isDebugEnabled()) {
// warn the user and leave trace just before OOM might happen
// the hits.getTotalHits() might be HUUGE
- getLogger().debug(
- "Executing unbounded search, and fitting topHitCounts to " + topHitCount
- + ", an OOMEx might follow. To avoid OOM use narrower queries or limit your expectancy with "
- + "request.setCount() method where appropriate. See MINDEXER-14 for details." );
+ getLogger()
+ .debug("Executing unbounded search, and fitting topHitCounts to " + topHitCount
+ + ", an OOMEx might follow. To avoid OOM use narrower queries or limit your expectancy with "
+ + "request.setCount() method where appropriate. See MINDEXER-14 for details.");
}
// redo all, but this time with correct numbers
- hits = TopScoreDocCollector.create( topHitCount, Integer.MAX_VALUE );
- indexSearcher.search( query, hits );
+ hits = TopScoreDocCollector.create(topHitCount, Integer.MAX_VALUE);
+ indexSearcher.search(query, hits);
}
return hits;
@@ -359,18 +318,15 @@ public class DefaultSearchEngine
/**
* Returns the list of participating contexts. Does not locks them, just builds a list of them.
*/
- protected List<IndexingContext> getParticipatingContexts( final Collection<IndexingContext> indexingContexts,
- final boolean ignoreContext )
- {
+ protected List<IndexingContext> getParticipatingContexts(
+ final Collection<IndexingContext> indexingContexts, final boolean ignoreContext) {
// to not change the API all away, but we need stable ordering here
// filter for those 1st, that take part in here
- final ArrayList<IndexingContext> contexts = new ArrayList<>( indexingContexts.size() );
+ final ArrayList<IndexingContext> contexts = new ArrayList<>(indexingContexts.size());
- for ( IndexingContext ctx : indexingContexts )
- {
- if ( ignoreContext || ctx.isSearchable() )
- {
- contexts.add( ctx );
+ for (IndexingContext ctx : indexingContexts) {
+ if (ignoreContext || ctx.isSearchable()) {
+ contexts.add(ctx);
}
}
@@ -380,36 +336,28 @@ public class DefaultSearchEngine
/**
* Locks down participating contexts, and returns a "merged" reader of them. In case of error, unlocks as part of
* cleanup and re-throws exception. Without error, it is the duty of caller to unlock contexts!
- *
+ *
* @param indexingContexts
* @param ignoreContext
* @return
* @throws IOException
*/
- protected NexusIndexMultiReader getMergedIndexReader( final Collection<IndexingContext> indexingContexts,
- final boolean ignoreContext )
- throws IOException
- {
- final List<IndexingContext> contexts = getParticipatingContexts( indexingContexts, ignoreContext );
- return new NexusIndexMultiReader( contexts );
+ protected NexusIndexMultiReader getMergedIndexReader(
+ final Collection<IndexingContext> indexingContexts, final boolean ignoreContext) throws IOException {
+ final List<IndexingContext> contexts = getParticipatingContexts(indexingContexts, ignoreContext);
+ return new NexusIndexMultiReader(contexts);
}
- protected int getTopDocsCollectorHitNum( final AbstractSearchRequest request, final int ceiling )
- {
- if ( request instanceof AbstractSearchPageableRequest )
- {
+ protected int getTopDocsCollectorHitNum(final AbstractSearchRequest request, final int ceiling) {
+ if (request instanceof AbstractSearchPageableRequest) {
final AbstractSearchPageableRequest prequest = (AbstractSearchPageableRequest) request;
- if ( AbstractSearchRequest.UNDEFINED != prequest.getCount() )
- {
+ if (AbstractSearchRequest.UNDEFINED != prequest.getCount()) {
// easy, user knows and tells us how many results he want
return prequest.getCount() + prequest.getStart();
}
- }
- else
- {
- if ( AbstractSearchRequest.UNDEFINED != request.getCount() )
- {
+ } else {
+ if (AbstractSearchRequest.UNDEFINED != request.getCount()) {
// easy, user knows and tells us how many results he want
return request.getCount();
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/Field.java b/indexer-core/src/main/java/org/apache/maven/index/Field.java
index bd8e816..22046b2 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/Field.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/Field.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,14 +16,14 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-public class Field
-{
+public class Field {
public static final String NOT_PRESENT = "N/P";
private final Field parent;
@@ -38,8 +36,7 @@ public class Field
private final List<IndexerField> indexerFields;
- public Field( final Field parent, final String namespace, final String name, final String description )
- {
+ public Field(final Field parent, final String namespace, final String name, final String description) {
this.parent = parent;
this.namespace = namespace;
@@ -51,48 +48,39 @@ public class Field
this.indexerFields = new ArrayList<>();
}
- public Field getParent()
- {
+ public Field getParent() {
return parent;
}
- public String getNamespace()
- {
+ public String getNamespace() {
return namespace;
}
- public String getFieldName()
- {
+ public String getFieldName() {
return fieldName;
}
- public String getDescription()
- {
+ public String getDescription() {
return description;
}
- public Collection<IndexerField> getIndexerFields()
- {
- return Collections.unmodifiableList( indexerFields );
+ public Collection<IndexerField> getIndexerFields() {
+ return Collections.unmodifiableList(indexerFields);
}
- public boolean addIndexerField( IndexerField field )
- {
- return indexerFields.add( field );
+ public boolean addIndexerField(IndexerField field) {
+ return indexerFields.add(field);
}
- public boolean removeIndexerField( IndexerField field )
- {
- return indexerFields.remove( field );
+ public boolean removeIndexerField(IndexerField field) {
+ return indexerFields.remove(field);
}
- public String getFQN()
- {
+ public String getFQN() {
return getNamespace() + getFieldName();
}
- public String toString()
- {
+ public String toString() {
return getFQN() + " (with " + getIndexerFields().size() + " registered index fields)";
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java b/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java
index b64958e..e6cde30 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/FlatSearchRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Arrays;
import java.util.Comparator;
@@ -27,43 +26,35 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A flat search request.
- *
+ *
* @see Indexer#searchFlat(FlatSearchRequest)
*/
-public class FlatSearchRequest
- extends AbstractSearchRequest
-{
+public class FlatSearchRequest extends AbstractSearchRequest {
private Comparator<ArtifactInfo> artifactInfoComparator;
- public FlatSearchRequest( Query query )
- {
- this( query, ArtifactInfo.VERSION_COMPARATOR );
+ public FlatSearchRequest(Query query) {
+ this(query, ArtifactInfo.VERSION_COMPARATOR);
}
- public FlatSearchRequest( Query query, Comparator<ArtifactInfo> artifactInfoComparator )
- {
- this( query, artifactInfoComparator, null );
+ public FlatSearchRequest(Query query, Comparator<ArtifactInfo> artifactInfoComparator) {
+ this(query, artifactInfoComparator, null);
}
- public FlatSearchRequest( Query query, IndexingContext context )
- {
- this( query, ArtifactInfo.VERSION_COMPARATOR, context );
+ public FlatSearchRequest(Query query, IndexingContext context) {
+ this(query, ArtifactInfo.VERSION_COMPARATOR, context);
}
- public FlatSearchRequest( Query query, Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext context )
- {
- super( query, context != null ? Arrays.asList( context ) : null );
+ public FlatSearchRequest(Query query, Comparator<ArtifactInfo> artifactInfoComparator, IndexingContext context) {
+ super(query, context != null ? Arrays.asList(context) : null);
this.artifactInfoComparator = artifactInfoComparator;
}
- public Comparator<ArtifactInfo> getArtifactInfoComparator()
- {
+ public Comparator<ArtifactInfo> getArtifactInfoComparator() {
return artifactInfoComparator;
}
- public void setArtifactInfoComparator( Comparator<ArtifactInfo> artifactInfoComparator )
- {
+ public void setArtifactInfoComparator(Comparator<ArtifactInfo> artifactInfoComparator) {
this.artifactInfoComparator = artifactInfoComparator;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java b/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java
index f9d7a6e..56db823 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/FlatSearchResponse.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Set;
@@ -25,23 +24,19 @@ import org.apache.lucene.search.Query;
/**
* A flat search response.
- *
+ *
* @see Indexer#searchFlat(FlatSearchRequest)
*/
-public class FlatSearchResponse
- extends AbstractSearchResponse
-{
+public class FlatSearchResponse extends AbstractSearchResponse {
private final Set<ArtifactInfo> results;
- public FlatSearchResponse( Query query, int totalHits, Set<ArtifactInfo> results )
- {
- super( query, totalHits, results.size() );
+ public FlatSearchResponse(Query query, int totalHits, Set<ArtifactInfo> results) {
+ super(query, totalHits, results.size());
this.results = results;
}
- public Set<ArtifactInfo> getResults()
- {
+ public Set<ArtifactInfo> getResults() {
return results;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java b/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java
index 16797c2..26c895c 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Arrays;
import java.util.Comparator;
@@ -28,58 +27,48 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A grouped search request. This kinds of request is not pageable, since order of incoming hits are not defined, hence
* paging between Document hits makes no sense, would produce unpredictable (and probably not meaningful) results.
- *
+ *
* @see Indexer#searchGrouped(GroupedSearchRequest)
*/
-public class GroupedSearchRequest
- extends AbstractSearchRequest
-{
+public class GroupedSearchRequest extends AbstractSearchRequest {
private Grouping grouping;
private Comparator<String> groupKeyComparator;
- public GroupedSearchRequest( Query query, Grouping grouping )
- {
- this( query, grouping, String.CASE_INSENSITIVE_ORDER );
+ public GroupedSearchRequest(Query query, Grouping grouping) {
+ this(query, grouping, String.CASE_INSENSITIVE_ORDER);
}
- public GroupedSearchRequest( Query query, Grouping grouping, Comparator<String> groupKeyComparator )
- {
- this( query, grouping, groupKeyComparator, null );
+ public GroupedSearchRequest(Query query, Grouping grouping, Comparator<String> groupKeyComparator) {
+ this(query, grouping, groupKeyComparator, null);
}
- public GroupedSearchRequest( Query query, Grouping grouping, IndexingContext context )
- {
- this( query, grouping, String.CASE_INSENSITIVE_ORDER, context );
+ public GroupedSearchRequest(Query query, Grouping grouping, IndexingContext context) {
+ this(query, grouping, String.CASE_INSENSITIVE_ORDER, context);
}
- public GroupedSearchRequest( Query query, Grouping grouping, Comparator<String> groupKeyComparator,
- IndexingContext context )
- {
- super( query, context != null ? Arrays.asList( context ) : null );
+ public GroupedSearchRequest(
+ Query query, Grouping grouping, Comparator<String> groupKeyComparator, IndexingContext context) {
+ super(query, context != null ? Arrays.asList(context) : null);
this.grouping = grouping;
this.groupKeyComparator = groupKeyComparator;
}
- public Grouping getGrouping()
- {
+ public Grouping getGrouping() {
return grouping;
}
- public void setGrouping( Grouping grouping )
- {
+ public void setGrouping(Grouping grouping) {
this.grouping = grouping;
}
- public Comparator<String> getGroupKeyComparator()
- {
+ public Comparator<String> getGroupKeyComparator() {
return groupKeyComparator;
}
- public void setGroupKeyComparator( Comparator<String> groupKeyComparator )
- {
+ public void setGroupKeyComparator(Comparator<String> groupKeyComparator) {
this.groupKeyComparator = groupKeyComparator;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java b/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java
index a62cb0f..db091e2 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/GroupedSearchResponse.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Map;
@@ -25,23 +24,19 @@ import org.apache.lucene.search.Query;
/**
* A grouped search response. For hitsCount, it reports the number of groups found.
- *
+ *
* @see Indexer#searchGrouped(GroupedSearchRequest)
*/
-public class GroupedSearchResponse
- extends AbstractSearchResponse
-{
+public class GroupedSearchResponse extends AbstractSearchResponse {
private final Map<String, ArtifactInfoGroup> results;
- public GroupedSearchResponse( Query query, int totalHits, Map<String, ArtifactInfoGroup> results )
- {
- super( query, totalHits, results.size() );
+ public GroupedSearchResponse(Query query, int totalHits, Map<String, ArtifactInfoGroup> results) {
+ super(query, totalHits, results.size());
this.results = results;
}
- public Map<String, ArtifactInfoGroup> getResults()
- {
+ public Map<String, ArtifactInfoGroup> getResults() {
return results;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/Grouping.java b/indexer-core/src/main/java/org/apache/maven/index/Grouping.java
index 48e1fa5..ac1a44f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/Grouping.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/Grouping.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,25 +16,24 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Map;
/**
* A grouping criteria for grouped searches.
- *
+ *
* @see Indexer#searchGrouped(GroupedSearchRequest)
* @author Tamas Cservenak
*/
-public interface Grouping
-{
+public interface Grouping {
/**
* Adds a single ArticatInfo to the result map.
- *
+ *
* @param result
* @param artifactInfo
* @return true, if the Grouping changed by addition of new artifactInfo
*/
- boolean addArtifactInfo( Map<String, ArtifactInfoGroup> result, ArtifactInfo artifactInfo );
-
+ boolean addArtifactInfo(Map<String, ArtifactInfoGroup> result, ArtifactInfo artifactInfo);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/Indexer.java b/indexer-core/src/main/java/org/apache/maven/index/Indexer.java
index b9ae97b..4a64f78 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/Indexer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/Indexer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
@@ -37,15 +36,14 @@ import org.apache.maven.index.expr.SearchExpression;
* making it less cludged, and focusing on main use cases. This component does not hold any reference to contexts
* it creates or uses, and caller of every method (except the createIndexingContext naturally) is obliged to
* explicitly supply {@link IndexingContext} to work with (perform searches or such).
- *
+ *
* @author cstamas
* @since 5.1.0
*/
-public interface Indexer
-{
+public interface Indexer {
/**
* Creates an indexing context.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents. You might have several contexts
* indexing same repository ID, but on separate locations.
@@ -69,14 +67,21 @@ public interface Indexer
* @throws IllegalArgumentException in case the supplied list of IndexCreators are having non-satisfiable
* dependencies.
*/
- IndexingContext createIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- String repositoryUrl, String indexUpdateUrl, boolean searchable,
- boolean reclaim, List<? extends IndexCreator> indexers )
- throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException;
+ IndexingContext createIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ boolean searchable,
+ boolean reclaim,
+ List<? extends IndexCreator> indexers)
+ throws IOException, ExistingLuceneIndexMismatchException, IllegalArgumentException;
/**
* Creates a merged indexing context.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents. You might have several contexts
* indexing same repository ID, but on separate locations.
@@ -87,20 +92,24 @@ public interface Indexer
* @return the context created.
* @throws IOException in case of some serious IO problem.
*/
- IndexingContext createMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- boolean searchable, ContextMemberProvider membersProvider )
- throws IOException;
+ IndexingContext createMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException;
/**
* Closes the indexing context: closes it and deletes (if specified) the index files.
- *
+ *
* @param context the one needed to be closed, never {@code null}.
* @param deleteFiles {@code true} if all indexer related files (including Lucene index!) needs to be deleted,
* {@code false} otherwise.
* @throws IOException
*/
- void closeIndexingContext( IndexingContext context, boolean deleteFiles )
- throws IOException;
+ void closeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException;
// ----------------------------------------------------------------------------
// Modifying
@@ -113,28 +122,25 @@ public interface Indexer
* @param context
* @throws IOException
*/
- void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
- throws IOException;
+ void addArtifactToIndex(ArtifactContext ac, IndexingContext context) throws IOException;
/**
* Adds the passed in artifact contexts to passed in indexing context.
- *
+ *
* @param acs
* @param context
* @throws IOException
*/
- void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException;
+ void addArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException;
/**
* Removes the passed in artifacts contexts from passed in indexing context.
- *
+ *
* @param acs
* @param context
* @throws IOException
*/
- void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException;
+ void deleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException;
// ----------------------------------------------------------------------------
// Searching
@@ -142,33 +148,30 @@ public interface Indexer
/**
* Searches according the request parameters.
- *
+ *
* @param request
* @return search response
* @throws IOException
*/
- FlatSearchResponse searchFlat( FlatSearchRequest request )
- throws IOException;
+ FlatSearchResponse searchFlat(FlatSearchRequest request) throws IOException;
/**
* Searches according to request parameters.
- *
+ *
* @param request
* @return search response
* @throws IOException
*/
- IteratorSearchResponse searchIterator( IteratorSearchRequest request )
- throws IOException;
+ IteratorSearchResponse searchIterator(IteratorSearchRequest request) throws IOException;
/**
* Searches according the request parameters.
- *
+ *
* @param request
* @return search response
* @throws IOException
*/
- GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
- throws IOException;
+ GroupedSearchResponse searchGrouped(GroupedSearchRequest request) throws IOException;
// ----------------------------------------------------------------------------
// Identify
@@ -179,26 +182,24 @@ public interface Indexer
* {@link #identify(Query, Collection)} method will be invoked searching with calculated hash the {@link MAVEN#SHA1}
* field. This is just a shorthand method, as these calls are simply calculating hex encoded SHA1 of the file, and
* invoking the {@link #constructQuery(Field, SearchExpression)} and {@link #identify(Query, Collection)} methods.
- *
+ *
* @param artifact the file
* @param contexts in which to perform the action
* @return collection of identified matches.
* @throws IOException
*/
- Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
- throws IOException;
+ Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException;
/**
* Performs an "identity" search. Those are usually simple key-value queries, involving "unique" fields like
* {@link MAVEN#SHA1} or such.
- *
+ *
* @param query
* @param contexts
* @return collection of identified matches.
* @throws IOException
*/
- Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
- throws IOException;
+ Collection<ArtifactInfo> identify(Query query, Collection<IndexingContext> contexts) throws IOException;
// ----------------------------------------------------------------------------
// Query construction
@@ -207,7 +208,7 @@ public interface Indexer
/**
* Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a
* field indexed, and WHAT query is needed to achieve that search.
- *
+ *
* @param field
* @param expression
* @return the query to be used for search.
@@ -216,8 +217,7 @@ public interface Indexer
* @see org.apache.maven.index.expr.SourcedSearchExpression
* @throws IllegalArgumentException
*/
- Query constructQuery( Field field, SearchExpression expression )
- throws IllegalArgumentException;
+ Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException;
/**
* Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a
@@ -229,6 +229,5 @@ public interface Indexer
* @return
* @throws IllegalArgumentException
*/
- Query constructQuery( Field field, String expression, SearchType searchType )
- throws IllegalArgumentException;
+ Query constructQuery(Field field, String expression, SearchType searchType) throws IllegalArgumentException;
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IndexerEngine.java b/indexer-core/src/main/java/org/apache/maven/index/IndexerEngine.java
index ad02d2b..25f7c7f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IndexerEngine.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IndexerEngine.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.IOException;
@@ -26,24 +25,19 @@ import org.apache.maven.index.context.IndexingContext;
/**
* An indexer engine used to index, update and remote artifacts to the indexing context.
*/
-public interface IndexerEngine
-{
+public interface IndexerEngine {
/**
* Add new artifact to the index
*/
- void index( IndexingContext context, ArtifactContext ac )
- throws IOException;
+ void index(IndexingContext context, ArtifactContext ac) throws IOException;
/**
* Replace data for a previously indexed artifact
*/
- void update( IndexingContext context, ArtifactContext ac )
- throws IOException;
+ void update(IndexingContext context, ArtifactContext ac) throws IOException;
/**
* Remove artifact to the index
*/
- void remove( IndexingContext context, ArtifactContext ac )
- throws IOException;
-
+ void remove(IndexingContext context, ArtifactContext ac) throws IOException;
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IndexerField.java b/indexer-core/src/main/java/org/apache/maven/index/IndexerField.java
index 3d67b2a..420f7e4 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IndexerField.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IndexerField.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@@ -26,11 +25,10 @@ import org.apache.lucene.index.IndexOptions;
/**
* Holds basic information about Indexer field, how it is stored. To keep this centralized, and not spread across code.
* Since Lucene 2.x, the field names are encoded, so please use real chatty names instead of cryptic chars!
- *
+ *
* @author cstamas
*/
-public class IndexerField
-{
+public class IndexerField {
private final org.apache.maven.index.Field ontology;
private final IndexerFieldVersion version;
@@ -51,32 +49,34 @@ public class IndexerField
/** Indexed, tokenized, stored. */
public static final FieldType ANALYZED_STORED = new FieldType();
- static
- {
- KEYWORD_NOT_STORED.setIndexOptions( IndexOptions.DOCS_AND_FREQS_AND_POSITIONS );
- KEYWORD_NOT_STORED.setStored( false );
- KEYWORD_NOT_STORED.setTokenized( false );
+ static {
+ KEYWORD_NOT_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+ KEYWORD_NOT_STORED.setStored(false);
+ KEYWORD_NOT_STORED.setTokenized(false);
KEYWORD_NOT_STORED.freeze();
- KEYWORD_STORED.setIndexOptions( IndexOptions.DOCS_AND_FREQS_AND_POSITIONS );
- KEYWORD_STORED.setStored( true );
- KEYWORD_STORED.setTokenized( false );
+ KEYWORD_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+ KEYWORD_STORED.setStored(true);
+ KEYWORD_STORED.setTokenized(false);
KEYWORD_STORED.freeze();
- ANALYZED_NOT_STORED.setIndexOptions( IndexOptions.DOCS_AND_FREQS_AND_POSITIONS );
- ANALYZED_NOT_STORED.setStored( false );
- ANALYZED_NOT_STORED.setTokenized( true );
+ ANALYZED_NOT_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+ ANALYZED_NOT_STORED.setStored(false);
+ ANALYZED_NOT_STORED.setTokenized(true);
ANALYZED_NOT_STORED.freeze();
- ANALYZED_STORED.setIndexOptions( IndexOptions.DOCS_AND_FREQS_AND_POSITIONS );
- ANALYZED_STORED.setStored( true );
- ANALYZED_STORED.setTokenized( true );
+ ANALYZED_STORED.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+ ANALYZED_STORED.setStored(true);
+ ANALYZED_STORED.setTokenized(true);
ANALYZED_STORED.freeze();
}
- public IndexerField( final org.apache.maven.index.Field ontology, final IndexerFieldVersion version,
- final String key, final String description, final FieldType fieldType )
- {
+ public IndexerField(
+ final org.apache.maven.index.Field ontology,
+ final IndexerFieldVersion version,
+ final String key,
+ final String description,
+ final FieldType fieldType) {
this.ontology = ontology;
this.version = version;
@@ -85,46 +85,38 @@ public class IndexerField
this.fieldType = fieldType;
- ontology.addIndexerField( this );
+ ontology.addIndexerField(this);
}
- public org.apache.maven.index.Field getOntology()
- {
+ public org.apache.maven.index.Field getOntology() {
return ontology;
}
- public IndexerFieldVersion getVersion()
- {
+ public IndexerFieldVersion getVersion() {
return version;
}
- public String getKey()
- {
+ public String getKey() {
return key;
}
- public FieldType getFieldType()
- {
+ public FieldType getFieldType() {
return fieldType;
}
- public boolean isIndexed()
- {
+ public boolean isIndexed() {
return fieldType.indexOptions() != IndexOptions.NONE;
}
- public boolean isKeyword()
- {
+ public boolean isKeyword() {
return isIndexed() && !fieldType.tokenized();
}
- public boolean isStored()
- {
+ public boolean isStored() {
return fieldType.stored();
}
- public Field toField( String value )
- {
- return new Field( getKey(), value, getFieldType() );
+ public Field toField(String value) {
+ return new Field(getKey(), value, getFieldType());
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IndexerFieldVersion.java b/indexer-core/src/main/java/org/apache/maven/index/IndexerFieldVersion.java
index e89cc52..9b924c8 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IndexerFieldVersion.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IndexerFieldVersion.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,9 +16,9 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
-public enum IndexerFieldVersion
-{
+public enum IndexerFieldVersion {
/**
* The 1.x line.
*/
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IteratorResultSet.java b/indexer-core/src/main/java/org/apache/maven/index/IteratorResultSet.java
index e57350c..b5beb48 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IteratorResultSet.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IteratorResultSet.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.Closeable;
import java.util.Iterator;
@@ -28,17 +27,15 @@ import java.util.Iterator;
* implement things like "streaming" results etc. The result set is java.util.Iterator, but is made also
* java.lang.Iterable to make it possible to take part in operations like "for-each", but it will usually return itself
* as Iterator.
- *
+ *
* @author cstamas
*/
-public interface IteratorResultSet
- extends Iterator<ArtifactInfo>, Iterable<ArtifactInfo>, Closeable
-{
+public interface IteratorResultSet extends Iterator<ArtifactInfo>, Iterable<ArtifactInfo>, Closeable {
/**
* Returns the up-to-date number of the actual number of loaded Lucene Documents that were converted into
* ArtifactInfo object until last next() invocation. Warning: this method will return ALL touched/loaded document
* count, even those that are filtered out and NOT returned by iterator's next() method!
- *
+ *
* @return total number of processed ArtifactInfos so far
*/
int getTotalProcessedArtifactInfoCount();
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchRequest.java b/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchRequest.java
index b0df393..b59cc8b 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.Arrays;
import java.util.List;
@@ -28,36 +27,29 @@ import org.apache.maven.index.context.IndexingContext;
/**
* A Search Request that will perform the new "iterator-like" type of search. It is pageable as plus, but on downside,
* it's corresponding result does not result size in advance.
- *
+ *
* @author cstamas
*/
-public class IteratorSearchRequest
- extends AbstractSearchPageableRequest
-{
- public IteratorSearchRequest( Query query )
- {
- this( query, null, null );
+public class IteratorSearchRequest extends AbstractSearchPageableRequest {
+ public IteratorSearchRequest(Query query) {
+ this(query, null, null);
}
- public IteratorSearchRequest( Query query, ArtifactInfoFilter filter )
- {
- this( query, null, filter );
+ public IteratorSearchRequest(Query query, ArtifactInfoFilter filter) {
+ this(query, null, filter);
}
- public IteratorSearchRequest( Query query, IndexingContext context )
- {
- this( query, context != null ? Arrays.asList( context ) : null, null );
+ public IteratorSearchRequest(Query query, IndexingContext context) {
+ this(query, context != null ? Arrays.asList(context) : null, null);
}
- public IteratorSearchRequest( Query query, List<IndexingContext> contexts )
- {
- this( query, contexts, null );
+ public IteratorSearchRequest(Query query, List<IndexingContext> contexts) {
+ this(query, contexts, null);
}
- public IteratorSearchRequest( Query query, List<IndexingContext> contexts, ArtifactInfoFilter filter )
- {
- super( query, contexts );
+ public IteratorSearchRequest(Query query, List<IndexingContext> contexts, ArtifactInfoFilter filter) {
+ super(query, contexts);
- setArtifactInfoFilter( filter );
+ setArtifactInfoFilter(filter);
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchResponse.java b/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchResponse.java
index f82b383..4172926 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchResponse.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/IteratorSearchResponse.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.Closeable;
import java.io.IOException;
@@ -29,102 +28,84 @@ import org.apache.lucene.search.Query;
* A Search Response for the "iterator-like" search request. The totalHitsCount reports <em>total</em> hits found on
* index, even if the set of ArtifactInfos are usually limited! On the flipside, the hitsCount is actually unknown,
* since this instance performs filtering on the fly, hence it does not know how many hits it will return ahead of time.
- *
+ *
* @author cstamas
*/
-public class IteratorSearchResponse
- extends AbstractSearchResponse
- implements Iterable<ArtifactInfo>, Closeable
-{
+public class IteratorSearchResponse extends AbstractSearchResponse implements Iterable<ArtifactInfo>, Closeable {
private final IteratorResultSet results;
- public IteratorSearchResponse( Query query, int totalHits, IteratorResultSet results )
- {
- super( query, totalHits, -1 );
+ public IteratorSearchResponse(Query query, int totalHits, IteratorResultSet results) {
+ super(query, totalHits, -1);
this.results = results;
}
- public IteratorResultSet getResults()
- {
+ public IteratorResultSet getResults() {
return results;
}
- public IteratorResultSet iterator()
- {
+ public IteratorResultSet iterator() {
return getResults();
}
@Override
- public void close()
- throws IOException
- {
+ public void close() throws IOException {
getResults().close();
}
/**
* A helper method delegating the call to the IteratorResultSet.
- *
+ *
* @return
*/
- public int getTotalProcessedArtifactInfoCount()
- {
+ public int getTotalProcessedArtifactInfoCount() {
return getResults().getTotalProcessedArtifactInfoCount();
}
// ==
- public static final IteratorResultSet EMPTY_ITERATOR_RESULT_SET = new IteratorResultSet()
- {
- public boolean hasNext()
- {
+ public static final IteratorResultSet EMPTY_ITERATOR_RESULT_SET = new IteratorResultSet() {
+ public boolean hasNext() {
return false;
}
- public ArtifactInfo next()
- {
+ public ArtifactInfo next() {
return null;
}
- public void remove()
- {
- throw new UnsupportedOperationException( "Method not supported on " + getClass().getName() );
+ public void remove() {
+ throw new UnsupportedOperationException(
+ "Method not supported on " + getClass().getName());
}
- public Iterator<ArtifactInfo> iterator()
- {
+ public Iterator<ArtifactInfo> iterator() {
return this;
}
- public int getTotalProcessedArtifactInfoCount()
- {
+ public int getTotalProcessedArtifactInfoCount() {
return 0;
}
- public void close()
- throws IOException
- {
- }
+ public void close() throws IOException {}
};
- public static IteratorSearchResponse empty( final Query q )
- {
- return new IteratorSearchResponse( q, 0, EMPTY_ITERATOR_RESULT_SET );
+ public static IteratorSearchResponse empty(final Query q) {
+ return new IteratorSearchResponse(q, 0, EMPTY_ITERATOR_RESULT_SET);
}
/**
* Empty search response.
- *
+ *
* @deprecated Use {@link #empty(Query)} instead.
*/
- public static final IteratorSearchResponse EMPTY_ITERATOR_SEARCH_RESPONSE = empty( null );
+ public static final IteratorSearchResponse EMPTY_ITERATOR_SEARCH_RESPONSE = empty(null);
/**
* Too many search response.
- *
+ *
* @deprecated Left here for backward compatibility, but since version 4.1.0 (see MINDEXER-14) there is NO notion of
* "hit limit" anymore.
*/
public static final IteratorSearchResponse TOO_MANY_HITS_ITERATOR_SEARCH_RESPONSE =
- new IteratorSearchResponse( null, -1, EMPTY_ITERATOR_RESULT_SET );
+ new IteratorSearchResponse(null, -1, EMPTY_ITERATOR_RESULT_SET);
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/MAVEN.java b/indexer-core/src/main/java/org/apache/maven/index/MAVEN.java
index 42c124b..46f07c2 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/MAVEN.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/MAVEN.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,52 +16,52 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
/**
* Maven ontology.
- *
+ *
* @author cstamas
*/
-public interface MAVEN
-{
+public interface MAVEN {
/** Maven namespace */
String MAVEN_NAMESPACE = "urn:maven#";
- Field REPOSITORY_ID = new Field( null, MAVEN_NAMESPACE, "repositoryId", "Artifact Repository ID" );
+ Field REPOSITORY_ID = new Field(null, MAVEN_NAMESPACE, "repositoryId", "Artifact Repository ID");
- Field GROUP_ID = new Field( null, MAVEN_NAMESPACE, "groupId", "Group ID" );
+ Field GROUP_ID = new Field(null, MAVEN_NAMESPACE, "groupId", "Group ID");
- Field ARTIFACT_ID = new Field( null, MAVEN_NAMESPACE, "artifactId", "Artifact ID" );
+ Field ARTIFACT_ID = new Field(null, MAVEN_NAMESPACE, "artifactId", "Artifact ID");
- Field VERSION = new Field( null, MAVEN_NAMESPACE, "version", "Version" );
+ Field VERSION = new Field(null, MAVEN_NAMESPACE, "version", "Version");
- Field BASE_VERSION = new Field( null, MAVEN_NAMESPACE, "baseVersion", "Base Version" );
+ Field BASE_VERSION = new Field(null, MAVEN_NAMESPACE, "baseVersion", "Base Version");
- Field CLASSNAMES = new Field( null, MAVEN_NAMESPACE, "classNames", "Artifact Classes" );
+ Field CLASSNAMES = new Field(null, MAVEN_NAMESPACE, "classNames", "Artifact Classes");
// Artifact Packaging (extension for secondary artifacts!).
- Field PACKAGING = new Field( null, MAVEN_NAMESPACE, "packaging", "Packaging/Extension" );
+ Field PACKAGING = new Field(null, MAVEN_NAMESPACE, "packaging", "Packaging/Extension");
// Artifact extension
- Field EXTENSION = new Field( null, MAVEN_NAMESPACE, "extension", "Extension" );
+ Field EXTENSION = new Field(null, MAVEN_NAMESPACE, "extension", "Extension");
- Field CLASSIFIER = new Field( null, MAVEN_NAMESPACE, "classifier", "Classifier" );
+ Field CLASSIFIER = new Field(null, MAVEN_NAMESPACE, "classifier", "Classifier");
// NAME: Artifact Name (from POM)
- Field NAME = new Field( null, MAVEN_NAMESPACE, "name", "Name" );
+ Field NAME = new Field(null, MAVEN_NAMESPACE, "name", "Name");
// DESCRIPTION: Artifact Description (from POM)
- Field DESCRIPTION = new Field( null, MAVEN_NAMESPACE, "name", "Description" );
+ Field DESCRIPTION = new Field(null, MAVEN_NAMESPACE, "name", "Description");
// LAST_MODIFIED: Artifact Last Modified Timestamp (UTC millis)
- Field LAST_MODIFIED = new Field( null, MAVEN_NAMESPACE, "lastModified", "Last Modified Timestamp" );
+ Field LAST_MODIFIED = new Field(null, MAVEN_NAMESPACE, "lastModified", "Last Modified Timestamp");
// SHA1: Artifact SHA1 checksum.
- Field SHA1 = new Field( null, MAVEN_NAMESPACE, "sha1", "SHA1 checksum" );
+ Field SHA1 = new Field(null, MAVEN_NAMESPACE, "sha1", "SHA1 checksum");
// PLUGIN_PREFIX: MavenPlugin Artifact Plugin Prefix.
- Field PLUGIN_PREFIX = new Field( null, MAVEN_NAMESPACE, "pluginPrefix", "Plugin Prefix" );
+ Field PLUGIN_PREFIX = new Field(null, MAVEN_NAMESPACE, "pluginPrefix", "Plugin Prefix");
// PLUGIN_GOALS: MavenPlugin Artifact Plugin Goals (list of strings)
- Field PLUGIN_GOALS = new Field( null, MAVEN_NAMESPACE, "pluginGoals", "Plugin Goals" );
+ Field PLUGIN_GOALS = new Field(null, MAVEN_NAMESPACE, "pluginGoals", "Plugin Goals");
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlight.java b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlight.java
index fc412ff..2c8306a 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlight.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlight.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,29 +16,26 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.util.List;
-public class MatchHighlight
-{
+public class MatchHighlight {
private final Field field;
private final List<String> highlightedMatch;
- public MatchHighlight( Field field, List<String> highlightedMatch )
- {
+ public MatchHighlight(Field field, List<String> highlightedMatch) {
this.field = field;
this.highlightedMatch = highlightedMatch;
}
- public Field getField()
- {
+ public Field getField() {
return field;
}
- public List<String> getHighlightedMatch()
- {
+ public List<String> getHighlightedMatch() {
return highlightedMatch;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightMode.java b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightMode.java
index 8c582f7..8c89740 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightMode.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightMode.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,8 +16,8 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
-public enum MatchHighlightMode
-{
+public enum MatchHighlightMode {
HTML
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightRequest.java b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightRequest.java
index 0b27792..bfae5e8 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightRequest.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/MatchHighlightRequest.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,19 +16,18 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import org.apache.lucene.search.Query;
-public class MatchHighlightRequest
-{
+public class MatchHighlightRequest {
private final Field field;
private final Query query;
private final MatchHighlightMode highlightMode;
- public MatchHighlightRequest( Field field, Query query, MatchHighlightMode highlightMode )
- {
+ public MatchHighlightRequest(Field field, Query query, MatchHighlightMode highlightMode) {
this.field = field;
this.query = query;
@@ -38,18 +35,15 @@ public class MatchHighlightRequest
this.highlightMode = highlightMode;
}
- public Field getField()
- {
+ public Field getField() {
return field;
}
- public Query getQuery()
- {
+ public Query getQuery() {
return query;
}
- public MatchHighlightMode getHighlightMode()
- {
+ public MatchHighlightMode getHighlightMode() {
return highlightMode;
}
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/NEXUS.java b/indexer-core/src/main/java/org/apache/maven/index/NEXUS.java
index f03a99b..63ed42f 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/NEXUS.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/NEXUS.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,25 +16,25 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
/**
* Ontology of Nexus. This is still Maven2 specific. Ideally, Nexus Ontology should contain three things only: path,
* sha1 and last_modified. And Indexer should index _everything_, and Maven should be just "topping" extending these
* informations. This would enable us to search and easily detect maven metadata files too, or to support non-maven
* repository indexing, like P2 is.
- *
+ *
* @author cstamas
*/
-public interface NEXUS
-{
+public interface NEXUS {
String NEXUS_NAMESPACE = "urn:nexus#";
// UINFO: Artifact Unique Info (groupId, artifactId, version, classifier, extension (or packaging))
- Field UINFO = new Field( null, NEXUS_NAMESPACE, "uinfo", "Artifact Unique Info" );
+ Field UINFO = new Field(null, NEXUS_NAMESPACE, "uinfo", "Artifact Unique Info");
// INFO: Artifact Info (packaging, lastModified, size, sourcesExists, javadocExists, signatureExists)
- Field INFO = new Field( null, NEXUS_NAMESPACE, "info", "Artifact Info" );
+ Field INFO = new Field(null, NEXUS_NAMESPACE, "info", "Artifact Info");
// DELETED: Deleted field marker (will contain UINFO if document is deleted from index)
- Field DELETED = new Field( null, NEXUS_NAMESPACE, "del", "Deleted field marker" );
+ Field DELETED = new Field(null, NEXUS_NAMESPACE, "del", "Deleted field marker");
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java b/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
index a704490..93dbc6c 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/NexusIndexer.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * 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
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
import java.io.File;
import java.io.IOException;
@@ -38,10 +37,10 @@ import org.apache.maven.index.expr.SearchExpression;
* <p>
* The following code snippet shows how to register indexing context, which should be done once on the application
* startup and Nexus indexer instance should be reused after that.
- *
+ *
* <pre>
* NexusIndexer indexer;
- *
+ *
* IndexingContext context = indexer.addIndexingContext( indexId, // index id (usually the same as repository id)
* repositoryId, // repository id
* directory, // Lucene directory where index is stored
@@ -50,7 +49,7 @@ import org.apache.maven.index.expr.SearchExpression;
* indexUpdateUrl, // index update url or null if derived from repositoryUrl
* false, false );
* </pre>
- *
+ *
* An indexing context could be populated using one of {@link #scan(IndexingContext)},
* {@link #addArtifactToIndex(ArtifactContext, IndexingContext)} or
* {@link #deleteArtifactFromIndex(ArtifactContext, IndexingContext)} methods.
@@ -60,7 +59,7 @@ import org.apache.maven.index.expr.SearchExpression;
* {@link org.apache.maven.index.packer.IndexPacker} API.
* <p>
* Once index is populated you can perform search queries using field names declared in the {@link ArtifactInfo}:
- *
+ *
* <pre>
* // run search query
* BooleanQuery q = new BooleanQuery.Builder()
@@ -68,16 +67,16 @@ import org.apache.maven.index.expr.SearchExpression;
* .add(indexer.constructQuery(ArtifactInfo.ARTIFACT_ID, term), Occur.SHOULD)
* .add(new PrefixQuery(new Term(ArtifactInfo.SHA1, term)), Occur.SHOULD)
* .build();
- *
+ *
* FlatSearchRequest request = new FlatSearchRequest(q);
* FlatSearchResponse response = indexer.searchFlat(request);
* ...
* </pre>
- *
+ *
* Query could be also constructed using a convenience {@link NexusIndexer#constructQuery(Field, SearchExpression)}
* method that handles creation of the wildcard queries. Also see {@link DefaultQueryCreator} for more details on
* supported queries.
- *
+ *
* @see IndexingContext
* @see org.apache.maven.index.updater.IndexUpdater
* @see DefaultQueryCreator
@@ -87,18 +86,17 @@ import org.apache.maven.index.expr.SearchExpression;
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
-public interface NexusIndexer
-{
+public interface NexusIndexer {
/**
* Adds an indexing context to Nexus indexer.
- *
+ *
* @since 5.1.0
*/
- void addIndexingContext( IndexingContext context );
+ void addIndexingContext(IndexingContext context);
/**
* Adds an indexing context to Nexus indexer.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents.
* @param repository the location of the repository.
@@ -115,16 +113,21 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- IndexingContext addIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException, UnsupportedExistingLuceneIndexException;
+ IndexingContext addIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException, UnsupportedExistingLuceneIndexException;
/**
* Adds an indexing context to Nexus indexer. It "forces" this operation, thus no
* UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply
* stomp-over and rewrite (or add) the Nexus index descriptor.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents.
* @param repository the location of the repository.
@@ -138,14 +141,19 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- IndexingContext addIndexingContextForced( String id, String repositoryId, File repository, File indexDirectory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException;
+ IndexingContext addIndexingContextForced(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException;
/**
* Adds an indexing context to Nexus indexer.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents.
* @param repository the location of the repository.
@@ -162,16 +170,21 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- IndexingContext addIndexingContext( String id, String repositoryId, File repository, Directory directory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException, UnsupportedExistingLuceneIndexException;
+ IndexingContext addIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory directory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException, UnsupportedExistingLuceneIndexException;
/**
* Adds an indexing context to Nexus indexer. It "forces" this operation, thus no
* UnsupportedExistingLuceneIndexException is thrown. If it founds an existing lucene index, it will simply
* stomp-over and rewrite (or add) the Nexus index descriptor.
- *
+ *
* @param id the ID of the context.
* @param repositoryId the ID of the repository that this context represents.
* @param repository the location of the repository.
@@ -185,48 +198,70 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- IndexingContext addIndexingContextForced( String id, String repositoryId, File repository, Directory directory,
- String repositoryUrl, String indexUpdateUrl,
- List<? extends IndexCreator> indexers )
- throws IOException;
+ IndexingContext addIndexingContextForced(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory directory,
+ String repositoryUrl,
+ String indexUpdateUrl,
+ List<? extends IndexCreator> indexers)
+ throws IOException;
@Deprecated
- IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- boolean searchable, Collection<IndexingContext> contexts )
- throws IOException;
+ IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ Collection<IndexingContext> contexts)
+ throws IOException;
@Deprecated
- IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository, File indexDirectory,
- boolean searchable, ContextMemberProvider membersProvider )
- throws IOException;
+ IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ File indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException;
@Deprecated
- IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- Directory indexDirectory, boolean searchable,
- Collection<IndexingContext> contexts )
- throws IOException;
+ IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory indexDirectory,
+ boolean searchable,
+ Collection<IndexingContext> contexts)
+ throws IOException;
@Deprecated
- IndexingContext addMergedIndexingContext( String id, String repositoryId, File repository,
- Directory indexDirectory, boolean searchable,
- ContextMemberProvider membersProvider )
- throws IOException;
+ IndexingContext addMergedIndexingContext(
+ String id,
+ String repositoryId,
+ File repository,
+ Directory indexDirectory,
+ boolean searchable,
+ ContextMemberProvider membersProvider)
+ throws IOException;
/**
* Removes the indexing context from Nexus indexer, closes it and deletes (if specified) the index files.
- *
+ *
* @param context
* @param deleteFiles
* @throws IOException
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void removeIndexingContext( IndexingContext context, boolean deleteFiles )
- throws IOException;
+ void removeIndexingContext(IndexingContext context, boolean deleteFiles) throws IOException;
/**
* Returns the map of indexing contexts keyed by their ID.
- *
+ *
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
@@ -237,53 +272,49 @@ public interface NexusIndexer
// ----------------------------------------------------------------------------
/**
* Performs full scan (reindex) for the local repository belonging to supplied context.
- *
+ *
* @param context
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void scan( IndexingContext context )
- throws IOException;
+ void scan(IndexingContext context) throws IOException;
/**
* Performs full scan (reindex) for the local repository belonging to supplied context. ArtifactListener is used
* during that process.
- *
+ *
* @param context
* @param listener
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void scan( IndexingContext context, ArtifactScanningListener listener )
- throws IOException;
+ void scan(IndexingContext context, ArtifactScanningListener listener) throws IOException;
/**
* Performs optionally incremental scan (reindex/full reindex) for the local repository belonging to the supplied
* context.
- *
+ *
* @param context
* @param update if incremental reindex wanted, set true, otherwise false and full reindex will happen
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void scan( IndexingContext context, boolean update )
- throws IOException;
+ void scan(IndexingContext context, boolean update) throws IOException;
/**
* Performs optionally incremental scan (reindex) for the local repository, with listener.
- *
+ *
* @param context
* @param listener
* @param update if incremental reindex wanted, set true, otherwise false and full reindex will happen
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void scan( IndexingContext context, ArtifactScanningListener listener, boolean update )
- throws IOException;
+ void scan(IndexingContext context, ArtifactScanningListener listener, boolean update) throws IOException;
/**
* Performs optionally incremental scan (reindex) for the local repository.
- *
+ *
* @param context
* @param fromPath a path segment if you want "sub-path" reindexing (ie. reindex just a given subfolder of a
* repository, ot whole repository from root.
@@ -292,32 +323,27 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- void scan( IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update )
- throws IOException;
+ void scan(IndexingContext context, String fromPath, ArtifactScanningListener listener, boolean update)
+ throws IOException;
@Deprecated
- void artifactDiscovered( ArtifactContext ac, IndexingContext context )
- throws IOException;
+ void artifactDiscovered(ArtifactContext ac, IndexingContext context) throws IOException;
// ----------------------------------------------------------------------------
// Modifying
// ----------------------------------------------------------------------------
@Deprecated
- void addArtifactToIndex( ArtifactContext ac, IndexingContext context )
- throws IOException;
+ void addArtifactToIndex(ArtifactContext ac, IndexingContext context) throws IOException;
@Deprecated
- void addArtifactsToIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException;
+ void addArtifactsToIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException;
@Deprecated
- void deleteArtifactFromIndex( ArtifactContext ac, IndexingContext context )
- throws IOException;
+ void deleteArtifactFromIndex(ArtifactContext ac, IndexingContext context) throws IOException;
@Deprecated
- void deleteArtifactsFromIndex( Collection<ArtifactContext> acs, IndexingContext context )
- throws IOException;
+ void deleteArtifactsFromIndex(Collection<ArtifactContext> acs, IndexingContext context) throws IOException;
// ----------------------------------------------------------------------------
// Searching
@@ -325,39 +351,36 @@ public interface NexusIndexer
/**
* Searches according the request parameters.
- *
+ *
* @param request
* @return
* @throws IOException
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- FlatSearchResponse searchFlat( FlatSearchRequest request )
- throws IOException;
+ FlatSearchResponse searchFlat(FlatSearchRequest request) throws IOException;
/**
* Searches according to request parameters.
- *
+ *
* @param request
* @return
* @throws IOException
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- IteratorSearchResponse searchIterator( IteratorSearchRequest request )
- throws IOException;
+ IteratorSearchResponse searchIterator(IteratorSearchRequest request) throws IOException;
/**
* Searches according the request parameters.
- *
+ *
* @param request
* @return
* @throws IOException
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- GroupedSearchResponse searchGrouped( GroupedSearchRequest request )
- throws IOException;
+ GroupedSearchResponse searchGrouped(GroupedSearchRequest request) throws IOException;
// ----------------------------------------------------------------------------
// Query construction
@@ -366,7 +389,7 @@ public interface NexusIndexer
/**
* Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a
* field indexed, and WHAT query is needed to achieve that.
- *
+ *
* @param field
* @param query
* @param type
@@ -374,21 +397,19 @@ public interface NexusIndexer
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- Query constructQuery( Field field, String query, SearchType type )
- throws IllegalArgumentException;
+ Query constructQuery(Field field, String query, SearchType type) throws IllegalArgumentException;
/**
* Helper method to construct Lucene query for given field without need for knowledge (on caller side) HOW is a
* field indexed, and WHAT query is needed to achieve that.
- *
+ *
* @param field
* @param expression
* @return
* @deprecated Use {@link Indexer} instead.
*/
@Deprecated
- Query constructQuery( Field field, SearchExpression expression )
- throws IllegalArgumentException;
+ Query constructQuery(Field field, SearchExpression expression) throws IllegalArgumentException;
// ----------------------------------------------------------------------------
// Identification
@@ -396,23 +417,17 @@ public interface NexusIndexer
// ----------------------------------------------------------------------------
@Deprecated
- Collection<ArtifactInfo> identify( Field field, String query )
- throws IllegalArgumentException, IOException;
+ Collection<ArtifactInfo> identify(Field field, String query) throws IllegalArgumentException, IOException;
@Deprecated
- Collection<ArtifactInfo> identify( File artifact )
- throws IOException;
+ Collection<ArtifactInfo> identify(File artifact) throws IOException;
@Deprecated
- Collection<ArtifactInfo> identify( File artifact, Collection<IndexingContext> contexts )
- throws IOException;
+ Collection<ArtifactInfo> identify(File artifact, Collection<IndexingContext> contexts) throws IOException;
@Deprecated
- Collection<ArtifactInfo> identify( Query query )
- throws IOException;
+ Collection<ArtifactInfo> identify(Query query) throws IOException;
@Deprecated
- Collection<ArtifactInfo> identify( Query query, Collection<IndexingContext> contexts )
- throws IOException;
-
+ Collection<ArtifactInfo> identify(Query query, Collection<IndexingContext> contexts) throws IOException;
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/OSGI.java b/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
index 9dc681c..679b685 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/OSGI.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -18,6 +16,7 @@ package org.apache.maven.index;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.maven.index;
/**
* OSGI ontology.
@@ -25,19 +24,18 @@ package org.apache.maven.index;
* @author Olivier Lamy
* @since 4.1.1
*/
-public interface OSGI
-{
+public interface OSGI {
/**
* OSGI namespace
*/
String OSGI_NAMESPACE = "urn:osgi#";
- Field SYMBOLIC_NAME = new Field( null, OSGI_NAMESPACE, "symbolicName", "Bundle Symbolic Name" );
+ Field SYMBOLIC_NAME = new Field(null, OSGI_NAMESPACE, "symbolicName", "Bundle Symbolic Name");
- Field VERSION = new Field( null, OSGI_NAMESPACE, "version", "Bundle Version" );
+ Field VERSION = new Field(null, OSGI_NAMESPACE, "version", "Bundle Version");
- Field EXPORT_PACKAGE = new Field( null, OSGI_NAMESPACE, "exportPackage", "Bundle Export-Package" );
+ Field EXPORT_PACKAGE = new Field(null, OSGI_NAMESPACE, "exportPackage", "Bundle Export-Package");
/**
* Export-Service has been deprecated since OSGI R4 (2005), and was never used by resolvers. It is replaced by
@@ -46,19 +44,19 @@ public interface OSGI
* @deprecated
*/
@Deprecated
- Field EXPORT_SERVICE = new Field( null, OSGI_NAMESPACE, "exportService", "Bundle Export-Service" );
+ Field EXPORT_SERVICE = new Field(null, OSGI_NAMESPACE, "exportService", "Bundle Export-Service");
- Field DESCRIPTION = new Field( null, OSGI_NAMESPACE, "bundleDescription", "Bundle-Description" );
+ Field DESCRIPTION = new Field(null, OSGI_NAMESPACE, "bundleDescription", "Bundle-Description");
- Field NAME = new Field( null, OSGI_NAMESPACE, "bundleName", "Bundle-Name" );
+ Field NAME = new Field(null, OSGI_NAMESPACE, "bundleName", "Bundle-Name");
- Field LICENSE = new Field( null, OSGI_NAMESPACE, "bundleLicense", "Bundle-License" );
+ Field LICENSE = new Field(null, OSGI_NAMESPACE, "bundleLicense", "Bundle-License");
- Field DOCURL = new Field( null, OSGI_NAMESPACE, "bundleDocUrl", "Bundle-DocURL" );
+ Field DOCURL = new Field(null, OSGI_NAMESPACE, "bundleDocUrl", "Bundle-DocURL");
- Field IMPORT_PACKAGE = new Field( null, OSGI_NAMESPACE, "importPackage", "Import-Package" );
+ Field IMPORT_PACKAGE = new Field(null, OSGI_NAMESPACE, "importPackage", "Import-Package");
- Field REQUIRE_BUNDLE = new Field( null, OSGI_NAMESPACE, "requireBundle", "Require-Bundle" );
+ Field REQUIRE_BUNDLE = new Field(null, OSGI_NAMESPACE, "requireBundle", "Require-Bundle");
/**
* used by OSGI resolvers to determine which bundles / artifacts / environments, etc. can satisfy a given
@@ -67,8 +65,7 @@ public interface OSGI
*
* @since 5.1.2
*/
- Field PROVIDE_CAPABILITY =
- new Field( null, OSGI_NAMESPACE, "provideCapability", "Bundle Provide-Capability" );
+ Field PROVIDE_CAPABILITY = new Field(null, OSGI_NAMESPACE, "provideCapability", "Bundle Provide-Capability");
/**
* used by OSGI resolvers to indicate which services, features, etc are required by a given .
@@ -76,22 +73,21 @@ public interface OSGI
*
* @since 5.1.2
*/
- Field REQUIRE_CAPABILITY =
- new Field( null, OSGI_NAMESPACE, "requireCapability", "Bundle Require-Capability" );
+ Field REQUIRE_CAPABILITY = new Field(null, OSGI_NAMESPACE, "requireCapability", "Bundle Require-Capability");
/**
* used to hold the SHA256 checksum required as identifier for OSGI Content resources.
*
* @since 5.1.2
*/
- Field SHA256 = new Field( null, OSGI_NAMESPACE, "sha256", "SHA-256 checksum" );
+ Field SHA256 = new Field(null, OSGI_NAMESPACE, "sha256", "SHA-256 checksum");
/**
* used to hold the Fragment Host header for an OSGI Fragment bundle.
*
* @since 5.1.2
*/
- Field FRAGMENT_HOST = new Field( null, OSGI_NAMESPACE, "fragmentHost", "Bundle Fragment-Host" );
+ Field FRAGMENT_HOST = new Field(null, OSGI_NAMESPACE, "fragmentHost", "Bundle Fragment-Host");
/**
* used to hold the Fragment Host header for an OSGI Fragment bundle.
@@ -99,6 +95,5 @@ public interface OSGI
* @since 5.1.2
*/
Field BUNDLE_REQUIRED_EXECUTION_ENVIRONMENT =
- new Field( null, OSGI_NAMESPACE, "bree", "Bundle Required Execution Environment" );
-
+ new Field(null, OSGI_NAMESPACE, "bree", "Bundle Required Execution Environment");
}
diff --git a/indexer-core/src/main/java/org/apache/maven/index/OneLineFragmenter.java b/indexer-core/src/main/java/org/apache/maven/index/OneLineFragmenter.java
index d0c9af3..b886ecc 100644
--- a/indexer-core/src/main/java/org/apache/maven/index/OneLineFragmenter.java
+++ b/indexer-core/src/main/java/org/apache/maven/index/OneLineFragmenter.java
@@ -1,5 +1,3 @@
-package org.apache.maven.index;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -9,7 +7,7 @@ package org.apache.maven.index;
* "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
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
... 40366 lines suppressed ...