summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java17
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java20
2 files changed, 36 insertions, 1 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
index 438031320..14e62d4e6 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryAction.java
@@ -42,6 +42,7 @@ import org.codehaus.plexus.redback.role.RoleManagerException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
/**
* DeleteManagedRepositoryAction
@@ -93,7 +94,7 @@ public class DeleteManagedRepositoryAction
}
private String deleteRepository( boolean deleteContents )
- {
+ {
ManagedRepositoryConfiguration existingRepository = repository;
if ( existingRepository == null )
{
@@ -101,6 +102,20 @@ public class DeleteManagedRepositoryAction
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
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
index 41536c1c7..4cb35ab71 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteManagedRepositoryActionTest.java
@@ -214,6 +214,26 @@ public class DeleteManagedRepositoryActionTest
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