From be37e4f6a152153ad699740dd52fde3520548eb3 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 21 Nov 2006 11:43:09 +0000 Subject: [PATCH] PR: MRM-231 Added deletion of user profiles associated with a specific repository once that repository is deleted. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@477635 13f79535-47bb-0310-9956-ffa450edef68 --- .../admin/AbstractDeleteRepositoryAction.java | 9 ++++++- .../action/admin/DeleteRepositoryAction.java | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java index 63206a74d..873abf73a 100644 --- a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java +++ b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/AbstractDeleteRepositoryAction.java @@ -28,6 +28,8 @@ import org.codehaus.plexus.security.ui.web.interceptor.SecureAction; import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle; import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; +import org.codehaus.plexus.rbac.profile.RoleProfileManager; +import org.codehaus.plexus.rbac.profile.RoleProfileException; import java.io.IOException; @@ -55,6 +57,10 @@ public abstract class AbstractDeleteRepositoryAction */ private String operation = "unmodified"; + /** + * @plexus.requirement role-hint="archiva" + */ + protected RoleProfileManager roleProfileManager; public String execute() throws ConfigurationStoreException, IOException, InvalidConfigurationException, ConfigurationChangeException { @@ -92,7 +98,7 @@ public abstract class AbstractDeleteRepositoryAction protected abstract AbstractRepositoryConfiguration getRepository( Configuration configuration ); protected abstract void removeRepository( Configuration configuration, - AbstractRepositoryConfiguration existingRepository ); + AbstractRepositoryConfiguration existingRepository ); public String input() { @@ -138,4 +144,5 @@ public abstract class AbstractDeleteRepositoryAction return bundle; } + } diff --git a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java index d28657e8f..30d22e64e 100644 --- a/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java +++ b/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/DeleteRepositoryAction.java @@ -20,6 +20,7 @@ import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.RepositoryConfiguration; import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.rbac.profile.RoleProfileException; import java.io.IOException; @@ -39,6 +40,16 @@ public class DeleteRepositoryAction protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository ) { configuration.removeRepository( (RepositoryConfiguration) existingRepository ); + + try + { + removeRepositoryRoles( existingRepository ); + } + catch ( RoleProfileException e ) + { + getLogger().error( "Error removing user roles associated with repository " + + existingRepository.getId() ); + } } protected void removeContents( AbstractRepositoryConfiguration existingRepository ) @@ -48,4 +59,19 @@ public class DeleteRepositoryAction getLogger().info( "Removing " + repository.getDirectory() ); FileUtils.deleteDirectory( repository.getDirectory() ); } + + /** + * Remove user roles associated with the repository + * + * @param existingRepository + * @throws RoleProfileException + */ + private void removeRepositoryRoles( AbstractRepositoryConfiguration existingRepository ) + throws RoleProfileException + { + roleProfileManager.deleteDynamicRole( "archiva-repository-manager", existingRepository.getId() ); + roleProfileManager.deleteDynamicRole( "archiva-repository-observer", existingRepository.getId() ); + + getLogger().info( "removed user roles associated with repository " + existingRepository.getId() ); + } } -- 2.39.5