From 44a76d924993680da06126630cb5dddce0601fd4 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Wed, 12 Sep 2007 06:56:33 +0000 Subject: [PATCH] [MRM-462] some more clean up git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@574805 13f79535-47bb-0310-9956-ffa450edef68 --- .../check/RoleExistanceEnvironmentCheck.java | 32 ++++++------------- .../startup/ConfigurationSynchronization.java | 2 +- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/check/RoleExistanceEnvironmentCheck.java b/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/check/RoleExistanceEnvironmentCheck.java index d0fd226d5..7106faa9e 100644 --- a/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/check/RoleExistanceEnvironmentCheck.java +++ b/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/check/RoleExistanceEnvironmentCheck.java @@ -19,16 +19,15 @@ package org.apache.maven.archiva.web.check; * under the License. */ +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.Configuration; +import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.model.ArchivaRepository; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.redback.role.RoleManager; import org.codehaus.plexus.redback.role.RoleManagerException; import org.codehaus.plexus.redback.system.check.EnvironmentCheck; -import java.util.Iterator; import java.util.List; /** @@ -57,6 +56,11 @@ public class RoleExistanceEnvironmentCheck */ private RoleManager roleManager; + /** + * @plexus.requirement + */ + private ArchivaConfiguration configuration; + private boolean checked; public void validateEnvironment( List list ) @@ -65,14 +69,9 @@ public class RoleExistanceEnvironmentCheck { try { - List repos = dao.getRepositoryDAO().getRepositories(); - - // TODO! this be skipping non-managed repos - Iterator it = repos.iterator(); - while ( it.hasNext() ) + Configuration config = configuration.getConfiguration(); + for ( ManagedRepositoryConfiguration repository : config.getManagedRepositoriesAsMap().values() ) { - ArchivaRepository repository = (ArchivaRepository) it.next(); - if ( !roleManager.templatedRoleExists( "archiva-repository-manager", repository.getId() ) ) { roleManager.createTemplatedRole( "archiva-repository-manager", repository.getId() ); @@ -89,17 +88,6 @@ public class RoleExistanceEnvironmentCheck list.add( this.getClass().getName() + "error initializing roles: " + rpe.getMessage() ); getLogger().info( "error initializing roles", rpe ); } - catch ( ObjectNotFoundException e ) - { - list.add( - this.getClass().getName() + "error initializing roles (repository not found): " + e.getMessage() ); - getLogger().info( "error initializing roles", e ); - } - catch ( ArchivaDatabaseException e ) - { - list.add( this.getClass().getName() + "error initializing roles (database error): " + e.getMessage() ); - getLogger().info( "error initializing roles", e ); - } checked = true; } diff --git a/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java b/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java index aae229286..041837977 100644 --- a/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java +++ b/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java @@ -46,6 +46,7 @@ import java.util.List; * @version $Id$ * @plexus.component role="org.apache.maven.archiva.web.startup.ConfigurationSynchronization" * role-hint="default" + * @todo consider whether we really need these in the database or not */ public class ConfigurationSynchronization extends AbstractLogEnabled @@ -68,7 +69,6 @@ public class ConfigurationSynchronization public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) { - // TODO! this used to store both types, but do we even need it? if ( ConfigurationNames.isManagedRepositories( propertyName ) ) { synchConfiguration( archivaConfiguration.getConfiguration().getManagedRepositories() ); -- 2.39.5