From c2bbd80b1b728fb6e7bff05d6fe2123c8b0f6122 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Thu, 6 Jun 2019 21:36:46 +0200 Subject: [PATCH] Adding type for repository group config --- .../RepositoryGroupConfiguration.java | 17 +++++++++++++++++ .../registry/ConfigurationRegistryReader.java | 1 + .../registry/ConfigurationRegistryWriter.java | 3 +++ .../archiva/indexer/merger/IndexMerger.java | 4 ++-- .../indexer/merger/IndexMergerException.java | 0 .../indexer/merger/IndexMergerRequest.java | 0 .../merger}/MergedRemoteIndexesScheduler.java | 5 +++-- .../indexer/merger/TemporaryGroupIndex.java | 0 .../DefaultMergedRemoteIndexesScheduler.java | 19 +++++++++++-------- .../merger/MergedRemoteIndexesTask.java | 4 ++-- .../MergedRemoteIndexesTaskRequest.java | 0 .../merger/MergedRemoteIndexesTaskResult.java | 10 +++++----- .../merger/TemporaryGroupIndexCleaner.java | 0 .../{merger => }/DefaultIndexMerger.java | 6 ++++-- 14 files changed, 48 insertions(+), 21 deletions(-) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-api}/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java (90%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-api}/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java (100%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-api}/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java (100%) rename archiva-modules/{archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler => archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger}/MergedRemoteIndexesScheduler.java (90%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-api}/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java (100%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-layer}/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java (79%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-layer}/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java (95%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-layer}/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskRequest.java (100%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-layer}/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java (77%) rename archiva-modules/{archiva-maven/archiva-maven-indexer => archiva-base/archiva-repository-layer}/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java (100%) rename archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/{merger => }/DefaultIndexMerger.java (95%) diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/RepositoryGroupConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/RepositoryGroupConfiguration.java index d2cc9cb27..db3498be3 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/RepositoryGroupConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/RepositoryGroupConfiguration.java @@ -47,6 +47,15 @@ public class RepositoryGroupConfiguration */ private String name; + /** + * + * The repository type. Currently only MAVEN type + * is known. + * + */ + private String type = "MAVEN"; + + /** * The path of the merged index. */ @@ -211,4 +220,12 @@ public class RepositoryGroupConfiguration public void setName(String name) { this.name = name; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryReader.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryReader.java index 7c0535e8b..8c0ff5d56 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryReader.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryReader.java @@ -731,6 +731,7 @@ public class ConfigurationRegistryReader { value.setId(id); value.setName(registry.getString(prefix + "name")); + value.setType(registry.getString(prefix + "type")); //String mergedIndexPath = registry.getString( prefix + "mergedIndexPath", value.getMergedIndexPath() ); diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryWriter.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryWriter.java index 915cd8b8e..786b027a9 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryWriter.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryWriter.java @@ -422,6 +422,9 @@ public class ConfigurationRegistryWriter { if (value.getName() != null) { registry.setString(prefix + "name", value.getName()); } + if (value.getType() != null) { + registry.setString(prefix + "type", value.getType()); + } if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer") ) { String mergedIndexPath = "mergedIndexPath"; diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java similarity index 90% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java rename to archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java index 756819e4f..79c7466cc 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMerger.java @@ -18,7 +18,7 @@ package org.apache.archiva.indexer.merger; * under the License. */ -import org.apache.maven.index.context.IndexingContext; +import org.apache.archiva.indexer.ArchivaIndexingContext; import java.util.Collection; @@ -33,7 +33,7 @@ public interface IndexMerger * @return a temporary directory with a merge index (directory marked deleteOnExit) * @throws IndexMergerException */ - IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest ) + ArchivaIndexingContext buildMergedIndex(IndexMergerRequest indexMergerRequest ) throws IndexMergerException; void cleanTemporaryGroupIndex( TemporaryGroupIndex temporaryGroupIndex ); diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java rename to archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerException.java diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java rename to archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/IndexMergerRequest.java diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java similarity index 90% rename from archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java rename to archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java index cd9520cba..9ba97e701 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-api/src/main/java/org/apache/archiva/scheduler/MergedRemoteIndexesScheduler.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesScheduler.java @@ -19,7 +19,8 @@ package org.apache.archiva.scheduler; * under the License. */ -import org.apache.archiva.admin.model.beans.RepositoryGroup; + +import org.apache.archiva.repository.RepositoryGroup; import java.nio.file.Path; @@ -35,7 +36,7 @@ public interface MergedRemoteIndexesScheduler * remote indexes * @param repositoryGroup */ - void schedule( RepositoryGroup repositoryGroup, Path directory ); + void schedule(RepositoryGroup repositoryGroup, Path directory ); void unschedule( RepositoryGroup repositoryGroup ); diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java rename to archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndex.java diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java similarity index 79% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java rename to archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java index f0fbcbd31..0e918a58c 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/DefaultMergedRemoteIndexesScheduler.java @@ -19,7 +19,8 @@ package org.apache.archiva.indexer.merger; * under the License. */ -import org.apache.archiva.admin.model.beans.RepositoryGroup; +import org.apache.archiva.repository.ManagedRepository; +import org.apache.archiva.repository.RepositoryGroup; import org.apache.archiva.scheduler.MergedRemoteIndexesScheduler; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -35,6 +36,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; +import java.util.stream.Collectors; /** * @author Olivier Lamy @@ -57,25 +59,26 @@ public class DefaultMergedRemoteIndexesScheduler private Map scheduledFutureMap = new ConcurrentHashMap<>(); @Override - public void schedule( RepositoryGroup repositoryGroup, Path directory ) + public void schedule(RepositoryGroup repositoryGroup, Path directory ) { - if ( StringUtils.isEmpty( repositoryGroup.getCronExpression() ) ) + if ( StringUtils.isEmpty( repositoryGroup.getSchedulingDefinition() ) ) { return; } - CronTrigger cronTrigger = new CronTrigger( repositoryGroup.getCronExpression() ); + CronTrigger cronTrigger = new CronTrigger( repositoryGroup.getSchedulingDefinition() ); - List repositories = repositoryGroup.getRepositories(); + List repositories = repositoryGroup.getRepositories(); IndexMergerRequest indexMergerRequest = - new IndexMergerRequest( repositories, true, repositoryGroup.getId(), repositoryGroup.getMergedIndexPath(), - repositoryGroup.getMergedIndexTtl() ).mergedIndexDirectory( directory ); + new IndexMergerRequest( repositories.stream().map(r -> r.getId()).collect(Collectors.toList()), true, repositoryGroup.getId(), + repositoryGroup.getMergedIndexPath().getFilePath().toString(), + repositoryGroup.getMergedIndexTTL() ).mergedIndexDirectory( directory ); MergedRemoteIndexesTaskRequest taskRequest = new MergedRemoteIndexesTaskRequest( indexMergerRequest, indexMerger ); logger.info( "schedule merge remote index for group {} with cron {}", repositoryGroup.getId(), - repositoryGroup.getCronExpression() ); + repositoryGroup.getSchedulingDefinition() ); ScheduledFuture scheduledFuture = taskScheduler.schedule( new MergedRemoteIndexesTask( taskRequest ), cronTrigger ); diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java similarity index 95% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java rename to archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java index c67d31286..42896e1f9 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTask.java @@ -19,7 +19,7 @@ package org.apache.archiva.indexer.merger; * under the License. */ -import org.apache.maven.index.context.IndexingContext; +import org.apache.archiva.indexer.ArchivaIndexingContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -58,7 +58,7 @@ public class MergedRemoteIndexesTask { IndexMerger indexMerger = mergedRemoteIndexesTaskRequest.getIndexMerger(); - IndexingContext indexingContext = + ArchivaIndexingContext indexingContext = indexMerger.buildMergedIndex( mergedRemoteIndexesTaskRequest.getIndexMergerRequest() ); return new MergedRemoteIndexesTaskResult( indexingContext ); diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskRequest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskRequest.java similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskRequest.java rename to archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskRequest.java diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java similarity index 77% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java rename to archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java index b75a29219..b7def7000 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/MergedRemoteIndexesTaskResult.java @@ -19,7 +19,7 @@ package org.apache.archiva.indexer.merger; * under the License. */ -import org.apache.maven.index.context.IndexingContext; +import org.apache.archiva.indexer.ArchivaIndexingContext; /** * @author Olivier Lamy @@ -27,19 +27,19 @@ import org.apache.maven.index.context.IndexingContext; */ public class MergedRemoteIndexesTaskResult { - private IndexingContext indexingContext; + private ArchivaIndexingContext indexingContext; - public MergedRemoteIndexesTaskResult( IndexingContext indexingContext ) + public MergedRemoteIndexesTaskResult( ArchivaIndexingContext indexingContext ) { this.indexingContext = indexingContext; } - public IndexingContext getIndexingContext() + public ArchivaIndexingContext getIndexingContext() { return indexingContext; } - public void setIndexingContext( IndexingContext indexingContext ) + public void setIndexingContext( ArchivaIndexingContext indexingContext ) { this.indexingContext = indexingContext; } diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java similarity index 100% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java rename to archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/indexer/merger/TemporaryGroupIndexCleaner.java diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/merger/DefaultIndexMerger.java b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/DefaultIndexMerger.java similarity index 95% rename from archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/merger/DefaultIndexMerger.java rename to archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/DefaultIndexMerger.java index 1f4648025..0843f230b 100644 --- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/merger/DefaultIndexMerger.java +++ b/archiva-modules/archiva-maven/archiva-maven-indexer/src/main/java/org/apache/archiva/indexer/maven/DefaultIndexMerger.java @@ -19,7 +19,9 @@ package org.apache.archiva.indexer.maven.merger; */ import org.apache.archiva.common.utils.FileUtils; +import org.apache.archiva.indexer.ArchivaIndexingContext; import org.apache.archiva.indexer.UnsupportedBaseContextException; +import org.apache.archiva.indexer.maven.MavenIndexContext; import org.apache.archiva.indexer.merger.IndexMerger; import org.apache.archiva.indexer.merger.IndexMergerException; import org.apache.archiva.indexer.merger.IndexMergerRequest; @@ -86,7 +88,7 @@ public class DefaultIndexMerger } @Override - public IndexingContext buildMergedIndex( IndexMergerRequest indexMergerRequest ) + public ArchivaIndexingContext buildMergedIndex(IndexMergerRequest indexMergerRequest ) throws IndexMergerException { String groupId = indexMergerRequest.getGroupId(); @@ -146,7 +148,7 @@ public class DefaultIndexMerger stopWatch.stop(); log.info( "merged index for repos {} in {} s", indexMergerRequest.getRepositoriesIds(), stopWatch.getTime() ); - return mergedCtx; + return new MavenIndexContext(repositoryRegistry.getRepositoryGroup(groupId), mergedCtx); } catch ( IOException e) { -- 2.39.5