From cd57d56fe9eab2d30db6c882dd79b27a039b1c43 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 13 Sep 2011 17:30:51 +0000 Subject: [PATCH] remove IndexingContext when deleting a managed repository git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170259 13f79535-47bb-0310-9956-ffa450edef68 --- .../DefaultManagedRepositoryAdmin.java | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index bee986948..d3d87eebb 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -24,6 +24,8 @@ import org.apache.archiva.admin.model.managed.ManagedRepository; import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin; import org.apache.archiva.admin.repository.AbstractRepositoryAdmin; import org.apache.archiva.audit.AuditEvent; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; +import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException; import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; @@ -39,6 +41,8 @@ import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; +import org.apache.maven.index.NexusIndexer; +import org.apache.maven.index.context.IndexingContext; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; import org.codehaus.plexus.taskqueue.TaskQueueException; @@ -86,6 +90,9 @@ public class DefaultManagedRepositoryAdmin @Inject private RepositoryStatisticsManager repositoryStatisticsManager; + @Inject + private PlexusSisuBridge plexusSisuBridge; + @Inject protected RoleManager roleManager; @@ -209,7 +216,6 @@ public class DefaultManagedRepositoryAdmin repository.setRetentionCount( retentionCount ); repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots ); - try { addRepository( repository, config ); @@ -281,7 +287,6 @@ public class DefaultManagedRepositoryAdmin if ( stagingRepository != null ) { // do not trigger event when deleting the staged one - //triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.DELETE_MANAGED_REPO, auditInformation ); deleteManagedRepository( stagingRepository, deleteContent, config, true ); } @@ -301,6 +306,25 @@ public class DefaultManagedRepositoryAdmin Configuration config, boolean stagedOne ) throws RepositoryAdminException { + + try + { + NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); + + IndexingContext context = nexusIndexer.getIndexingContexts().get( repository.getId() ); + if ( context != null ) + { + nexusIndexer.removeIndexingContext( context, deleteContent ); + } + } + catch ( PlexusSisuBridgeException e ) + { + throw new RepositoryAdminException( e.getMessage(), e ); + } + catch ( IOException e ) + { + throw new RepositoryAdminException( e.getMessage(), e ); + } if ( !stagedOne ) { RepositorySession repositorySession = getRepositorySessionFactory().createSession(); -- 2.39.5