Author: brett
Date: Thu Mar  1 13:15:45 2012
New Revision: 1295553

URL: http://svn.apache.org/viewvc?rev=1295553&view=rev
Log:
[MRM-1612] reduce number of security checks for a configuration change to avoid
blocking when the number of repositories gets large

Modified:
    
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java?rev=1295553&r1=1295552&r2=1295553&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java
 Thu Mar  1 13:15:45 2012
@@ -100,9 +100,12 @@ public class SecuritySynchronization
 
     public void afterConfigurationChange( Registry registry, String 
propertyName, Object propertyValue )
     {
-        if ( ConfigurationNames.isManagedRepositories( propertyName ) )
+        if ( ConfigurationNames.isManagedRepositories( propertyName ) && 
propertyName.endsWith( ".id" ) )
         {
-            synchConfiguration( 
archivaConfiguration.getConfiguration().getManagedRepositories() );
+            if ( propertyValue != null )
+            {
+                syncRepoConfiguration( (String) propertyValue );
+            }
         }
     }
 
@@ -117,39 +120,38 @@ public class SecuritySynchronization
 
         for ( ManagedRepositoryConfiguration repoConfig : repos )
         {
-            // manage roles for repositories
-            try
+            syncRepoConfiguration( repoConfig.getId() );
+        }
+    }
+
+    private void syncRepoConfiguration( String id )
+    {
+        // manage roles for repositories
+        try
+        {
+            if ( !roleManager.templatedRoleExists( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id ) )
             {
-                if ( !roleManager.templatedRoleExists( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
-                                                       repoConfig.getId() ) )
-                {
-                    roleManager.createTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
-                                                     repoConfig.getId() );
-                }
-                else
-                {
-                    roleManager.verifyTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
-                                                     repoConfig.getId() );
-                }
+                roleManager.createTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id );
+            }
+            else
+            {
+                roleManager.verifyTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id );
+            }
 
-                if ( !roleManager.templatedRoleExists( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER,
-                                                       repoConfig.getId() ) )
-                {
-                    roleManager.createTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER,
-                                                     repoConfig.getId() );
-                }
-                else
-                {
-                    roleManager.verifyTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER,
-                                                     repoConfig.getId() );
-                }
+            if ( !roleManager.templatedRoleExists( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, id ) )
+            {
+                roleManager.createTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, id );
             }
-            catch ( RoleManagerException e )
+            else
             {
-                // Log error.
-                log.error( "Unable to create roles for configured 
repositories: " + e.getMessage(), e );
+                roleManager.verifyTemplatedRole( 
ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, id );
             }
         }
+        catch ( RoleManagerException e )
+        {
+            // Log error.
+            log.error( "Unable to create roles for configured repositories: " 
+ e.getMessage(), e );
+        }
     }
 
     public void startup()


Reply via email to