import java.io.IOException;
import java.util.List;
+import java.util.Map;
/**
* DeleteManagedRepositoryAction
throws RoleManagerException, ArchivaDatabaseException
{
removeRepositoryRoles( cleanupRepository );
-
- // TODO: [MRM-382] Remove index from artifacts of deleted managed repositories.
-
- // [MRM-265] After removing a managed repository - Browse/Search still see it
cleanupDatabase( cleanupRepository.getId() );
cleanupScanStats( cleanupRepository.getId() );
-
- // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
+
List<ProxyConnectorConfiguration> proxyConnectors = getProxyConnectors();
for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
{
archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector );
}
}
+
+ Map<String, List<String>> repoToGroupMap = archivaConfiguration.getConfiguration().getRepositoryToGroupMap();
+ if( repoToGroupMap != null )
+ {
+ if( repoToGroupMap.containsKey( cleanupRepository.getId() ) )
+ {
+ List<String> repoGroups = repoToGroupMap.get( cleanupRepository.getId() );
+ for( String repoGroup : repoGroups )
+ {
+ archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository( cleanupRepository.getId() );
+ }
+ }
+ }
}
private void cleanupDatabase( String repoId )
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
+import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration;
import org.apache.maven.archiva.model.ArchivaProjectModel;
import org.apache.maven.archiva.security.ArchivaRoleConstants;
import org.codehaus.plexus.redback.role.RoleManager;
import org.easymock.MockControl;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
/**
* DeleteManagedRepositoryActionTest
{
prepareRoleManagerMock();
- Configuration configuration = prepDeletionTest( createRepository(), 3 );
+ Configuration configuration = prepDeletionTest( createRepository(), 4 );
String status = action.deleteEntry();
{
prepareRoleManagerMock();
- Configuration configuration = prepDeletionTest( createRepository(), 3 );
+ Configuration configuration = prepDeletionTest( createRepository(), 4 );
String status = action.deleteContents();
public void testDeleteRepositoryAndAssociatedProxyConnectors()
throws Exception
{
- Configuration configuration = prepDeletionTest( createRepository(), 4 );
+ Configuration configuration = prepDeletionTest( createRepository(), 5 );
configuration.addRemoteRepository( createRemoteRepository( "codehaus", "http://repository.codehaus.org" ) );
configuration.addRemoteRepository( createRemoteRepository( "java.net", "http://dev.java.net/maven2" ) );
configuration.addProxyConnector( createProxyConnector( REPO_ID, "codehaus" ) );
assertTrue( location.exists() );
}
+
+ public void testDeleteRepositoryAndReposUnderRepoGroup()
+ throws Exception
+ {
+ Configuration configuration = prepDeletionTest( createRepository(), 5 );
+ List<String> repoIds = new ArrayList<String>();
+ repoIds.add( REPO_ID );
+ configuration.addRepositoryGroup( createRepoGroup( repoIds, "repo.group" ) );
+
+ prepareRoleManagerMock();
+
+ assertEquals( 1, configuration.getRepositoryGroups().size() );
+
+ String status = action.deleteContents();
+ assertEquals( Action.SUCCESS, status );
+
+ assertTrue( configuration.getManagedRepositories().isEmpty() );
+ assertEquals( 0, ( ( RepositoryGroupConfiguration ) configuration.getRepositoryGroups().get( 0 ) ).getRepositories().size() );
+
+ assertFalse( location.exists() );
+ }
private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository, int expectCountGetConfig )
throws RegistryException, IndeterminateConfigurationException
return connector;
}
+ private RepositoryGroupConfiguration createRepoGroup( List<String> repoIds, String repoGroupId )
+ {
+ RepositoryGroupConfiguration repoGroup = new RepositoryGroupConfiguration();
+ repoGroup.setId( repoGroupId );
+ repoGroup.setRepositories( repoIds );
+
+ return repoGroup;
+ }
+
private void prepareRoleManagerMock()
throws RoleManagerException
{