1 package org.apache.archiva.admin.repository.managed;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.admin.model.AuditInformation;
22 import org.apache.archiva.admin.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.ManagedRepository;
24 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
25 import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
26 import org.apache.archiva.audit.AuditEvent;
27 import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
28 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
29 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
30 import org.apache.archiva.configuration.Configuration;
31 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
32 import org.apache.archiva.configuration.ProxyConnectorConfiguration;
33 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
34 import org.apache.archiva.metadata.repository.MetadataRepository;
35 import org.apache.archiva.metadata.repository.MetadataRepositoryException;
36 import org.apache.archiva.metadata.repository.RepositorySession;
37 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
38 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
39 import org.apache.archiva.redback.components.cache.Cache;
40 import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
41 import org.apache.archiva.redback.role.RoleManager;
42 import org.apache.archiva.redback.role.RoleManagerException;
43 import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
44 import org.apache.archiva.scheduler.repository.model.RepositoryTask;
45 import org.apache.archiva.security.common.ArchivaRoleConstants;
46 import org.apache.commons.io.FileUtils;
47 import org.apache.commons.lang.StringUtils;
48 import org.apache.maven.index.NexusIndexer;
49 import org.apache.maven.index.context.IndexCreator;
50 import org.apache.maven.index.context.IndexingContext;
51 import org.apache.maven.index.context.UnsupportedExistingLuceneIndexException;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
54 import org.springframework.stereotype.Service;
56 import javax.annotation.PostConstruct;
57 import javax.annotation.PreDestroy;
58 import javax.inject.Inject;
59 import javax.inject.Named;
61 import java.io.IOException;
62 import java.net.MalformedURLException;
63 import java.util.ArrayList;
64 import java.util.Collection;
65 import java.util.Collections;
66 import java.util.HashMap;
67 import java.util.List;
71 * FIXME review the staging mechanism to have a per user session one
73 * @author Olivier Lamy
75 @Service("managedRepositoryAdmin#default")
76 public class DefaultManagedRepositoryAdmin
77 extends AbstractRepositoryAdmin
78 implements ManagedRepositoryAdmin
81 private Logger log = LoggerFactory.getLogger( getClass() );
83 public static final String STAGE_REPO_ID_END = "-stage";
86 @Named(value = "archivaTaskScheduler#repository")
87 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
90 * FIXME: this could be multiple implementations and needs to be configured.
93 private RepositorySessionFactory repositorySessionFactory;
96 private RepositoryStatisticsManager repositoryStatisticsManager;
99 private PlexusSisuBridge plexusSisuBridge;
102 private MavenIndexerUtils mavenIndexerUtils;
105 protected RoleManager roleManager;
108 @Named(value = "cache#namespaces")
109 private Cache<String, Collection<String>> namespacesCache;
112 List<? extends IndexCreator> indexCreators;
114 NexusIndexer indexer;
117 public void initialize()
118 throws RepositoryAdminException, RoleManagerException
122 indexCreators = mavenIndexerUtils.getAllIndexCreators();
123 indexer = plexusSisuBridge.lookup( NexusIndexer.class );
125 catch ( PlexusSisuBridgeException e )
127 throw new RepositoryAdminException( e.getMessage(), e );
129 // initialize index context on start and check roles here
130 for ( ManagedRepository managedRepository : getManagedRepositories() )
132 createIndexContext( managedRepository );
133 addRepositoryRoles( managedRepository.getId() );
139 public void shutdown()
140 throws RepositoryAdminException
144 // close index on shutdown
145 for ( ManagedRepository managedRepository : getManagedRepositories() )
147 IndexingContext context = indexer.getIndexingContexts().get( managedRepository.getId() );
148 if ( context != null )
150 indexer.removeIndexingContext( context, false );
154 catch ( IOException e )
156 throw new RepositoryAdminException( e.getMessage(), e );
161 public List<ManagedRepository> getManagedRepositories()
162 throws RepositoryAdminException
164 List<ManagedRepositoryConfiguration> managedRepoConfigs =
165 getArchivaConfiguration().getConfiguration().getManagedRepositories();
167 if ( managedRepoConfigs == null )
169 return Collections.emptyList();
172 List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
174 for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
176 ManagedRepository repo =
177 new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
178 repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
179 repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
180 repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
181 repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(),
182 repoConfig.isStageRepoNeeded() );
183 repo.setDescription( repoConfig.getDescription() );
184 repo.setSkipPackedIndexCreation( repoConfig.isSkipPackedIndexCreation() );
185 managedRepos.add( repo );
192 public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
193 throws RepositoryAdminException
195 List<ManagedRepository> managedRepositories = getManagedRepositories();
196 Map<String, ManagedRepository> repositoriesMap = new HashMap<>( managedRepositories.size() );
197 for ( ManagedRepository managedRepository : managedRepositories )
199 repositoriesMap.put( managedRepository.getId(), managedRepository );
201 return repositoriesMap;
205 public ManagedRepository getManagedRepository( String repositoryId )
206 throws RepositoryAdminException
208 List<ManagedRepository> repos = getManagedRepositories();
209 for ( ManagedRepository repo : repos )
211 if ( StringUtils.equals( repo.getId(), repositoryId ) )
220 public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
221 AuditInformation auditInformation )
222 throws RepositoryAdminException
225 getRepositoryCommonValidator().basicValidation( managedRepository, false );
226 getRepositoryCommonValidator().validateManagedRepository( managedRepository );
227 triggerAuditEvent( managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
229 addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
230 managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
231 managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
232 managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
233 managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
234 managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
235 managedRepository.isSkipPackedIndexCreation(), managedRepository.isScanned(),
236 auditInformation, getArchivaConfiguration().getConfiguration() ) != null;
238 createIndexContext( managedRepository );
243 private ManagedRepositoryConfiguration addManagedRepository( String repoId, String layout, String name,
244 String location, boolean blockRedeployments,
245 boolean releasesIncluded, boolean snapshotsIncluded,
246 boolean stageRepoNeeded, String cronExpression,
247 String indexDir, int daysOlder, int retentionCount,
248 boolean deteleReleasedSnapshots, String description,
249 boolean skipPackedIndexCreation, boolean scanned,
250 AuditInformation auditInformation,
251 Configuration config )
252 throws RepositoryAdminException
255 ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
257 repository.setId( repoId );
258 repository.setBlockRedeployments( blockRedeployments );
259 repository.setReleases( releasesIncluded );
260 repository.setSnapshots( snapshotsIncluded );
261 repository.setScanned( scanned );
262 repository.setName( name );
263 repository.setLocation( getRepositoryCommonValidator().removeExpressions( location ) );
264 repository.setLayout( layout );
265 repository.setRefreshCronExpression( cronExpression );
266 repository.setIndexDir( indexDir );
267 repository.setDaysOlder( daysOlder );
268 repository.setRetentionCount( retentionCount );
269 repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
270 repository.setIndexDir( indexDir );
271 repository.setDescription( description );
272 repository.setSkipPackedIndexCreation( skipPackedIndexCreation );
273 repository.setStageRepoNeeded( stageRepoNeeded );
277 addRepository( repository, config );
278 addRepositoryRoles( repository.getId() );
280 if ( stageRepoNeeded )
282 ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
283 addRepository( stagingRepository, config );
284 addRepositoryRoles( stagingRepository.getId() );
285 triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
288 catch ( RoleManagerException e )
290 throw new RepositoryAdminException( "failed to add repository roles " + e.getMessage(), e );
292 catch ( IOException e )
294 throw new RepositoryAdminException( "failed to add repository " + e.getMessage(), e );
297 saveConfiguration( config );
299 //MRM-1342 Repository statistics report doesn't appear to be working correctly
300 //scan repository when adding of repository is successful
305 scanRepository( repoId, true );
308 // TODO need a better to define scanning or not for staged repo
309 if ( stageRepoNeeded && scanned )
311 ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
312 scanRepository( stagingRepository.getId(), true );
315 catch ( Exception e )
317 log.warn( new StringBuilder( "Unable to scan repository [" ).append( repoId ).append( "]: " ).append(
318 e.getMessage() ).toString(), e );
325 public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
326 boolean deleteContent )
327 throws RepositoryAdminException
329 Configuration config = getArchivaConfiguration().getConfiguration();
331 ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repositoryId );
333 if ( repository == null )
335 throw new RepositoryAdminException( "A repository with that id does not exist" );
338 triggerAuditEvent( repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation );
340 deleteManagedRepository( repository, deleteContent, config, false );
342 // stage repo exists ?
343 ManagedRepositoryConfiguration stagingRepository =
344 getArchivaConfiguration().getConfiguration().findManagedRepositoryById( repositoryId + STAGE_REPO_ID_END );
345 if ( stagingRepository != null )
347 // do not trigger event when deleting the staged one
348 deleteManagedRepository( stagingRepository, deleteContent, config, true );
353 saveConfiguration( config );
355 catch ( Exception e )
357 throw new RepositoryAdminException( "Error saving configuration for delete action" + e.getMessage(), e );
363 private Boolean deleteManagedRepository( ManagedRepositoryConfiguration repository, boolean deleteContent,
364 Configuration config, boolean stagedOne )
365 throws RepositoryAdminException
370 NexusIndexer nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
372 IndexingContext context = nexusIndexer.getIndexingContexts().get( repository.getId() );
373 if ( context != null )
375 // delete content only if directory exists
376 nexusIndexer.removeIndexingContext( context,
377 deleteContent && context.getIndexDirectoryFile().exists() );
380 catch ( PlexusSisuBridgeException e )
382 throw new RepositoryAdminException( e.getMessage(), e );
384 catch ( IOException e )
386 throw new RepositoryAdminException( e.getMessage(), e );
390 RepositorySession repositorySession = getRepositorySessionFactory().createSession();
393 MetadataRepository metadataRepository = repositorySession.getRepository();
394 metadataRepository.removeRepository( repository.getId() );
396 namespacesCache.remove( repository.getId() );
397 log.debug( "call repositoryStatisticsManager.deleteStatistics" );
398 getRepositoryStatisticsManager().deleteStatistics( metadataRepository, repository.getId() );
399 repositorySession.save();
401 catch ( MetadataRepositoryException e )
403 //throw new RepositoryAdminException( e.getMessage(), e );
404 log.warn( "skip error during removing repository from MetadataRepository:{}", e.getMessage(), e );
408 repositorySession.close();
411 config.removeManagedRepository( repository );
415 // TODO could be async ? as directory can be huge
416 File dir = new File( repository.getLocation() );
417 if ( !FileUtils.deleteQuietly( dir ) )
419 throw new RepositoryAdminException( "Cannot delete repository " + dir );
423 // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
424 List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>( config.getProxyConnectors() );
425 for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
427 if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
429 config.removeProxyConnector( proxyConnector );
433 Map<String, List<String>> repoToGroupMap = config.getRepositoryToGroupMap();
434 if ( repoToGroupMap != null )
436 if ( repoToGroupMap.containsKey( repository.getId() ) )
438 List<String> repoGroups = repoToGroupMap.get( repository.getId() );
439 for ( String repoGroup : repoGroups )
441 // copy to prevent UnsupportedOperationException
442 RepositoryGroupConfiguration repositoryGroupConfiguration =
443 config.findRepositoryGroupById( repoGroup );
444 List<String> repos = new ArrayList<>( repositoryGroupConfiguration.getRepositories() );
445 config.removeRepositoryGroup( repositoryGroupConfiguration );
446 repos.remove( repository.getId() );
447 repositoryGroupConfiguration.setRepositories( repos );
448 config.addRepositoryGroup( repositoryGroupConfiguration );
455 removeRepositoryRoles( repository );
457 catch ( RoleManagerException e )
459 throw new RepositoryAdminException(
460 "fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
463 saveConfiguration( config );
470 public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
471 AuditInformation auditInformation, boolean resetStats )
472 throws RepositoryAdminException
475 log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ", managedRepository, needStageRepo,
478 // Ensure that the fields are valid.
480 getRepositoryCommonValidator().basicValidation( managedRepository, true );
482 getRepositoryCommonValidator().validateManagedRepository( managedRepository );
484 Configuration configuration = getArchivaConfiguration().getConfiguration();
486 ManagedRepositoryConfiguration toremove = configuration.findManagedRepositoryById( managedRepository.getId() );
488 boolean updateIndexContext = false;
490 if ( toremove != null )
492 configuration.removeManagedRepository( toremove );
494 updateIndexContext = !StringUtils.equals( toremove.getIndexDir(), managedRepository.getIndexDirectory() );
497 ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( toremove );
499 // TODO remove content from old if path has changed !!!!!
501 if ( stagingRepository != null )
503 configuration.removeManagedRepository( stagingRepository );
506 ManagedRepositoryConfiguration managedRepositoryConfiguration =
507 addManagedRepository( managedRepository.getId(), managedRepository.getLayout(), managedRepository.getName(),
508 managedRepository.getLocation(), managedRepository.isBlockRedeployments(),
509 managedRepository.isReleases(), managedRepository.isSnapshots(), needStageRepo,
510 managedRepository.getCronExpression(), managedRepository.getIndexDirectory(),
511 managedRepository.getDaysOlder(), managedRepository.getRetentionCount(),
512 managedRepository.isDeleteReleasedSnapshots(), managedRepository.getDescription(),
513 managedRepository.isSkipPackedIndexCreation(), managedRepository.isScanned(),
514 auditInformation, getArchivaConfiguration().getConfiguration() );
516 // Save the repository configuration.
517 RepositorySession repositorySession = getRepositorySessionFactory().createSession();
521 triggerAuditEvent( managedRepositoryConfiguration.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
524 saveConfiguration( this.getArchivaConfiguration().getConfiguration() );
527 log.debug( "call repositoryStatisticsManager.deleteStatistics" );
528 getRepositoryStatisticsManager().deleteStatistics( repositorySession.getRepository(),
529 managedRepositoryConfiguration.getId() );
530 repositorySession.save();
534 catch ( MetadataRepositoryException e )
536 throw new RepositoryAdminException( e.getMessage(), e );
540 repositorySession.close();
543 if ( updateIndexContext )
547 IndexingContext indexingContext = indexer.getIndexingContexts().get( managedRepository.getId() );
548 if ( indexingContext != null )
550 indexer.removeIndexingContext( indexingContext, true );
553 // delete directory too as only content is deleted
554 File indexDirectory = indexingContext.getIndexDirectoryFile();
555 FileUtils.deleteDirectory( indexDirectory );
557 createIndexContext( managedRepository );
559 catch ( IOException e )
561 throw new RepositoryAdminException( e.getMessage(), e );
568 //--------------------------
570 //--------------------------
573 protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
574 throws RepositoryAdminException, IOException
576 // Normalize the path
577 File file = new File( repository.getLocation() );
578 if ( !file.isAbsolute() )
580 // add appserver.base/repositories
581 file = new File( getRegistry().getString( "appserver.base" ) + File.separatorChar + "repositories",
582 repository.getLocation() );
584 repository.setLocation( file.getCanonicalPath() );
585 if ( !file.exists() )
589 if ( !file.exists() || !file.isDirectory() )
591 throw new RepositoryAdminException(
592 "Unable to add repository - no write access, can not create the root directory: " + file );
595 configuration.addManagedRepository( repository );
600 public IndexingContext createIndexContext( ManagedRepository repository )
601 throws RepositoryAdminException
604 IndexingContext context = indexer.getIndexingContexts().get( repository.getId() );
606 if ( context != null )
608 log.debug( "skip creating repository indexingContent with id {} as already exists", repository.getId() );
612 // take care first about repository location as can be relative
613 File repositoryDirectory = new File( repository.getLocation() );
615 if ( !repositoryDirectory.isAbsolute() )
617 repositoryDirectory =
618 new File( getRegistry().getString( "appserver.base" ) + File.separatorChar + "repositories",
619 repository.getLocation() );
622 if ( !repositoryDirectory.exists() )
624 repositoryDirectory.mkdirs();
630 String indexDir = repository.getIndexDirectory();
631 //File managedRepository = new File( repository.getLocation() );
633 File indexDirectory = null;
634 if ( StringUtils.isNotBlank( indexDir ) )
636 indexDirectory = new File( repository.getIndexDirectory() );
637 // not absolute so create it in repository directory
638 if ( !indexDirectory.isAbsolute() )
640 indexDirectory = new File( repositoryDirectory, repository.getIndexDirectory() );
642 repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
646 indexDirectory = new File( repositoryDirectory, ".indexer" );
647 if ( !repositoryDirectory.isAbsolute() )
649 indexDirectory = new File( repositoryDirectory, ".indexer" );
651 repository.setIndexDirectory( indexDirectory.getAbsolutePath() );
654 if ( !indexDirectory.exists() )
656 indexDirectory.mkdirs();
659 context = indexer.getIndexingContexts().get( repository.getId() );
661 if ( context == null )
663 context = indexer.addIndexingContext( repository.getId(), repository.getId(), repositoryDirectory,
665 repositoryDirectory.toURI().toURL().toExternalForm(),
666 indexDirectory.toURI().toURL().toString(), indexCreators );
668 context.setSearchable( repository.isScanned() );
672 catch ( MalformedURLException e )
674 throw new RepositoryAdminException( e.getMessage(), e );
676 catch ( IOException e )
678 throw new RepositoryAdminException( e.getMessage(), e );
680 catch ( UnsupportedExistingLuceneIndexException e )
682 throw new RepositoryAdminException( e.getMessage(), e );
686 private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository )
688 ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
689 stagingRepository.setId( repository.getId() + STAGE_REPO_ID_END );
690 stagingRepository.setLayout( repository.getLayout() );
691 stagingRepository.setName( repository.getName() + STAGE_REPO_ID_END );
692 stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
693 stagingRepository.setDaysOlder( repository.getDaysOlder() );
694 stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
696 String path = repository.getLocation();
697 int lastIndex = path.replace( '\\', '/' ).lastIndexOf( '/' );
698 stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
700 if ( StringUtils.isNotBlank( repository.getIndexDir() ) )
702 File indexDir = new File( repository.getIndexDir() );
703 // in case of absolute dir do not use the same
704 if ( indexDir.isAbsolute() )
706 stagingRepository.setIndexDir( stagingRepository.getLocation() + "/.index" );
710 stagingRepository.setIndexDir( repository.getIndexDir() );
713 stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
714 stagingRepository.setReleases( repository.isReleases() );
715 stagingRepository.setRetentionCount( repository.getRetentionCount() );
716 stagingRepository.setScanned( repository.isScanned() );
717 stagingRepository.setSnapshots( repository.isSnapshots() );
718 stagingRepository.setSkipPackedIndexCreation( repository.isSkipPackedIndexCreation() );
719 // do not duplicate description
720 //stagingRepository.getDescription("")
721 return stagingRepository;
724 public Boolean scanRepository( String repositoryId, boolean fullScan )
726 if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
728 log.info( "scanning of repository with id {} already scheduled", repositoryId );
730 RepositoryTask task = new RepositoryTask();
731 task.setRepositoryId( repositoryId );
732 task.setScanAll( fullScan );
735 getRepositoryTaskScheduler().queueTask( task );
737 catch ( TaskQueueException e )
739 log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
746 private void addRepositoryRoles( String repoId )
747 throws RoleManagerException
749 // TODO: double check these are configured on start up
750 // TODO: belongs in the business logic
752 if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
754 getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
757 if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
759 getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
763 protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
764 throws RoleManagerException
766 String repoId = existingRepository.getId();
768 if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
770 getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
773 if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
775 getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
778 log.debug( "removed user roles associated with repository {}", repoId );
781 //--------------------------
783 //--------------------------
786 public RoleManager getRoleManager()
791 public void setRoleManager( RoleManager roleManager )
793 this.roleManager = roleManager;
796 public RepositoryStatisticsManager getRepositoryStatisticsManager()
798 return repositoryStatisticsManager;
801 public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
803 this.repositoryStatisticsManager = repositoryStatisticsManager;
806 public RepositorySessionFactory getRepositorySessionFactory()
808 return repositorySessionFactory;
811 public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
813 this.repositorySessionFactory = repositorySessionFactory;
817 public RepositoryArchivaTaskScheduler getRepositoryTaskScheduler()
819 return repositoryTaskScheduler;
822 public void setRepositoryTaskScheduler( RepositoryArchivaTaskScheduler repositoryTaskScheduler )
824 this.repositoryTaskScheduler = repositoryTaskScheduler;
827 public PlexusSisuBridge getPlexusSisuBridge()
829 return plexusSisuBridge;
832 public void setPlexusSisuBridge( PlexusSisuBridge plexusSisuBridge )
834 this.plexusSisuBridge = plexusSisuBridge;
837 public MavenIndexerUtils getMavenIndexerUtils()
839 return mavenIndexerUtils;
842 public void setMavenIndexerUtils( MavenIndexerUtils mavenIndexerUtils )
844 this.mavenIndexerUtils = mavenIndexerUtils;
847 public NexusIndexer getIndexer()
852 public void setIndexer( NexusIndexer indexer )
854 this.indexer = indexer;
857 public List<? extends IndexCreator> getIndexCreators()
859 return indexCreators;
862 public void setIndexCreators( List<? extends IndexCreator> indexCreators )
864 this.indexCreators = indexCreators;