mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
31ef1c070d
commit
be37e4f6a1
|
@ -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
|
||||
{
|
||||
|
@ -138,4 +144,5 @@ public abstract class AbstractDeleteRepositoryAction
|
|||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue