From 4c5e00e833f5ddafb68ccd44b02db7df00c5eeba Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 19 May 2019 17:35:34 +0200 Subject: [PATCH] Adding repository group --- .../repository/EditableRepositoryGroup.java | 41 ++++ .../archiva/repository/RepositoryGroup.java | 78 +++++++ .../repository/RepositoryProvider.java | 42 ++++ .../archiva-repository-layer/pom.xml | 4 + .../repository/AbstractRepositoryGroup.java | 220 ++++++++++++++++++ .../archiva-maven-repository/pom.xml | 1 + .../maven2/MavenRepositoryGroup.java | 81 +++++++ .../maven2/MavenRepositoryProvider.java | 84 ++++--- 8 files changed, 513 insertions(+), 38 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepositoryGroup.java create mode 100644 archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryGroup.java create mode 100644 archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java create mode 100644 archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepositoryGroup.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepositoryGroup.java new file mode 100644 index 000000000..dff3dc85d --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/EditableRepositoryGroup.java @@ -0,0 +1,41 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.List; + +public interface EditableRepositoryGroup extends EditableRepository,RepositoryGroup { + + void clearRepositories(); + + void setRepositories(List repositories); + + void addRepository(ManagedRepository repository); + + void addRepository(int index, ManagedRepository repository); + + boolean removeRepository(ManagedRepository repository); + + ManagedRepository removeRepository(String repoId); + + void setMergedIndexPath(String path); + + void setMergedIndexTTL(int timeInSeconds); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryGroup.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryGroup.java new file mode 100644 index 000000000..93b368c1d --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryGroup.java @@ -0,0 +1,78 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.repository.content.RepositoryStorage; +import org.apache.archiva.repository.content.StorageAsset; + +import java.util.List; + +/** + * Interface for repository groups. + * + * Repository groups are a combined view over a list of repositories. + * All repositories of this group must be of the same type. + * + * Repository groups are read only. You cannot store artifacts into a repository group. + * + * This interface extends {@link RepositoryStorage} to provide access to the merged + * index data files and other metadata. + * + */ +public interface RepositoryGroup extends Repository, RepositoryStorage { + + /** + * Returns the list of repositories. The order of the elements represents + * the order of getting artifacts (first one wins). + * + * + * @return + */ + List getRepositories(); + + /** + * Returns true, if the given repository is part of this group. + * + * @param repository The repository to check. + * @return True, if it is part, otherwise false. + */ + boolean contains(ManagedRepository repository); + + /** + * Returns true, if the repository with the given id is part of this group. + * + * @param id The repository id to check + * @return True, if it is part, otherwise false + */ + boolean contains(String id); + + /** + * Returns the path to the merged index + * @return + */ + StorageAsset getMergedIndexPath(); + + /** + * Returns the time to live in seconds for the merged index. + * + * @return + */ + int getMergedIndexTTL(); +} diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java index 4492b01cb..abbb8c46c 100644 --- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java +++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java @@ -21,6 +21,7 @@ package org.apache.archiva.repository; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; +import org.apache.archiva.configuration.RepositoryGroupConfiguration; import java.util.Set; @@ -69,6 +70,17 @@ public interface RepositoryProvider extends RepositoryEventListener */ EditableRemoteRepository createRemoteInstance(String id, String name); + /** + * Creates a editable repository group. . The provider must not check the uniqueness of the + * id parameter and must not track the already created instances. Each call to this method will create + * a new instance. + * + * @param id the repository identifier + * @param name the repository name + * @return A new instance of the repository group implementation + */ + EditableRepositoryGroup createRepositoryGroup(String id, String name); + /** * Creates a new managed repository instance from the given configuration. All attributes are filled from the * provided configuration object. @@ -119,6 +131,27 @@ public interface RepositoryProvider extends RepositoryEventListener */ void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration configuration) throws RepositoryException; + + /** + * Creates a new repository group instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param configuration the repository group configuration + * @return a new created repository group instance + * @throws RepositoryException if some of the configuration values are not valid + */ + RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException; + + /** + * Updates the given remote repository instance from the given configuration. All attributes are filled from the + * provided configuration object. + * + * @param repositoryGroup the repository group instance that should be updated + * @param configuration the repository group configuration that contains the group data + * @throws RepositoryException if some of the configuration values are not valid + */ + void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException; + /** * Returns a configuration object from the given remote repository instance. * @@ -136,4 +169,13 @@ public interface RepositoryProvider extends RepositoryEventListener * @throws RepositoryException if the data cannot be converted */ ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException; + + /** + * Returns a configuration object from the given repository group instance. + * + * @param repositoryGroup the repository group + * @return the repository group configuration with all the data that is stored in the repository instance + * @throws RepositoryException if the data cannot be converted + */ + RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException; } diff --git a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml index 2606b82f6..7d2c1a667 100644 --- a/archiva-modules/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-modules/archiva-base/archiva-repository-layer/pom.xml @@ -61,6 +61,10 @@ org.apache.archiva.maven archiva-maven-metadata + + org.apache.archiva + archiva-filelock + org.springframework spring-context diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java new file mode 100644 index 000000000..f212b7636 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java @@ -0,0 +1,220 @@ +package org.apache.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.repository.content.RepositoryStorage; +import org.apache.archiva.repository.content.StorageAsset; +import org.apache.commons.collections4.map.ListOrderedMap; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Path; +import java.util.List; +import java.util.Locale; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.function.Consumer; + +/** + * Abstract repository group implementation. + * + */ +public class AbstractRepositoryGroup extends AbstractRepository implements EditableRepositoryGroup { + + private ListOrderedMap repositories = new ListOrderedMap<>(); + + private String mergedIndexPath; + + private int mergedIndexTTL; + + private final ReadWriteLock rwl = new ReentrantReadWriteLock(); + + private RepositoryStorage storage; + + private RepositoryCapabilities capabilities; + + public AbstractRepositoryGroup(RepositoryType type, String id, String name, Path repositoryBase) { + super(type, id, name, repositoryBase); + } + + public AbstractRepositoryGroup(Locale primaryLocale, RepositoryType type, String id, String name, Path repositoryBase) { + super(primaryLocale, type, id, name, repositoryBase); + } + + @Override + public boolean hasIndex() { + return true; + } + + @Override + public RepositoryCapabilities getCapabilities() { + return capabilities; + } + + + @Override + public void clearRepositories() { + rwl.writeLock().lock(); + try { + repositories.clear(); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public void setRepositories(List repositories) { + rwl.writeLock().lock(); + try { + repositories.clear(); + repositories.addAll(repositories); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public void addRepository(ManagedRepository repository) { + rwl.writeLock().lock(); + try { + repositories.put(repository.getId(), repository); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public void addRepository(int index, ManagedRepository repository) { + rwl.writeLock().lock(); + try { + repositories.put(index, repository.getId(), repository); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public boolean removeRepository(ManagedRepository repository) { + rwl.writeLock().lock(); + try { + return repositories.remove(repository.getId(), repository); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public ManagedRepository removeRepository(String repoId) { + rwl.writeLock().lock(); + try { + return repositories.remove(repoId); + } finally { + rwl.writeLock().unlock(); + } + } + + @Override + public void setMergedIndexPath(String path) { + this.mergedIndexPath = path; + } + + @Override + public void setMergedIndexTTL(int timeInSeconds) { + this.mergedIndexTTL = timeInSeconds; + } + + @Override + public List getRepositories() { + rwl.readLock().lock(); + try { + return repositories.valueList(); + } finally { + rwl.readLock().unlock(); + } + } + + @Override + public boolean contains(ManagedRepository repository) { + rwl.readLock().lock(); + try { + return repositories.containsValue(repository); + } finally { + rwl.readLock().unlock(); + } + } + + @Override + public boolean contains(String id) { + rwl.readLock().lock(); + try { + return repositories.containsKey(id); + } finally { + rwl.readLock().unlock(); + } + } + + @Override + public StorageAsset getMergedIndexPath() { + return storage.getAsset(mergedIndexPath); + } + + @Override + public int getMergedIndexTTL() { + return mergedIndexTTL; + } + + @Override + public StorageAsset getAsset(String path) { + return storage.getAsset(path); + } + + @Override + public void consumeData(StorageAsset asset, Consumer consumerFunction, boolean readLock) throws IOException { + storage.consumeData(asset, consumerFunction, readLock); + } + + @Override + public StorageAsset addAsset(String path, boolean container) { + return storage.addAsset(path, container); + } + + @Override + public void removeAsset(StorageAsset asset) throws IOException { + storage.removeAsset(asset); + } + + @Override + public StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException { + return storage.moveAsset(origin, destination); + } + + @Override + public StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException { + return storage.copyAsset(origin, destination); + } + + protected void setStorage(RepositoryStorage storage) { + this.storage = storage; + } + + protected void setCapabilities(RepositoryCapabilities capabilities) { + this.capabilities = capabilities; + } +} diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml index e9cd8d052..627bd5be7 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml +++ b/archiva-modules/archiva-maven/archiva-maven-repository/pom.xml @@ -56,6 +56,7 @@ org.apache.archiva archiva-model + org.apache.archiva.maven archiva-maven-proxy diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java new file mode 100644 index 000000000..e9845ba99 --- /dev/null +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java @@ -0,0 +1,81 @@ +package org.apache.archiva.repository.maven2; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.common.filelock.FileLockManager; +import org.apache.archiva.repository.*; +import org.apache.archiva.repository.content.FilesystemStorage; +import org.apache.archiva.repository.features.ArtifactCleanupFeature; +import org.apache.archiva.repository.features.IndexCreationFeature; +import org.apache.archiva.repository.features.StagingRepositoryFeature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.Locale; + +public class MavenRepositoryGroup extends AbstractRepositoryGroup implements EditableRepositoryGroup { + + private static final RepositoryCapabilities CAPABILITIES = new StandardCapabilities( + new ReleaseScheme[] { ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT }, + new String[] { MavenManagedRepository.DEFAULT_LAYOUT, MavenManagedRepository.LEGACY_LAYOUT}, + new String[] {}, + new String[] {ArtifactCleanupFeature.class.getName(), IndexCreationFeature.class.getName(), + StagingRepositoryFeature.class.getName()}, + true, + true, + true, + true, + false + ); + + private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class); + + private FileLockManager lockManager; + private FilesystemStorage fsStorage; + + public MavenRepositoryGroup(String id, String name, Path repositoryBase, FileLockManager lockManager) { + super(RepositoryType.MAVEN, id, name, repositoryBase); + this.lockManager = lockManager; + init(); + } + + public MavenRepositoryGroup(Locale primaryLocale, String id, String name, Path repositoryBase, FileLockManager lockManager) { + super(primaryLocale, RepositoryType.MAVEN, id, name, repositoryBase); + this.lockManager = lockManager; + init(); + } + + private Path getRepositoryPath() { + return getRepositoryBase().resolve(getId()); + } + + private void init() { + setCapabilities(CAPABILITIES); + try { + fsStorage = new FilesystemStorage(getRepositoryPath(), lockManager); + } catch (IOException e) { + log.error("IOException while initializing repository group with path {}",getRepositoryBase()); + throw new RuntimeException("Fatal error while accessing repository path "+ getRepositoryBase(), e); + } + setStorage(fsStorage); + } +} diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java index 79a9fb9e6..280cb36de 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java @@ -19,24 +19,9 @@ package org.apache.archiva.repository.maven2; * under the License. */ -import org.apache.archiva.configuration.AbstractRepositoryConfiguration; -import org.apache.archiva.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.ManagedRepositoryConfiguration; -import org.apache.archiva.configuration.RemoteRepositoryConfiguration; -import org.apache.archiva.repository.BasicManagedRepository; -import org.apache.archiva.repository.EditableManagedRepository; -import org.apache.archiva.repository.EditableRemoteRepository; -import org.apache.archiva.repository.EditableRepository; -import org.apache.archiva.repository.ManagedRepository; -import org.apache.archiva.repository.PasswordCredentials; -import org.apache.archiva.repository.ReleaseScheme; -import org.apache.archiva.repository.RemoteRepository; -import org.apache.archiva.repository.RepositoryCredentials; -import org.apache.archiva.repository.RepositoryEvent; -import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.RepositoryProvider; -import org.apache.archiva.repository.RepositoryType; -import org.apache.archiva.repository.UnsupportedURIException; +import org.apache.archiva.common.filelock.FileLockManager; +import org.apache.archiva.configuration.*; +import org.apache.archiva.repository.*; import org.apache.archiva.repository.features.ArtifactCleanupFeature; import org.apache.archiva.repository.features.IndexCreationFeature; import org.apache.archiva.repository.features.RemoteIndexFeature; @@ -57,6 +42,7 @@ import java.time.Duration; import java.time.Period; import java.time.temporal.ChronoUnit; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -71,6 +57,12 @@ public class MavenRepositoryProvider implements RepositoryProvider { @Inject private ArchivaConfiguration archivaConfiguration; + @Inject + private RepositoryRegistry repositoryRegistry; + + @Inject + private FileLockManager fileLockManager; + private static final Logger log = LoggerFactory.getLogger(MavenRepositoryProvider.class); static final Set TYPES = new HashSet<>(); @@ -94,6 +86,11 @@ public class MavenRepositoryProvider implements RepositoryProvider { return new MavenRemoteRepository(id, name, archivaConfiguration.getRemoteRepositoryBaseDir()); } + @Override + public EditableRepositoryGroup createRepositoryGroup(String id, String name) { + return new MavenRepositoryGroup(id, name, archivaConfiguration.getRepositoryBaseDir(), fileLockManager); + } + private URI getURIFromString(String uriStr) throws RepositoryException { URI uri; try { @@ -165,26 +162,6 @@ public class MavenRepositoryProvider implements RepositoryProvider { indexCreationFeature.setSkipPackedIndexCreation(cfg.isSkipPackedIndexCreation()); indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir())); indexCreationFeature.setPackedIndexPath(getURIFromString(cfg.getPackedIndexDir())); - /* -> Should be created by MavenIndexProvider - - Path indexPath; - if (indexCreationFeature.getIndexPath().getScheme() == null) { - indexPath = Paths.get(indexCreationFeature.getIndexPath().getPath()); - } else { - indexPath = Paths.get(indexCreationFeature.getIndexPath()); - } - Path absoluteIndexPath; - if (indexPath.isAbsolute()) { - absoluteIndexPath = indexPath; - } else { - absoluteIndexPath = PathUtil.getPathFromUri(repo.getLocation()).resolve(indexCreationFeature.getIndexPath().getPath()); - } - try { - Files.createDirectories(absoluteIndexPath); - } catch (IOException e) { - log.error("Could not create index directory {}", absoluteIndexPath); - throw new RepositoryException("Could not create index directory " + absoluteIndexPath); - }*/ ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get(); @@ -268,6 +245,22 @@ public class MavenRepositoryProvider implements RepositoryProvider { log.debug("Updated remote instance {}", repo); } + @Override + public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException { + Path repositoryGroupBase = getArchivaConfiguration().getRepositoryGroupBaseDir(); + return new MavenRepositoryGroup(configuration.getId(), configuration.getId(), + repositoryGroupBase, fileLockManager); + } + + @Override + public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException { + repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), configuration.getName()); + repositoryGroup.setRepositories(configuration.getRepositories().stream().map(rid -> repositoryRegistry.getManagedRepository(rid)).collect(Collectors.toList())); + repositoryGroup.setMergedIndexPath(configuration.getMergedIndexPath()); + repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl()); + repositoryGroup.setSchedulingDefinition(configuration.getCronExpression()); + } + @Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { @@ -353,6 +346,21 @@ public class MavenRepositoryProvider implements RepositoryProvider { } + @Override + public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException { + if (repositoryGroup.getType() != RepositoryType.MAVEN) { + throw new RepositoryException("The given repository group is not of MAVEN type"); + } + RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration(); + cfg.setId(repositoryGroup.getId()); + cfg.setName(repositoryGroup.getName()); + cfg.setMergedIndexPath(repositoryGroup.getMergedIndexPath().getPath()); + cfg.setMergedIndexTtl(repositoryGroup.getMergedIndexTTL()); + cfg.setRepositories(repositoryGroup.getRepositories().stream().map(r -> r.getId()).collect(Collectors.toList())); + cfg.setCronExpression(repositoryGroup.getSchedulingDefinition()); + return cfg; + } + private ManagedRepositoryConfiguration getStageRepoConfig(ManagedRepositoryConfiguration repository) { ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration(); stagingRepository.setId(repository.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); -- 2.39.5