aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-repository-api
diff options
context:
space:
mode:
authorMartin Schreier <martin_s@apache.org>2022-01-09 23:14:44 +0100
committerMartin Schreier <martin_s@apache.org>2022-01-09 23:14:44 +0100
commita0c5e5a0b0ad6502b0e3c82862bf57287c6a1c15 (patch)
tree36433dbf2a2147cf3dde4a1714b09268a309d678 /archiva-modules/archiva-base/archiva-repository-api
parent239669209d0ca6036ec3387b9f20cb8c3da6ff42 (diff)
downloadarchiva-a0c5e5a0b0ad6502b0e3c82862bf57287c6a1c15.tar.gz
archiva-a0c5e5a0b0ad6502b0e3c82862bf57287c6a1c15.zip
Splitting configuration module. Adding mapper interface.
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-api')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/pom.xml4
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java4
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandler.java17
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandlerManager.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java6
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java33
6 files changed, 51 insertions, 15 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/pom.xml b/archiva-modules/archiva-base/archiva-repository-api/pom.xml
index be94705fe..4ae27d9e3 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-api/pom.xml
@@ -52,8 +52,8 @@
<artifactId>archiva-model</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.archiva</groupId>
- <artifactId>archiva-configuration</artifactId>
+ <groupId>org.apache.archiva.configuration</groupId>
+ <artifactId>archiva-configuration-provider</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java
index 537a043a6..3ea75b266 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryContentFactory.java
@@ -19,10 +19,10 @@ package org.apache.archiva.repository;
* under the License.
*/
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.ConfigurationNames;
import org.apache.archiva.components.registry.Registry;
import org.apache.archiva.components.registry.RegistryListener;
+import org.apache.archiva.configuration.model.ConfigurationNames;
+import org.apache.archiva.configuration.provider.ArchivaConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandler.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandler.java
index ee7f1e4e1..8ed6c37da 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandler.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandler.java
@@ -17,8 +17,8 @@ package org.apache.archiva.repository;
* under the License.
*/
-import org.apache.archiva.configuration.AbstractRepositoryConfiguration;
-import org.apache.archiva.configuration.Configuration;
+import org.apache.archiva.configuration.model.AbstractRepositoryConfiguration;
+import org.apache.archiva.configuration.model.Configuration;
import org.apache.archiva.repository.validation.CheckedResult;
import org.apache.archiva.repository.validation.RepositoryChecker;
import org.apache.archiva.repository.validation.RepositoryValidator;
@@ -141,6 +141,19 @@ public interface RepositoryHandler<R extends Repository, C extends AbstractRepos
putWithCheck( C repositoryConfiguration, RepositoryChecker<R, D> checker ) throws RepositoryException;
/**
+ * Adds or updates a repository from the given configuration data. The resulting repository is
+ * checked by the default repository checker of the handler instance and the result is returned.
+ * If the checker returns a valid result, the registry is updated and configuration is saved.
+ *
+ * @param repositoryConfiguration the repository configuration
+ * @return the repository and the check result as map of attributes -> list of validation errors
+ * @throws RepositoryException if the creation or update failed
+ */
+ CheckedResult<R, Map<String, List<ValidationError>>>
+ putWithCheck( C repositoryConfiguration ) throws RepositoryException;
+
+
+ /**
* Removes the given repository from the registry and updates references and saves the new configuration.
*
* @param id The repository identifier
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandlerManager.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandlerManager.java
index d3270d184..f47bb184a 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandlerManager.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryHandlerManager.java
@@ -17,7 +17,7 @@ package org.apache.archiva.repository;
* under the License.
*/
-import org.apache.archiva.configuration.AbstractRepositoryConfiguration;
+import org.apache.archiva.configuration.model.AbstractRepositoryConfiguration;
import org.apache.archiva.event.Event;
import org.apache.archiva.event.EventHandler;
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 813acb61d..89005f662 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
@@ -19,9 +19,9 @@ package org.apache.archiva.repository;
* under the License.
*/
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.configuration.model.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.model.RemoteRepositoryConfiguration;
+import org.apache.archiva.configuration.model.RepositoryGroupConfiguration;
import org.apache.archiva.event.EventHandler;
import org.apache.archiva.repository.event.RepositoryEvent;
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
index 718045e29..1c6123a83 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
@@ -19,11 +19,11 @@ package org.apache.archiva.repository;
* under the License.
*/
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import org.apache.archiva.configuration.provider.ArchivaConfiguration;
+import org.apache.archiva.configuration.model.Configuration;
+import org.apache.archiva.configuration.model.ManagedRepositoryConfiguration;
+import org.apache.archiva.configuration.model.RemoteRepositoryConfiguration;
+import org.apache.archiva.configuration.model.RepositoryGroupConfiguration;
import org.apache.archiva.event.EventSource;
import org.apache.archiva.indexer.ArchivaIndexManager;
import org.apache.archiva.indexer.IndexUpdateFailedException;
@@ -191,6 +191,16 @@ public interface RepositoryRegistry extends EventSource, RepositoryHandlerManage
ManagedRepository putRepository( ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration ) throws RepositoryException;
/**
+ * Validates the given repository configuration and adds the repository persistent to the registry, if it is valid.
+ * If the validation was not successful, the repository will not be added or persistet, and it will return the list of validation errors.
+ *
+ * @param configuration the managed repository configuration
+ * @return the managed repository or a list of validation errors
+ * @throws RepositoryException if there are errors while adding the repository
+ */
+ CheckedResult<ManagedRepository, Map<String, List<ValidationError>>> putRepositoryAndValidate( ManagedRepositoryConfiguration configuration) throws RepositoryException;
+
+ /**
* Adds or updates the given repository group. If a repository group with the given id exists already, it is updated
* from the data of the given instance. Otherwise a new repository is created and updated by the data of the given instance.
*
@@ -265,6 +275,19 @@ public interface RepositoryRegistry extends EventSource, RepositoryHandlerManage
* Adds or updates the given remote repository. If a remote repository with the given id exists already, it is updated
* from the data of the given configuration. Otherwise a new repository is created and updated by the data of the given configuration.
*
+ * The remoteRepositoryConfiguration is validated before adding to the registry and persisting. If the validation fails,
+ * it is not registered or updated.
+ *
+ * @param remoteRepositoryConfiguration the remote repository configuration
+ * @return the repository instance, that was created or updated
+ * @throws RepositoryException if an error occurred while creating or updating the instance
+ */
+ CheckedResult<RemoteRepository, Map<String, List<ValidationError>>> putRepositoryAndValidate( RemoteRepositoryConfiguration remoteRepositoryConfiguration ) throws RepositoryException;
+
+ /**
+ * Adds or updates the given remote repository. If a remote repository with the given id exists already, it is updated
+ * from the data of the given configuration. Otherwise a new repository is created and updated by the data of the given configuration.
+ *
* This method can be used, if the archiva configuration should not be saved. It will only update the given configuration object.
*
* @param remoteRepositoryConfiguration the remote repository configuration