add repository roles from the configuration

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@541057 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jesse McConnell 2007-05-23 20:33:54 +00:00
parent 4687c698c7
commit 728afe73ad
1 changed files with 28 additions and 1 deletions

View File

@ -30,6 +30,8 @@ import org.apache.maven.archiva.repository.ArchivaConfigurationAdaptor;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.redback.role.RoleManager;
import org.codehaus.plexus.redback.role.RoleManagerException;
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener;
@ -54,6 +56,11 @@ public class ConfigurationSynchronization
*/
private ArchivaDAO dao;
/**
* @plexus.requirement role-hint="default"
*/
RoleManager roleManager;
/**
* @plexus.requirement
*/
@ -109,6 +116,26 @@ public class ConfigurationSynchronization
// Log error.
getLogger().error( "Unable to add configured repositories to the database: " + e.getMessage(), e );
}
// manage roles for repositories
try
{
if ( !roleManager.templatedRoleExists( "archiva-repository-observer", repoConfig.getId() ) )
{
roleManager.createTemplatedRole( "archiva-repository-observer", repoConfig.getId() );
}
if ( !roleManager.templatedRoleExists( "archiva-repository-manager", repoConfig.getId() ) );
{
roleManager.createTemplatedRole( "archiva-repository-manager", repoConfig.getId() );
}
}
catch ( RoleManagerException e )
{
// Log error.
getLogger().error( "Unable to create roles for configured repositories: " + e.getMessage(), e );
}
}
}