From: Brett Porter Date: Thu, 1 Mar 2012 13:15:45 +0000 (+0000) Subject: [MRM-1612] reduce number of security checks for a configuration change to avoid X-Git-Tag: archiva-1.4-M3~1156 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fa3688a693bc10bf53e72965027a82df0a8ad267;p=archiva.git [MRM-1612] reduce number of security checks for a configuration change to avoid blocking when the number of repositories gets large git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295553 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java index 76d81feef..47980e88c 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/startup/SecuritySynchronization.java @@ -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()