]> source.dussan.org Git - archiva.git/commitdiff
[MRM-462] some more clean up
authorBrett Porter <brett@apache.org>
Wed, 12 Sep 2007 06:56:33 +0000 (06:56 +0000)
committerBrett Porter <brett@apache.org>
Wed, 12 Sep 2007 06:56:33 +0000 (06:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches@574805 13f79535-47bb-0310-9956-ffa450edef68

MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/check/RoleExistanceEnvironmentCheck.java
MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/startup/ConfigurationSynchronization.java

index d0fd226d5e286879d11d7cfdfcee307d5390609f..7106faa9eaf3aab2a183350b4e84a6cd7aadda99 100644 (file)
@@ -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;
         }
index aae229286e99530f8252b3d425d2eddd628de770..0418379775f39f5eb787f1f24c9f5dd7d926a22a 100644 (file)
@@ -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() );