*
* @author Olivier Lamy
*/
-@Service ( "managedRepositoryAdmin#default" )
+@Service( "managedRepositoryAdmin#default" )
public class DefaultManagedRepositoryAdmin
extends AbstractRepositoryAdmin
implements ManagedRepositoryAdmin
public static final String STAGE_REPO_ID_END = "-stage";
@Inject
- @Named ( value = "archivaTaskScheduler#repository" )
+ @Named( value = "archivaTaskScheduler#repository" )
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
@Inject
}
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;
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 );
{
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;
}