aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-06-22 08:03:00 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-06-22 08:03:00 +0200
commitb48158fdcd72c5f8a9dfc2fd38e2ff60660d6f81 (patch)
tree2e5926d9973fe48553ce2c2017825e5018385643 /archiva-modules/archiva-base
parenta52b7f2005ddf040a712ee774909206294833668 (diff)
downloadarchiva-b48158fdcd72c5f8a9dfc2fd38e2ff60660d6f81.tar.gz
archiva-b48158fdcd72c5f8a9dfc2fd38e2ff60660d6f81.zip
Fixing RepositoryGroupAdmin after refactor
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java13
2 files changed, 15 insertions, 1 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
index 142f4f44a..757aa12a8 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/group/DefaultRepositoryGroupAdmin.java
@@ -165,7 +165,7 @@ public class DefaultRepositoryGroupAdmin
throw new RepositoryAdminException("Removal of repository failed: " + e.getMessage(), e);
}
mergedRemoteIndexesScheduler.unschedule(
- repositoryRegistry.getRepositoryGroup( repositoryGroupId ) );
+ repositoryGroup );
triggerAuditEvent( repositoryGroupId, null, AuditEvent.DELETE_REPO_GROUP, auditInformation );
return Boolean.TRUE;
@@ -204,6 +204,7 @@ public class DefaultRepositoryGroupAdmin
org.apache.archiva.repository.RepositoryGroup rg = repositoryRegistry.getRepositoryGroup( repositoryGroup.getId( ) );
mergedRemoteIndexesScheduler.unschedule( rg );
mergedRemoteIndexesScheduler.schedule( rg, getMergedIndexDirectory( repositoryGroup.getId() ) );
+ triggerAuditEvent( repositoryGroup.getId(), null, AuditEvent.MODIFY_REPO_GROUP, auditInformation );
return Boolean.TRUE;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
index 6a9db1dad..79c28bbe1 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/RepositoryRegistry.java
@@ -1029,6 +1029,10 @@ public class RepositoryRegistry implements ConfigurationListener, RepositoryEven
@SuppressWarnings( "unchecked" )
public void removeRepository(Repository repo) throws RepositoryException
{
+ if (repo==null) {
+ log.warn("Trying to remove null repository");
+ return;
+ }
if (repo instanceof RemoteRepository ) {
removeRepository( (RemoteRepository)repo );
} else if (repo instanceof ManagedRepository) {
@@ -1057,6 +1061,7 @@ public class RepositoryRegistry implements ConfigurationListener, RepositoryEven
repo = managedRepositories.remove( id );
if (repo!=null) {
repo.close();
+ removeRepositoryFromGroups(repo);
Configuration configuration = getArchivaConfiguration().getConfiguration();
ManagedRepositoryConfiguration cfg = configuration.findManagedRepositoryById( id );
if (cfg!=null) {
@@ -1079,6 +1084,13 @@ public class RepositoryRegistry implements ConfigurationListener, RepositoryEven
}
}
+ private void removeRepositoryFromGroups(ManagedRepository repo) {
+ if (repo!=null) {
+ repositoryGroups.values().stream().filter(repoGroup -> repoGroup instanceof EditableRepository).
+ map(repoGroup -> (EditableRepositoryGroup) repoGroup).forEach(repoGroup -> repoGroup.removeRepository(repo));
+ }
+ }
+
public void removeRepository(ManagedRepository managedRepository, Configuration configuration) throws RepositoryException
{
final String id = managedRepository.getId();
@@ -1089,6 +1101,7 @@ public class RepositoryRegistry implements ConfigurationListener, RepositoryEven
repo = managedRepositories.remove( id );
if (repo!=null) {
repo.close();
+ removeRepositoryFromGroups(repo);
ManagedRepositoryConfiguration cfg = configuration.findManagedRepositoryById( id );
if (cfg!=null) {
configuration.removeManagedRepository( cfg );