import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
/**
* DeleteManagedRepositoryAction
}
private String deleteRepository( boolean deleteContents )
- {
+ {
ManagedRepositoryConfiguration existingRepository = repository;
if ( existingRepository == null )
{
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;
try
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 )
throws RegistryException, IndeterminateConfigurationException