mirror of https://github.com/apache/archiva.git
[MRM-789]
-check if the repo location is referenced as a system property before deleting the contents of the repo git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@662662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
82bc905da8
commit
ab0724b375
|
@ -42,6 +42,7 @@ import org.codehaus.plexus.redback.role.RoleManagerException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeleteManagedRepositoryAction
|
* DeleteManagedRepositoryAction
|
||||||
|
@ -101,6 +102,20 @@ public class DeleteManagedRepositoryAction
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( deleteContents )
|
||||||
|
{
|
||||||
|
// [MRM-789] Archiva may delete your app server installation
|
||||||
|
Properties props = System.getProperties();
|
||||||
|
for( Object value : props.values() )
|
||||||
|
{
|
||||||
|
if( StringUtils.equalsIgnoreCase( ( (String) value ).trim(), existingRepository.getLocation().trim() ) )
|
||||||
|
{
|
||||||
|
addActionError( "Unable to delete repository. The location is being referenced in the system properties." );
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String result = SUCCESS;
|
String result = SUCCESS;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -215,6 +215,26 @@ public class DeleteManagedRepositoryActionTest
|
||||||
assertFalse( location.exists() );
|
assertFalse( location.exists() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeleteRepositoryLocationReferencedInSysPropertiesError()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
System.setProperty( "test.property", getTestFile( "target/test/location" ).getAbsolutePath() );
|
||||||
|
|
||||||
|
prepareRoleManagerMock();
|
||||||
|
|
||||||
|
Configuration configuration = prepDeletionTest( createRepository(), 4 );
|
||||||
|
|
||||||
|
String status = action.deleteContents();
|
||||||
|
|
||||||
|
assertEquals( Action.ERROR, status );
|
||||||
|
|
||||||
|
assertFalse( configuration.getManagedRepositories().isEmpty() );
|
||||||
|
|
||||||
|
assertTrue( location.exists() );
|
||||||
|
|
||||||
|
System.clearProperty( "test.property" );
|
||||||
|
}
|
||||||
|
|
||||||
private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository, int expectCountGetConfig )
|
private Configuration prepDeletionTest( ManagedRepositoryConfiguration originalRepository, int expectCountGetConfig )
|
||||||
throws RegistryException, IndeterminateConfigurationException
|
throws RegistryException, IndeterminateConfigurationException
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue