diff options
author | Olivier Lamy <olamy@apache.org> | 2013-04-24 13:38:23 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2013-04-24 13:38:23 +0000 |
commit | a63168fbbc1793906238e670897458b23aaffeec (patch) | |
tree | 4a6227e9d7353342cc735b842fc05451b7334514 /archiva-modules/archiva-base | |
parent | 3c082f7e58b0c7ac4c5af3a32c5ce5f9b662aec9 (diff) | |
download | archiva-a63168fbbc1793906238e670897458b23aaffeec.tar.gz archiva-a63168fbbc1793906238e670897458b23aaffeec.zip |
verify roles for repository are configured on startup
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1471410 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r-- | archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/managed/DefaultManagedRepositoryAdmin.java | 31 |
1 files changed, 26 insertions, 5 deletions
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 { |