diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java index f3c62a023..f35af62e4 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java @@ -109,7 +109,7 @@ public class DefaultManagedRepositoryAdmin @PostConstruct public void initialize() - throws RepositoryAdminException + throws RepositoryAdminException, RoleManagerException { try { @@ -120,10 +120,12 @@ public class DefaultManagedRepositoryAdmin { throw new RepositoryAdminException( e.getMessage(), e ); } - // initialize index context on start + // initialize index context on start and check roles here for ( ManagedRepository managedRepository : getManagedRepositories() ) { createIndexContext( managedRepository ); + addRepositoryRoles( managedRepository.getId() ); + } } @@ -264,13 +266,13 @@ public class DefaultManagedRepositoryAdmin try { addRepository( repository, config ); - addRepositoryRoles( repository ); + addRepositoryRoles( repository.getId() ); if ( stageRepoNeeded ) { ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository ); addRepository( stagingRepository, config ); - addRepositoryRoles( stagingRepository ); + addRepositoryRoles( stagingRepository.getId() ); triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation ); } } @@ -727,7 +729,8 @@ public class DefaultManagedRepositoryAdmin return true; } - protected void addRepositoryRoles( ManagedRepositoryConfiguration newRepository ) + + public void addRepositoryRoles( ManagedRepository newRepository ) throws RoleManagerException { String repoId = newRepository.getId(); @@ -746,6 +749,24 @@ public class DefaultManagedRepositoryAdmin } } + + private void addRepositoryRoles( String repoId ) + throws RoleManagerException + { + // TODO: double check these are configured on start up + // TODO: belongs in the business logic + + if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) ) + { + getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ); + } + + if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) ) + { + getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ); + } + } + protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository ) throws RoleManagerException { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index bd856338a..6bd4dd280 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -179,6 +179,8 @@ public class DefaultRedbackRuntimeConfigurationService ldapUserMapper.initialize(); + //check repositories roles are here !!! + return Boolean.TRUE; } catch ( Exception e )