]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1744] updating managed repository fail to correctly update maven index directory.
authorOlivier Lamy <olamy@apache.org>
Wed, 6 Feb 2013 21:21:01 +0000 (21:21 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 6 Feb 2013 21:21:01 +0000 (21:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1443216 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 d82473f71cfa923a59049b38a1176990986db3a7..0617266d7d4c4bbbe70712be99a58bbfc062b9df 100644 (file)
@@ -70,7 +70,7 @@ import java.util.Map;
  *
  * @author Olivier Lamy
  */
-@Service ( "managedRepositoryAdmin#default" )
+@Service( "managedRepositoryAdmin#default" )
 public class DefaultManagedRepositoryAdmin
     extends AbstractRepositoryAdmin
     implements ManagedRepositoryAdmin
@@ -81,7 +81,7 @@ public class DefaultManagedRepositoryAdmin
     public static final String STAGE_REPO_ID_END = "-stage";
 
     @Inject
-    @Named ( value = "archivaTaskScheduler#repository" )
+    @Named( value = "archivaTaskScheduler#repository" )
     private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
 
     @Inject
@@ -339,7 +339,7 @@ public class DefaultManagedRepositoryAdmin
         }
         catch ( Exception e )
         {
-            throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage(), e);
+            throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage(), e );
         }
 
         return Boolean.TRUE;
@@ -468,9 +468,13 @@ public class DefaultManagedRepositoryAdmin
 
         ManagedRepositoryConfiguration toremove = configuration.findManagedRepositoryById( managedRepository.getId() );
 
+        boolean updateIndexContext = false;
+
         if ( toremove != null )
         {
             configuration.removeManagedRepository( toremove );
+
+            updateIndexContext = !StringUtils.equals( toremove.getIndexDir(), managedRepository.getIndexDirectory() );
         }
 
         ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( toremove );
@@ -518,7 +522,24 @@ public class DefaultManagedRepositoryAdmin
         {
             repositorySession.close();
         }
-        createIndexContext( managedRepository );
+
+        if ( updateIndexContext )
+        {
+            try
+            {
+                IndexingContext indexingContext = indexer.getIndexingContexts().get( managedRepository.getId() );
+                if ( indexingContext != null )
+                {
+                    indexer.removeIndexingContext( indexingContext, true );
+                }
+                createIndexContext( managedRepository );
+            }
+            catch ( IOException e )
+            {
+                throw new RepositoryAdminException( e.getMessage(), e );
+            }
+        }
+
         return true;
     }