From: Martin Stockhammer Date: Sun, 19 May 2019 15:31:58 +0000 (+0200) Subject: Adding new group properties to configuration X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7d37fdc65b32cb22664978e78a3b4e7b80aeb566;p=archiva.git Adding new group properties to configuration --- diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java index e7b2b6edb..0f6ff82e2 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java @@ -113,6 +113,12 @@ public interface ArchivaConfiguration */ public Path getRemoteRepositoryBaseDir(); + /** + * Returns the base directory for repository group files. + * @return + */ + public Path getRepositoryGroupBaseDir(); + /** * Returns the data directory where repositories and metadata reside * @return diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaRuntimeConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaRuntimeConfiguration.java index ae9b9bb90..b05686092 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaRuntimeConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaRuntimeConfiguration.java @@ -67,6 +67,12 @@ public class ArchivaRuntimeConfiguration */ private String remoteRepositoryBaseDirectory; + /** + * The base directory for local storage of repository group files. + * If not set, it's ${dataDirectory}/groups + */ + private String repositoryGroupBaseDirectory; + /** * The default language used for setting internationalized * strings. @@ -156,6 +162,17 @@ public class ArchivaRuntimeConfiguration return this.repositoryBaseDirectory; } //-- String getRepositoryBaseDirectory() + /** + * Get the base directory for local storage of repository group data. + * If not set it's ${dataDirectory}/groups + * + * @return The path to the directory. Either a absolute path, or a path + * relative to ${dataDirectory} + */ + public String getRepositoryGroupBaseDirectory() { + return this.repositoryGroupBaseDirectory; + } + /** * Get the url failure cache configuration. * @@ -232,6 +249,11 @@ public class ArchivaRuntimeConfiguration this.repositoryBaseDirectory = repositoryBaseDirectory; } //-- void setRepositoryBaseDirectory( String ) + + public void setRepositoryGroupBaseDirectory(String repositoryGroupBaseDirectory) { + this.repositoryGroupBaseDirectory = repositoryGroupBaseDirectory; + } + /** * Set the url failure cache configuration. * diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index 8839db6c5..13e8a2898 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -178,6 +178,7 @@ public class DefaultArchivaConfiguration private volatile Path dataDirectory; private volatile Path repositoryBaseDirectory; private volatile Path remoteRepositoryBaseDirectory; + private volatile Path repositoryGroupBaseDirectory; @PostConstruct private void init() { @@ -254,6 +255,7 @@ public class DefaultArchivaConfiguration dataDirectory.resolve(tmpRepoBaseDir); } } + String remoteRepoBaseDir = config.getArchivaRuntimeConfiguration().getRemoteRepositoryBaseDirectory(); if (StringUtils.isEmpty(remoteRepoBaseDir)) { remoteRepositoryBaseDirectory = dataDirectory.resolve("remotes"); @@ -266,6 +268,18 @@ public class DefaultArchivaConfiguration } } + String repositoryGroupBaseDir = config.getArchivaRuntimeConfiguration().getRepositoryGroupBaseDirectory(); + if (StringUtils.isEmpty(repositoryGroupBaseDir)) { + repositoryGroupBaseDirectory = dataDirectory.resolve("groups"); + } else { + Path tmpGroupDir = Paths.get(repositoryGroupBaseDir); + if (tmpGroupDir.isAbsolute()) { + repositoryGroupBaseDirectory = tmpGroupDir; + } else { + dataDirectory.resolve(tmpGroupDir); + } + } + config.getRepositoryGroups(); config.getRepositoryGroupsAsMap(); @@ -850,6 +864,14 @@ public class DefaultArchivaConfiguration return remoteRepositoryBaseDirectory; } + @Override + public Path getRepositoryGroupBaseDir() { + if (repositoryGroupBaseDirectory == null) { + getConfiguration(); + } + return repositoryGroupBaseDirectory; + } + @Override public Path getDataDirectory() { if (dataDirectory == null) { 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 826fc5063..d2cc9cb27 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 @@ -19,6 +19,10 @@ package org.apache.archiva.configuration; * under the License. */ +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + /** * Class RepositoryGroupConfiguration. * @@ -26,7 +30,7 @@ package org.apache.archiva.configuration; */ @SuppressWarnings( "all" ) public class RepositoryGroupConfiguration - implements java.io.Serializable + implements Serializable { //--------------------------/ @@ -38,6 +42,11 @@ public class RepositoryGroupConfiguration */ private String id; + /** + * The name of the repository group + */ + private String name; + /** * The path of the merged index. */ @@ -59,7 +68,7 @@ public class RepositoryGroupConfiguration /** * Field repositories. */ - private java.util.List repositories; + private List repositories; //-----------/ @@ -123,11 +132,11 @@ public class RepositoryGroupConfiguration * * @return List */ - public java.util.List getRepositories() + public List getRepositories() { if ( this.repositories == null ) { - this.repositories = new java.util.ArrayList(); + this.repositories = new ArrayList(); } return this.repositories; @@ -190,9 +199,16 @@ public class RepositoryGroupConfiguration * * @param repositories */ - public void setRepositories( java.util.List repositories ) + public void setRepositories( List repositories ) { this.repositories = repositories; } //-- void setRepositories( java.util.List ) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } 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 d8783453e..7c0535e8b 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 @@ -729,6 +729,9 @@ public class ConfigurationRegistryReader { } value.setId(id); + + value.setName(registry.getString(prefix + "name")); + //String mergedIndexPath = registry.getString( prefix + "mergedIndexPath", value.getMergedIndexPath() ); List mergedIndexPathList = registry.getList(prefix + "mergedIndexPath"); @@ -1392,6 +1395,22 @@ public class ConfigurationRegistryReader { value.setRemoteRepositoryBaseDirectory(remoteRepositoryBaseDirectory); //String defaultLanguage = registry.getString( prefix + "defaultLanguage", value.getDefaultLanguage() ); + + List repositoryGroupBaseDirectoryList = registry.getList(prefix + "repositoryGroupBaseDirectory"); + String repositoryGroupBaseDirectory = value.getRepositoryGroupBaseDirectory(); + if (repositoryGroupBaseDirectoryList != null && !repositoryGroupBaseDirectoryList.isEmpty()) { + StringBuilder sb = new StringBuilder(); + for (int i = 0, size = repositoryGroupBaseDirectoryList.size(); i < size; i++) { + sb.append(repositoryGroupBaseDirectoryList.get(i)); + if (i < size - 1) { + sb.append(','); + } + } + repositoryGroupBaseDirectory = sb.toString(); + } + + value.setRepositoryGroupBaseDirectory(repositoryGroupBaseDirectory); + List defaultLanguageList = registry.getList(prefix + "defaultLanguage"); String defaultLanguage = value.getDefaultLanguage(); if (defaultLanguageList != null && !defaultLanguageList.isEmpty()) { 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 31ffc6b9d..915cd8b8e 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 @@ -419,6 +419,9 @@ public class ConfigurationRegistryWriter { String id = "id"; registry.setString(prefix + id, value.getId()); } + if (value.getName() != null) { + registry.setString(prefix + "name", value.getName()); + } if (value.getMergedIndexPath() != null && !value.getMergedIndexPath().equals(".indexer") ) { String mergedIndexPath = "mergedIndexPath"; @@ -887,6 +890,12 @@ public class ConfigurationRegistryWriter { String remoteRepositoryBaseDirectory = "remoteRepositoryBaseDirectory"; registry.setString(prefix + remoteRepositoryBaseDirectory, value.getRemoteRepositoryBaseDirectory()); } + if (value.getRepositoryGroupBaseDirectory() != null + ) { + String repositoryGroupBaseDirectory = "repositoryGroupBaseDirectory"; + registry.setString(prefix + repositoryGroupBaseDirectory, value.getRepositoryGroupBaseDirectory()); + } + if (value.getDefaultLanguage() != null && !value.getDefaultLanguage().equals("en-US") ) { String defaultLanguage = "defaultLanguage";