mirror of https://github.com/apache/archiva.git
added in a refresh in case the user store is nukes and the repos still exist, it will now add roles for the existing repos.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@447799 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c8f3d6ba77
commit
f34871ea6d
|
@ -20,11 +20,15 @@ import com.opensymphony.xwork.ActionInvocation;
|
|||
import com.opensymphony.xwork.interceptor.Interceptor;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationStore;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationStoreException;
|
||||
import org.apache.maven.archiva.web.util.RoleManager;
|
||||
import org.apache.maven.archiva.web.ArchivaDefaults;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.security.rbac.RBACManager;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* An interceptor that makes the application configuration available
|
||||
*
|
||||
|
@ -65,6 +69,7 @@ public class ConfigurationInterceptor
|
|||
throws Exception
|
||||
{
|
||||
archivaDefaults.ensureDefaultsExist();
|
||||
ensureRepoRolesExist();
|
||||
|
||||
// determine if we need an admin account made
|
||||
|
||||
|
@ -89,6 +94,38 @@ public class ConfigurationInterceptor
|
|||
}
|
||||
}
|
||||
|
||||
public void ensureRepoRolesExist()
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( configurationStore.getConfigurationFromStore().isValid() )
|
||||
{
|
||||
Map repositories = configurationStore.getConfigurationFromStore().getRepositoriesMap();
|
||||
|
||||
for ( Iterator i = repositories.keySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
String id = (String) i.next();
|
||||
|
||||
if ( !rbacManager.roleExists( "Repository Observer - " + id ) )
|
||||
{
|
||||
getLogger().info( "recovering Repository Observer - " + id );
|
||||
roleManager.addRepository( id );
|
||||
}
|
||||
|
||||
if ( !rbacManager.roleExists( "Repository Manager - " + id ) )
|
||||
{
|
||||
getLogger().info( "recovering Repository Manager - " + id );
|
||||
roleManager.addRepository( id );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( ConfigurationStoreException e )
|
||||
{
|
||||
throw new RuntimeException( "error with configurationStore()" );
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
// This space left intentionally blank
|
||||
|
|
Loading…
Reference in New Issue