@PostConstruct
public void initialize()
- throws RepositoryAdminException
+ throws RepositoryAdminException, RoleManagerException
{
try
{
{
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() );
+
}
}
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 );
}
}
return true;
}
- protected void addRepositoryRoles( ManagedRepositoryConfiguration newRepository )
+
+ public void addRepositoryRoles( ManagedRepository newRepository )
throws RoleManagerException
{
String repoId = newRepository.getId();
}
}
+
+ 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
{