mirror of https://github.com/apache/archiva.git
[MRM-823]
-remove repo in group when repo is removed git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@662342 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8b1dbf37ee
commit
eb6967d2e6
|
@ -41,6 +41,7 @@ import org.codehaus.plexus.redback.role.RoleManagerException;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* DeleteManagedRepositoryAction
|
||||
|
@ -140,14 +141,9 @@ public class 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 )
|
||||
{
|
||||
|
@ -156,6 +152,19 @@ public class DeleteManagedRepositoryAction
|
|||
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 )
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.maven.archiva.configuration.IndeterminateConfigurationExceptio
|
|||
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;
|
||||
|
@ -37,7 +38,9 @@ import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
|||
import org.easymock.MockControl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DeleteManagedRepositoryActionTest
|
||||
|
@ -128,7 +131,7 @@ public class DeleteManagedRepositoryActionTest
|
|||
{
|
||||
prepareRoleManagerMock();
|
||||
|
||||
Configuration configuration = prepDeletionTest( createRepository(), 3 );
|
||||
Configuration configuration = prepDeletionTest( createRepository(), 4 );
|
||||
|
||||
String status = action.deleteEntry();
|
||||
|
||||
|
@ -144,7 +147,7 @@ public class DeleteManagedRepositoryActionTest
|
|||
{
|
||||
prepareRoleManagerMock();
|
||||
|
||||
Configuration configuration = prepDeletionTest( createRepository(), 3 );
|
||||
Configuration configuration = prepDeletionTest( createRepository(), 4 );
|
||||
|
||||
String status = action.deleteContents();
|
||||
|
||||
|
@ -158,7 +161,7 @@ public class DeleteManagedRepositoryActionTest
|
|||
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" ) );
|
||||
|
@ -191,6 +194,27 @@ public class DeleteManagedRepositoryActionTest
|
|||
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
|
||||
{
|
||||
|
@ -276,6 +300,15 @@ public class DeleteManagedRepositoryActionTest
|
|||
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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue