]> source.dussan.org Git - archiva.git/commitdiff
Adding new group properties to configuration
authorMartin Stockhammer <martin_s@apache.org>
Sun, 19 May 2019 15:31:58 +0000 (17:31 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 19 May 2019 15:31:58 +0000 (17:31 +0200)
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/ArchivaRuntimeConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/RepositoryGroupConfiguration.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryReader.java
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/io/registry/ConfigurationRegistryWriter.java

index e7b2b6edb604b952f699e98be67951ad3b1b4d1a..0f6ff82e2b05c89748698cd704dca17c09128129 100644 (file)
@@ -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
index ae9b9bb90400a411fb7b687a80fbc8a8c0406e4e..b0568609291f90991161633dfbbbe76e6114e1e4 100644 (file)
@@ -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.
      * 
index 8839db6c5c22df7785b7955c0f43f50b3cb66b09..13e8a2898aee54c37e071a445f55b72ebdf21dc0 100644 (file)
@@ -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) {
index 826fc506390a1eac6d23a218a16201d110968226..d2cc9cb2745d98b4b68f1b3c637e9a7ec88a8630 100644 (file)
@@ -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<String> repositories;
+    private List<String> repositories;
 
 
       //-----------/
@@ -123,11 +132,11 @@ public class RepositoryGroupConfiguration
      * 
      * @return List
      */
-    public java.util.List<String> getRepositories()
+    public List<String> getRepositories()
     {
         if ( this.repositories == null )
         {
-            this.repositories = new java.util.ArrayList<String>();
+            this.repositories = new ArrayList<String>();
         }
 
         return this.repositories;
@@ -190,9 +199,16 @@ public class RepositoryGroupConfiguration
      * 
      * @param repositories
      */
-    public void setRepositories( java.util.List<String> repositories )
+    public void setRepositories( List<String> repositories )
     {
         this.repositories = repositories;
     } //-- void setRepositories( java.util.List )
 
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 }
index d8783453e5471aadd78ce402344109344be2a084..7c0535e8bdb25393108223622c6a18784e80fd40 100644 (file)
@@ -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<String> mergedIndexPathList = registry.getList(prefix + "mergedIndexPath");
@@ -1392,6 +1395,22 @@ public class ConfigurationRegistryReader {
         value.setRemoteRepositoryBaseDirectory(remoteRepositoryBaseDirectory);
         //String defaultLanguage = registry.getString( prefix + "defaultLanguage", value.getDefaultLanguage() );
 
+
+        List<String> 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<String> defaultLanguageList = registry.getList(prefix + "defaultLanguage");
         String defaultLanguage = value.getDefaultLanguage();
         if (defaultLanguageList != null && !defaultLanguageList.isEmpty()) {
index 31ffc6b9d5201bae5c42e5faf576c545300472dc..915cd8b8ec0d70ae5b2a23ee4c1f8fd658e35444 100644 (file)
@@ -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";