]> source.dussan.org Git - archiva.git/blob
9e47f1004e7bab331908dd5b133609dba198b3bf
[archiva.git] /
1 package org.apache.archiva.admin.repository.managed;
2 /*
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
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
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
18  * under the License.
19  */
20
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.configuration.*;
27 import org.apache.archiva.indexer.ArchivaIndexManager;
28 import org.apache.archiva.indexer.IndexManagerFactory;
29 import org.apache.archiva.indexer.IndexUpdateFailedException;
30 import org.apache.archiva.metadata.model.facets.AuditEvent;
31 import org.apache.archiva.metadata.repository.MetadataRepository;
32 import org.apache.archiva.metadata.repository.MetadataRepositoryException;
33 import org.apache.archiva.metadata.repository.RepositorySession;
34 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
35 import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager;
36 import org.apache.archiva.redback.components.cache.Cache;
37 import org.apache.archiva.redback.components.registry.RegistryException;
38 import org.apache.archiva.redback.components.taskqueue.TaskQueueException;
39 import org.apache.archiva.redback.role.RoleManager;
40 import org.apache.archiva.redback.role.RoleManagerException;
41 import org.apache.archiva.repository.ReleaseScheme;
42 import org.apache.archiva.repository.RepositoryException;
43 import org.apache.archiva.repository.RepositoryRegistry;
44 import org.apache.archiva.repository.features.ArtifactCleanupFeature;
45 import org.apache.archiva.repository.features.IndexCreationFeature;
46 import org.apache.archiva.repository.features.StagingRepositoryFeature;
47 import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
48 import org.apache.archiva.scheduler.repository.model.RepositoryTask;
49 import org.apache.archiva.security.common.ArchivaRoleConstants;
50 import org.apache.commons.lang.StringUtils;
51 import org.slf4j.Logger;
52 import org.slf4j.LoggerFactory;
53 import org.springframework.stereotype.Service;
54
55 import javax.annotation.PostConstruct;
56 import javax.annotation.PreDestroy;
57 import javax.inject.Inject;
58 import javax.inject.Named;
59 import java.io.IOException;
60 import java.nio.file.Path;
61 import java.nio.file.Paths;
62 import java.util.ArrayList;
63 import java.util.Collection;
64 import java.util.List;
65 import java.util.Map;
66 import java.util.stream.Collectors;
67
68 /**
69  * FIXME review the staging mechanism to have a per user session one
70  *
71  * @author Olivier Lamy
72  */
73 @Service("managedRepositoryAdmin#default")
74 public class DefaultManagedRepositoryAdmin
75     extends AbstractRepositoryAdmin
76     implements ManagedRepositoryAdmin
77 {
78
79     private Logger log = LoggerFactory.getLogger( getClass() );
80
81     public static final String STAGE_REPO_ID_END = "-stage";
82
83
84     @Inject
85     private RepositoryRegistry repositoryRegistry;
86
87     @Inject
88     @Named(value = "archivaTaskScheduler#repository")
89     private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
90
91     /**
92      * FIXME: this could be multiple implementations and needs to be configured.
93      */
94     @Inject
95     private RepositorySessionFactory repositorySessionFactory;
96
97     @Inject
98     private RepositoryStatisticsManager repositoryStatisticsManager;
99
100     @Inject
101     protected RoleManager roleManager;
102
103     @Inject
104     @Named(value = "cache#namespaces")
105     private Cache<String, Collection<String>> namespacesCache;
106
107     @Inject
108     private IndexManagerFactory indexManagerFactory;
109
110
111
112
113     @PostConstruct
114     public void initialize()
115         throws RepositoryAdminException, RoleManagerException
116     {
117         // initialize index context on start and check roles here
118         for ( ManagedRepository managedRepository : getManagedRepositories() )
119         {
120             log.debug("Initializating {}", managedRepository.getId());
121             addRepositoryRoles( managedRepository.getId() );
122
123         }
124     }
125
126     @PreDestroy
127     public void shutdown()
128         throws RepositoryAdminException
129     {
130     }
131
132     /*
133      * Conversion between the repository from the registry and the serialized DTO for the admin API
134      */
135     private ManagedRepository convertRepo( org.apache.archiva.repository.ManagedRepository repo ) {
136         if (repo==null) {
137             return null;
138         }
139         ManagedRepository adminRepo = new ManagedRepository( getArchivaConfiguration().getDefaultLocale() );
140         setBaseRepoAttributes( adminRepo, repo );
141         adminRepo.setLocation( convertUriToString( repo.getLocation()) );
142         adminRepo.setReleases(repo.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ));
143         adminRepo.setSnapshots( repo.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) );
144         adminRepo.setBlockRedeployments( repo.blocksRedeployments() );
145         adminRepo.setCronExpression( repo.getSchedulingDefinition() );
146         if (repo.supportsFeature( IndexCreationFeature.class )) {
147             IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get();
148             adminRepo.setIndexDirectory(convertUriToString( icf.getIndexPath() ));
149             adminRepo.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation() );
150         }
151         adminRepo.setScanned( repo.isScanned() );
152         if (repo.supportsFeature( ArtifactCleanupFeature.class) ) {
153             ArtifactCleanupFeature acf = repo.getFeature( ArtifactCleanupFeature.class ).get();
154             adminRepo.setRetentionPeriod( acf.getRetentionPeriod().getDays() );
155             adminRepo.setRetentionCount( acf.getRetentionCount() );
156             adminRepo.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots() );
157
158         }
159         if (repo.supportsFeature( StagingRepositoryFeature.class )) {
160             StagingRepositoryFeature stf = repo.getFeature( StagingRepositoryFeature.class ).get();
161             adminRepo.setStageRepoNeeded( stf.isStageRepoNeeded() );
162             if (stf.getStagingRepository()!=null) {
163                 adminRepo.setStagingRepository( convertRepo( stf.getStagingRepository() ) );
164             }
165         }
166         return adminRepo;
167     }
168
169     private ManagedRepositoryConfiguration getRepositoryConfiguration(ManagedRepository repo) {
170         ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
171         setBaseRepoAttributes( repoConfig, repo );
172         repoConfig.setBlockRedeployments( repo.isBlockRedeployments( ) );
173         repoConfig.setReleases( repo.isReleases() );
174         repoConfig.setSnapshots( repo.isSnapshots() );
175         repoConfig.setScanned( repo.isScanned() );
176         repoConfig.setLocation( getRepositoryCommonValidator().removeExpressions( repo.getLocation() ) );
177         repoConfig.setRefreshCronExpression( repo.getCronExpression() );
178         repoConfig.setRetentionPeriod( repo.getRetentionPeriod() );
179         repoConfig.setRetentionCount( repo.getRetentionCount());
180         repoConfig.setDeleteReleasedSnapshots( repo.isDeleteReleasedSnapshots() );
181         repoConfig.setSkipPackedIndexCreation( repo.isSkipPackedIndexCreation());
182         repoConfig.setStageRepoNeeded( repo.isStageRepoNeeded() );
183         return repoConfig;
184     }
185
186     @Override
187     public List<ManagedRepository> getManagedRepositories()
188         throws RepositoryAdminException
189     {
190
191         return repositoryRegistry.getManagedRepositories().stream().map( rep -> this.convertRepo( rep ) ).collect( Collectors.toList());
192     }
193
194     @Override
195     public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
196         throws RepositoryAdminException
197     {
198         return repositoryRegistry.getManagedRepositories().stream().collect( Collectors.toMap( e -> e.getId(), e -> convertRepo( e ) ) );
199     }
200
201     @Override
202     public ManagedRepository getManagedRepository( String repositoryId )
203         throws RepositoryAdminException
204     {
205         return convertRepo( repositoryRegistry.getManagedRepository( repositoryId ) );
206     }
207
208     @Override
209     public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
210                                          AuditInformation auditInformation )
211         throws RepositoryAdminException
212     {
213         log.debug("addManagedRepository {}, {}, {}", managedRepository.getId(), needStageRepo, auditInformation);
214
215         getRepositoryCommonValidator().basicValidation( managedRepository, false );
216         getRepositoryCommonValidator().validateManagedRepository( managedRepository );
217         triggerAuditEvent( managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
218         ManagedRepositoryConfiguration repoConfig = getRepositoryConfiguration( managedRepository );
219         if (needStageRepo) {
220             repoConfig.setStageRepoNeeded( true );
221         }
222         Configuration configuration = getArchivaConfiguration().getConfiguration();
223         try
224         {
225             org.apache.archiva.repository.ManagedRepository newRepo = repositoryRegistry.putRepository( repoConfig, configuration );
226             log.debug("Added new repository {}", newRepo.getId());
227             org.apache.archiva.repository.ManagedRepository stagingRepo = null;
228             addRepositoryRoles( newRepo.getId() );
229             if ( newRepo.supportsFeature( StagingRepositoryFeature.class )) {
230                 StagingRepositoryFeature stf = newRepo.getFeature( StagingRepositoryFeature.class ).get();
231                 stagingRepo = stf.getStagingRepository();
232                 if (stf.isStageRepoNeeded() && stagingRepo != null) {
233                     addRepositoryRoles( stagingRepo.getId() );
234                     triggerAuditEvent( stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
235                 }
236             }
237             saveConfiguration( configuration );
238             //MRM-1342 Repository statistics report doesn't appear to be working correctly
239             //scan repository when adding of repository is successful
240             try
241             {
242                 if ( newRepo.isScanned())
243                 {
244                     scanRepository( newRepo.getId(), true );
245                 }
246
247                 if ( stagingRepo!=null && stagingRepo.isScanned() )
248                 {
249                     scanRepository( stagingRepo.getId(), true );
250                 }
251             }
252             catch ( Exception e )
253             {
254                 log.warn("Unable to scan repository [{}]: {}", newRepo.getId(), e.getMessage(), e);
255             }
256         }
257         catch ( RepositoryException e )
258         {
259             log.error("Could not add managed repository {}"+managedRepository);
260             throw new RepositoryAdminException( "Could not add repository "+e.getMessage() );
261         }
262         catch ( RoleManagerException e )
263         {
264             log.error("Could not add repository roles for repository [{}]: {}", managedRepository.getId(), e.getMessage(), e);
265             throw new RepositoryAdminException( "Could not add roles to repository "+e.getMessage() );
266         }
267         return Boolean.TRUE;
268
269     }
270
271
272
273     @Override
274     public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
275                                             boolean deleteContent )
276         throws RepositoryAdminException
277     {
278         Configuration config = getArchivaConfiguration().getConfiguration();
279         ManagedRepositoryConfiguration repoConfig=config.findManagedRepositoryById( repositoryId );
280         if (repoConfig!=null) {
281
282             log.debug("Repo location " + repoConfig.getLocation());
283
284             org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository(repositoryId);
285             org.apache.archiva.repository.ManagedRepository stagingRepository = null;
286             if (repo != null) {
287                 try {
288                     if (repo.supportsFeature(StagingRepositoryFeature.class)) {
289                         stagingRepository = repo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository();
290                     }
291                     repositoryRegistry.removeRepository(repo, config);
292                 } catch (RepositoryException e) {
293                     log.error("Removal of repository {} failed: {}", repositoryId, e.getMessage(), e);
294                     throw new RepositoryAdminException("Removal of repository " + repositoryId + " failed.");
295                 }
296             } else {
297                 throw new RepositoryAdminException("A repository with that id does not exist");
298             }
299
300             triggerAuditEvent(repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation);
301             if (repoConfig != null) {
302                 deleteManagedRepository(repoConfig, deleteContent, config, false);
303             }
304
305
306             // stage repo exists ?
307             if (stagingRepository != null) {
308                 // do not trigger event when deleting the staged one
309                 ManagedRepositoryConfiguration stagingRepositoryConfig = config.findManagedRepositoryById(stagingRepository.getId());
310                 try {
311                     repositoryRegistry.removeRepository(stagingRepository);
312                     if (stagingRepositoryConfig != null) {
313                         deleteManagedRepository(stagingRepositoryConfig, deleteContent, config, true);
314                     }
315                 } catch (RepositoryException e) {
316                     log.error("Removal of staging repository {} failed: {}", stagingRepository.getId(), e.getMessage(), e);
317                 }
318             }
319
320             try {
321                 saveConfiguration(config);
322             } catch (Exception e) {
323                 throw new RepositoryAdminException("Error saving configuration for delete action" + e.getMessage(), e);
324             }
325
326             return Boolean.TRUE;
327         } else {
328             return Boolean.FALSE;
329         }
330     }
331
332     private Boolean deleteManagedRepository( ManagedRepositoryConfiguration repository, boolean deleteContent,
333                                              Configuration config, boolean stagedOne )
334         throws RepositoryAdminException
335     {
336
337         if ( !stagedOne )
338         {
339             RepositorySession repositorySession = getRepositorySessionFactory().createSession();
340             try
341             {
342                 MetadataRepository metadataRepository = repositorySession.getRepository();
343                 metadataRepository.removeRepository( repository.getId() );
344                 //invalidate cache
345                 namespacesCache.remove( repository.getId() );
346                 log.debug( "call repositoryStatisticsManager.deleteStatistics" );
347                 getRepositoryStatisticsManager().deleteStatistics( metadataRepository, repository.getId() );
348                 repositorySession.save();
349             }
350             catch ( MetadataRepositoryException e )
351             {
352                 //throw new RepositoryAdminException( e.getMessage(), e );
353                 log.warn( "skip error during removing repository from MetadataRepository:{}", e.getMessage(), e );
354             }
355             finally
356             {
357                 repositorySession.close();
358             }
359         }
360
361         if ( deleteContent )
362         {
363             // TODO could be async ? as directory can be huge
364             Path dir = Paths.get( repository.getLocation() );
365             org.apache.archiva.common.utils.FileUtils.deleteQuietly( dir );
366         }
367
368         // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
369         List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>( config.getProxyConnectors() );
370         for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
371         {
372             if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
373             {
374                 config.removeProxyConnector( proxyConnector );
375             }
376         }
377
378         Map<String, List<String>> repoToGroupMap = config.getRepositoryToGroupMap();
379         if ( repoToGroupMap != null )
380         {
381             if ( repoToGroupMap.containsKey( repository.getId() ) )
382             {
383                 List<String> repoGroups = repoToGroupMap.get( repository.getId() );
384                 for ( String repoGroup : repoGroups )
385                 {
386                     // copy to prevent UnsupportedOperationException
387                     RepositoryGroupConfiguration repositoryGroupConfiguration =
388                         config.findRepositoryGroupById( repoGroup );
389                     List<String> repos = new ArrayList<>( repositoryGroupConfiguration.getRepositories() );
390                     config.removeRepositoryGroup( repositoryGroupConfiguration );
391                     repos.remove( repository.getId() );
392                     repositoryGroupConfiguration.setRepositories( repos );
393                     config.addRepositoryGroup( repositoryGroupConfiguration );
394                 }
395             }
396         }
397
398         try
399         {
400             removeRepositoryRoles( repository );
401         }
402         catch ( RoleManagerException e )
403         {
404             throw new RepositoryAdminException(
405                 "fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
406         }
407
408         try {
409             final RepositoryRegistry reg = getRepositoryRegistry();
410             if (reg.getManagedRepository(repository.getId())!=null) {
411                 reg.removeRepository(reg.getManagedRepository(repository.getId()));
412             }
413         } catch (RepositoryException e) {
414             throw new RepositoryAdminException("Removal of repository "+repository.getId()+ " failed: "+e.getMessage());
415         }
416
417         saveConfiguration( config );
418
419         return Boolean.TRUE;
420     }
421
422     ArchivaIndexManager getIndexManager(ManagedRepository managedRepository) {
423         org.apache.archiva.repository.ManagedRepository repo = getRepositoryRegistry().getManagedRepository(managedRepository.getId());
424         return indexManagerFactory.getIndexManager(repo.getType());
425     }
426
427     @Override
428     public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
429                                             AuditInformation auditInformation, boolean resetStats )
430         throws RepositoryAdminException
431     {
432
433         log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ", managedRepository, needStageRepo,
434                    resetStats );
435
436         // Ensure that the fields are valid.
437
438         getRepositoryCommonValidator().basicValidation( managedRepository, true );
439
440         getRepositoryCommonValidator().validateManagedRepository( managedRepository );
441
442         Configuration configuration = getArchivaConfiguration().getConfiguration();
443
444         ManagedRepositoryConfiguration updatedRepoConfig = getRepositoryConfiguration( managedRepository );
445         updatedRepoConfig.setStageRepoNeeded( needStageRepo );
446
447         org.apache.archiva.repository.ManagedRepository oldRepo = repositoryRegistry.getManagedRepository( managedRepository.getId( ) );
448         boolean stagingExists = false;
449         if (oldRepo.supportsFeature( StagingRepositoryFeature.class ) ){
450             stagingExists = oldRepo.getFeature( StagingRepositoryFeature.class ).get().getStagingRepository() != null;
451         }
452         boolean updateIndexContext = !StringUtils.equals( updatedRepoConfig.getIndexDir(), managedRepository.getIndexDirectory() );
453         org.apache.archiva.repository.ManagedRepository newRepo;
454         // TODO remove content from old if path has changed !!!!!
455         try
456         {
457             newRepo = repositoryRegistry.putRepository( updatedRepoConfig, configuration );
458             if (newRepo.supportsFeature( StagingRepositoryFeature.class )) {
459                 org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).get( ).getStagingRepository( );
460                 if (stagingRepo!=null && !stagingExists)
461                 {
462                     triggerAuditEvent( stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
463                     addRepositoryRoles( stagingRepo.getId( ) );
464                 }
465             }
466
467
468         }
469         catch ( RepositoryException e )
470         {
471             log.error("Could not update repository {}: {}", managedRepository.getId(), e.getMessage(), e);
472             throw new RepositoryAdminException( "Could not update repository "+managedRepository.getId());
473         }
474         catch ( RoleManagerException e ) {
475             log.error("Error during role update of stage repo {}", managedRepository.getId(), e);
476             throw new RepositoryAdminException( "Could not update repository "+managedRepository.getId());
477         }
478         triggerAuditEvent( managedRepository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
479             auditInformation );
480         try
481         {
482             getArchivaConfiguration().save(configuration);
483         }
484         catch ( RegistryException | IndeterminateConfigurationException e )
485         {
486             log.error("Could not save repository configuration: {}", e.getMessage(), e);
487             throw new RepositoryAdminException( "Could not save repository configuration: "+e.getMessage() );
488         }
489
490         // Save the repository configuration.
491         RepositorySession repositorySession = getRepositorySessionFactory().createSession();
492
493         try
494         {
495
496             if ( resetStats )
497             {
498                 log.debug( "call repositoryStatisticsManager.deleteStatistics" );
499                 getRepositoryStatisticsManager().deleteStatistics( repositorySession.getRepository(),
500                                                                    managedRepository.getId() );
501                 repositorySession.save();
502             }
503
504         }
505         catch ( MetadataRepositoryException e )
506         {
507             throw new RepositoryAdminException( e.getMessage(), e );
508         }
509         finally
510         {
511             repositorySession.close();
512         }
513
514         if ( updateIndexContext )
515         {
516             try
517             {
518
519                 repositoryRegistry.resetIndexingContext(newRepo);
520             } catch (IndexUpdateFailedException e) {
521                 e.printStackTrace();
522             }
523         }
524
525         return true;
526     }
527
528     //--------------------------
529     // utils methods
530     //--------------------------
531
532
533     protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
534         throws RepositoryAdminException, IOException
535     {
536         try
537         {
538             getRepositoryRegistry().putRepository( repository, configuration );
539         }
540         catch ( RepositoryException e )
541         {
542             throw new RepositoryAdminException( "Could not add the repository to the registry. Cause: "+e.getMessage() );
543         }
544
545     }
546
547
548     public Boolean scanRepository( String repositoryId, boolean fullScan )
549     {
550         if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
551         {
552             log.info( "scanning of repository with id {} already scheduled", repositoryId );
553         }
554         RepositoryTask task = new RepositoryTask();
555         task.setRepositoryId( repositoryId );
556         task.setScanAll( fullScan );
557         try
558         {
559             getRepositoryTaskScheduler().queueTask( task );
560         }
561         catch ( TaskQueueException e )
562         {
563             log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
564             return false;
565         }
566         return true;
567     }
568
569
570     private void addRepositoryRoles( String repoId )
571         throws RoleManagerException
572     {
573         // TODO: double check these are configured on start up
574         // TODO: belongs in the business logic
575
576         if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
577         {
578             getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
579         }
580
581         if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
582         {
583             getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
584         }
585     }
586
587     protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
588         throws RoleManagerException
589     {
590         String repoId = existingRepository.getId();
591
592         if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
593         {
594             getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
595         }
596
597         if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
598         {
599             getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
600         }
601
602         log.debug( "removed user roles associated with repository {}", repoId );
603     }
604
605     //--------------------------
606     // setters/getters
607     //--------------------------
608
609
610     public RoleManager getRoleManager()
611     {
612         return roleManager;
613     }
614
615     public void setRoleManager( RoleManager roleManager )
616     {
617         this.roleManager = roleManager;
618     }
619
620     public RepositoryStatisticsManager getRepositoryStatisticsManager()
621     {
622         return repositoryStatisticsManager;
623     }
624
625     public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
626     {
627         this.repositoryStatisticsManager = repositoryStatisticsManager;
628     }
629
630     public RepositorySessionFactory getRepositorySessionFactory()
631     {
632         return repositorySessionFactory;
633     }
634
635     public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
636     {
637         this.repositorySessionFactory = repositorySessionFactory;
638     }
639
640
641     public RepositoryArchivaTaskScheduler getRepositoryTaskScheduler()
642     {
643         return repositoryTaskScheduler;
644     }
645
646     public void setRepositoryTaskScheduler( RepositoryArchivaTaskScheduler repositoryTaskScheduler )
647     {
648         this.repositoryTaskScheduler = repositoryTaskScheduler;
649     }
650
651
652     public RepositoryRegistry getRepositoryRegistry( )
653     {
654         return repositoryRegistry;
655     }
656
657     public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )
658     {
659         this.repositoryRegistry = repositoryRegistry;
660     }
661 }