]> source.dussan.org Git - archiva.git/commitdiff
remove IndexingContext when deleting a managed repository
authorOlivier Lamy <olamy@apache.org>
Tue, 13 Sep 2011 17:30:51 +0000 (17:30 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 13 Sep 2011 17:30:51 +0000 (17:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170259 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java

index bee98694895d89f864b10a088698f503bfbfca4e..d3d87eebbf1ff88f3bb07ec420830c6d4b02a041 100644 (file)
@@ -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();