This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.admin.repository.managed;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.archiva.admin.model.AuditInformation;
022import org.apache.archiva.admin.model.RepositoryAdminException;
023import org.apache.archiva.admin.model.beans.ManagedRepository;
024import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
025import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
026import org.apache.archiva.configuration.Configuration;
027import org.apache.archiva.configuration.IndeterminateConfigurationException;
028import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
029import org.apache.archiva.configuration.ProxyConnectorConfiguration;
030import org.apache.archiva.configuration.RepositoryGroupConfiguration;
031import org.apache.archiva.indexer.ArchivaIndexManager;
032import org.apache.archiva.indexer.IndexManagerFactory;
033import org.apache.archiva.indexer.IndexUpdateFailedException;
034import org.apache.archiva.metadata.model.facets.AuditEvent;
035import org.apache.archiva.metadata.repository.*;
036import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager;
037import org.apache.archiva.components.cache.Cache;
038import org.apache.archiva.components.registry.RegistryException;
039import org.apache.archiva.components.taskqueue.TaskQueueException;
040import org.apache.archiva.redback.role.RoleManager;
041import org.apache.archiva.redback.role.RoleManagerException;
042import org.apache.archiva.repository.ReleaseScheme;
043import org.apache.archiva.repository.RepositoryException;
044import org.apache.archiva.repository.RepositoryRegistry;
045import org.apache.archiva.repository.features.ArtifactCleanupFeature;
046import org.apache.archiva.repository.features.IndexCreationFeature;
047import org.apache.archiva.repository.features.StagingRepositoryFeature;
048import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
049import org.apache.archiva.scheduler.repository.model.RepositoryTask;
050import org.apache.archiva.security.common.ArchivaRoleConstants;
051import org.apache.commons.lang3.StringUtils;
052import org.slf4j.Logger;
053import org.slf4j.LoggerFactory;
054import org.springframework.stereotype.Service;
055
056import javax.annotation.PostConstruct;
057import javax.annotation.PreDestroy;
058import javax.inject.Inject;
059import javax.inject.Named;
060import java.io.IOException;
061import java.nio.file.Path;
062import java.nio.file.Paths;
063import java.util.ArrayList;
064import java.util.Collection;
065import java.util.List;
066import java.util.Map;
067import java.util.stream.Collectors;
068
069/**
070 * FIXME review the staging mechanism to have a per user session one
071 *
072 * @author Olivier Lamy
073 */
074@Service("managedRepositoryAdmin#default")
075public class DefaultManagedRepositoryAdmin
076    extends AbstractRepositoryAdmin
077    implements ManagedRepositoryAdmin
078{
079
080    private Logger log = LoggerFactory.getLogger( getClass() );
081
082    public static final String STAGE_REPO_ID_END = "-stage";
083
084
085    @Inject
086    private RepositoryRegistry repositoryRegistry;
087
088    @Inject
089    @Named(value = "archivaTaskScheduler#repository")
090    private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
091
092    /**
093     * FIXME: this could be multiple implementations and needs to be configured.
094     */
095    @Inject
096    private RepositorySessionFactory repositorySessionFactory;
097
098    @Inject
099    private RepositoryStatisticsManager repositoryStatisticsManager;
100
101    @Inject
102    protected RoleManager roleManager;
103
104    @Inject
105    @Named(value = "cache#namespaces")
106    private Cache<String, Collection<String>> namespacesCache;
107
108    @Inject
109    private IndexManagerFactory indexManagerFactory;
110
111
112
113
114    @PostConstruct
115    public void initialize()
116        throws RepositoryAdminException, RoleManagerException
117    {
118        // initialize index context on start and check roles here
119        for ( ManagedRepository managedRepository : getManagedRepositories() )
120        {
121            log.debug("Initializating {}", managedRepository.getId());
122            addRepositoryRoles( managedRepository.getId() );
123
124        }
125    }
126
127    @PreDestroy
128    public void shutdown()
129        throws RepositoryAdminException
130    {
131    }
132
133    /*
134     * Conversion between the repository from the registry and the serialized DTO for the admin API
135     */
136    private ManagedRepository convertRepo( org.apache.archiva.repository.ManagedRepository repo ) {
137        if (repo==null) {
138            return null;
139        }
140        ManagedRepository adminRepo = new ManagedRepository( getArchivaConfiguration().getDefaultLocale() );
141        setBaseRepoAttributes( adminRepo, repo );
142        adminRepo.setLocation( convertUriToString( repo.getLocation()) );
143        adminRepo.setReleases(repo.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ));
144        adminRepo.setSnapshots( repo.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) );
145        adminRepo.setBlockRedeployments( repo.blocksRedeployments() );
146        adminRepo.setCronExpression( repo.getSchedulingDefinition() );
147        if (repo.supportsFeature( IndexCreationFeature.class )) {
148            IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get();
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
184        return repoConfig;
185    }
186
187    @Override
188    public List<ManagedRepository> getManagedRepositories()
189        throws RepositoryAdminException
190    {
191
192        return repositoryRegistry.getManagedRepositories().stream().map( rep -> this.convertRepo( rep ) ).collect( Collectors.toList());
193    }
194
195    @Override
196    public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
197        throws RepositoryAdminException
198    {
199        return repositoryRegistry.getManagedRepositories().stream().collect( Collectors.toMap( e -> e.getId(), e -> convertRepo( e ) ) );
200    }
201
202    @Override
203    public ManagedRepository getManagedRepository( String repositoryId )
204        throws RepositoryAdminException
205    {
206        return convertRepo( repositoryRegistry.getManagedRepository( repositoryId ) );
207    }
208
209    @Override
210    public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
211                                         AuditInformation auditInformation )
212        throws RepositoryAdminException
213    {
214        log.debug("addManagedRepository {}, {}, {}", managedRepository.getId(), needStageRepo, auditInformation);
215
216        getRepositoryCommonValidator().basicValidation( managedRepository, false );
217        getRepositoryCommonValidator().validateManagedRepository( managedRepository );
218        triggerAuditEvent( managedRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
219        ManagedRepositoryConfiguration repoConfig = getRepositoryConfiguration( managedRepository );
220        if (needStageRepo) {
221            repoConfig.setStageRepoNeeded( true );
222        }
223        Configuration configuration = getArchivaConfiguration().getConfiguration();
224        try
225        {
226            org.apache.archiva.repository.ManagedRepository newRepo = repositoryRegistry.putRepository( repoConfig, configuration );
227            log.debug("Added new repository {}", newRepo.getId());
228            org.apache.archiva.repository.ManagedRepository stagingRepo = null;
229            addRepositoryRoles( newRepo.getId() );
230            if ( newRepo.supportsFeature( StagingRepositoryFeature.class )) {
231                StagingRepositoryFeature stf = newRepo.getFeature( StagingRepositoryFeature.class ).get();
232                stagingRepo = stf.getStagingRepository();
233                if (stf.isStageRepoNeeded() && stagingRepo != null) {
234                    addRepositoryRoles( stagingRepo.getId() );
235                    triggerAuditEvent( stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
236                }
237            }
238            saveConfiguration( configuration );
239            //MRM-1342 Repository statistics report doesn't appear to be working correctly
240            //scan repository when adding of repository is successful
241            try
242            {
243                if ( newRepo.isScanned())
244                {
245                    scanRepository( newRepo.getId(), true );
246                }
247
248                if ( stagingRepo!=null && stagingRepo.isScanned() )
249                {
250                    scanRepository( stagingRepo.getId(), true );
251                }
252            }
253            catch ( Exception e )
254            {
255                log.warn("Unable to scan repository [{}]: {}", newRepo.getId(), e.getMessage(), e);
256            }
257        }
258        catch ( RepositoryException e )
259        {
260            log.error("Could not add managed repository {}"+managedRepository);
261            throw new RepositoryAdminException( "Could not add repository "+e.getMessage() );
262        }
263        catch ( RoleManagerException e )
264        {
265            log.error("Could not add repository roles for repository [{}]: {}", managedRepository.getId(), e.getMessage(), e);
266            throw new RepositoryAdminException( "Could not add roles to repository "+e.getMessage() );
267        }
268        return Boolean.TRUE;
269
270    }
271
272
273
274    @Override
275    public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
276                                            boolean deleteContent )
277        throws RepositoryAdminException
278    {
279        Configuration config = getArchivaConfiguration().getConfiguration();
280        ManagedRepositoryConfiguration repoConfig=config.findManagedRepositoryById( repositoryId );
281        if (repoConfig!=null) {
282
283            log.debug("Repo location " + repoConfig.getLocation());
284
285            org.apache.archiva.repository.ManagedRepository repo = repositoryRegistry.getManagedRepository(repositoryId);
286            org.apache.archiva.repository.ManagedRepository stagingRepository = null;
287            if (repo != null) {
288                try {
289                    if (repo.supportsFeature(StagingRepositoryFeature.class)) {
290                        stagingRepository = repo.getFeature(StagingRepositoryFeature.class).get().getStagingRepository();
291                    }
292                    repositoryRegistry.removeRepository(repo, config);
293                } catch (RepositoryException e) {
294                    log.error("Removal of repository {} failed: {}", repositoryId, e.getMessage(), e);
295                    throw new RepositoryAdminException("Removal of repository " + repositoryId + " failed.");
296                }
297            } else {
298                throw new RepositoryAdminException("A repository with that id does not exist");
299            }
300
301            triggerAuditEvent(repositoryId, null, AuditEvent.DELETE_MANAGED_REPO, auditInformation);
302            if (repoConfig != null) {
303                deleteManagedRepository(repoConfig, deleteContent, config, false);
304            }
305
306
307            // stage repo exists ?
308            if (stagingRepository != null) {
309                // do not trigger event when deleting the staged one
310                ManagedRepositoryConfiguration stagingRepositoryConfig = config.findManagedRepositoryById(stagingRepository.getId());
311                try {
312                    repositoryRegistry.removeRepository(stagingRepository);
313                    if (stagingRepositoryConfig != null) {
314                        deleteManagedRepository(stagingRepositoryConfig, deleteContent, config, true);
315                    }
316                } catch (RepositoryException e) {
317                    log.error("Removal of staging repository {} failed: {}", stagingRepository.getId(), e.getMessage(), e);
318                }
319            }
320
321            try {
322                saveConfiguration(config);
323            } catch (Exception e) {
324                throw new RepositoryAdminException("Error saving configuration for delete action" + e.getMessage(), e);
325            }
326
327            return Boolean.TRUE;
328        } else {
329            return Boolean.FALSE;
330        }
331    }
332
333    private Boolean deleteManagedRepository( ManagedRepositoryConfiguration repository, boolean deleteContent,
334                                             Configuration config, boolean stagedOne )
335        throws RepositoryAdminException
336    {
337
338        if ( !stagedOne )
339        {
340            boolean success=false;
341            try(RepositorySession repositorySession = getRepositorySessionFactory().createSession())
342            {
343                MetadataRepository metadataRepository = repositorySession.getRepository();
344                metadataRepository.removeRepository(repositorySession , repository.getId() );
345                //invalidate cache
346                namespacesCache.remove( repository.getId() );
347                repositorySession.save();
348                success=true;
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                success = false;
355            } catch (MetadataSessionException e) {
356                log.warn( "skip error during removing repository from MetadataRepository:{}", e.getMessage(), e );
357                success = false;
358            }
359            if (success)
360            {
361                log.debug( "call repositoryStatisticsManager.deleteStatistics" );
362                try
363                {
364                    getRepositoryStatisticsManager( ).deleteStatistics( repository.getId( ) );
365                }
366                catch ( MetadataRepositoryException e )
367                {
368                    e.printStackTrace( );
369                }
370            }
371
372        }
373
374        if ( deleteContent )
375        {
376            // TODO could be async ? as directory can be huge
377            Path dir = Paths.get( repository.getLocation() );
378            org.apache.archiva.common.utils.FileUtils.deleteQuietly( dir );
379        }
380
381        // olamy: copy list for reading as a unit test in webapp fail with ConcurrentModificationException
382        List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>( config.getProxyConnectors() );
383        for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
384        {
385            if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
386            {
387                config.removeProxyConnector( proxyConnector );
388            }
389        }
390
391        Map<String, List<String>> repoToGroupMap = config.getRepositoryToGroupMap();
392        if ( repoToGroupMap != null )
393        {
394            if ( repoToGroupMap.containsKey( repository.getId() ) )
395            {
396                List<String> repoGroups = repoToGroupMap.get( repository.getId() );
397                for ( String repoGroup : repoGroups )
398                {
399                    // copy to prevent UnsupportedOperationException
400                    RepositoryGroupConfiguration repositoryGroupConfiguration =
401                        config.findRepositoryGroupById( repoGroup );
402                    List<String> repos = new ArrayList<>( repositoryGroupConfiguration.getRepositories() );
403                    config.removeRepositoryGroup( repositoryGroupConfiguration );
404                    repos.remove( repository.getId() );
405                    repositoryGroupConfiguration.setRepositories( repos );
406                    config.addRepositoryGroup( repositoryGroupConfiguration );
407                }
408            }
409        }
410
411        try
412        {
413            removeRepositoryRoles( repository );
414        }
415        catch ( RoleManagerException e )
416        {
417            throw new RepositoryAdminException(
418                "fail to remove repository roles for repository " + repository.getId() + " : " + e.getMessage(), e );
419        }
420
421        try {
422            final RepositoryRegistry reg = getRepositoryRegistry();
423            if (reg.getManagedRepository(repository.getId())!=null) {
424                reg.removeRepository(reg.getManagedRepository(repository.getId()));
425            }
426        } catch (RepositoryException e) {
427            throw new RepositoryAdminException("Removal of repository "+repository.getId()+ " failed: "+e.getMessage());
428        }
429
430        saveConfiguration( config );
431
432        return Boolean.TRUE;
433    }
434
435    ArchivaIndexManager getIndexManager(ManagedRepository managedRepository) {
436        org.apache.archiva.repository.ManagedRepository repo = getRepositoryRegistry().getManagedRepository(managedRepository.getId());
437        return indexManagerFactory.getIndexManager(repo.getType());
438    }
439
440    @Override
441    public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
442                                            AuditInformation auditInformation, boolean resetStats )
443        throws RepositoryAdminException
444    {
445
446        log.debug( "updateManagedConfiguration repo {} needStage {} resetStats {} ", managedRepository, needStageRepo,
447                   resetStats );
448
449        // Ensure that the fields are valid.
450
451        getRepositoryCommonValidator().basicValidation( managedRepository, true );
452
453        getRepositoryCommonValidator().validateManagedRepository( managedRepository );
454
455        Configuration configuration = getArchivaConfiguration().getConfiguration();
456
457        ManagedRepositoryConfiguration updatedRepoConfig = getRepositoryConfiguration( managedRepository );
458        updatedRepoConfig.setStageRepoNeeded( needStageRepo );
459
460        org.apache.archiva.repository.ManagedRepository oldRepo = repositoryRegistry.getManagedRepository( managedRepository.getId( ) );
461        boolean stagingExists = false;
462        if (oldRepo.supportsFeature( StagingRepositoryFeature.class ) ){
463            stagingExists = oldRepo.getFeature( StagingRepositoryFeature.class ).get().getStagingRepository() != null;
464        }
465        boolean updateIndexContext = !StringUtils.equals( updatedRepoConfig.getIndexDir(), managedRepository.getIndexDirectory() );
466        org.apache.archiva.repository.ManagedRepository newRepo;
467        // TODO remove content from old if path has changed !!!!!
468        try
469        {
470            newRepo = repositoryRegistry.putRepository( updatedRepoConfig, configuration );
471            if (newRepo.supportsFeature( StagingRepositoryFeature.class )) {
472                org.apache.archiva.repository.ManagedRepository stagingRepo = newRepo.getFeature( StagingRepositoryFeature.class ).get( ).getStagingRepository( );
473                if (stagingRepo!=null && !stagingExists)
474                {
475                    triggerAuditEvent( stagingRepo.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
476                    addRepositoryRoles( stagingRepo.getId( ) );
477                }
478            }
479
480
481        }
482        catch ( RepositoryException e )
483        {
484            log.error("Could not update repository {}: {}", managedRepository.getId(), e.getMessage(), e);
485            throw new RepositoryAdminException( "Could not update repository "+managedRepository.getId());
486        }
487        catch ( RoleManagerException e ) {
488            log.error("Error during role update of stage repo {}", managedRepository.getId(), e);
489            throw new RepositoryAdminException( "Could not update repository "+managedRepository.getId());
490        }
491        triggerAuditEvent( managedRepository.getId(), null, AuditEvent.MODIFY_MANAGED_REPO,
492            auditInformation );
493        try
494        {
495            getArchivaConfiguration().save(configuration);
496        }
497        catch ( RegistryException | IndeterminateConfigurationException e )
498        {
499            log.error("Could not save repository configuration: {}", e.getMessage(), e);
500            throw new RepositoryAdminException( "Could not save repository configuration: "+e.getMessage() );
501        }
502
503        // Save the repository configuration.
504        RepositorySession repositorySession = null;
505        try
506        {
507            repositorySession = getRepositorySessionFactory().createSession();
508        }
509        catch ( MetadataRepositoryException e )
510        {
511            e.printStackTrace( );
512        }
513
514        try
515        {
516
517            if ( resetStats )
518            {
519                log.debug( "call repositoryStatisticsManager.deleteStatistics" );
520                getRepositoryStatisticsManager().deleteStatistics(
521                    managedRepository.getId() );
522                repositorySession.save();
523            }
524
525        }
526        catch (MetadataRepositoryException | MetadataSessionException e )
527        {
528            throw new RepositoryAdminException( e.getMessage(), e );
529        }
530        finally
531        {
532            repositorySession.close();
533        }
534
535        if ( updateIndexContext )
536        {
537            try
538            {
539
540                repositoryRegistry.resetIndexingContext(newRepo);
541            } catch (IndexUpdateFailedException e) {
542                e.printStackTrace();
543            }
544        }
545
546        return true;
547    }
548
549    //--------------------------
550    // utils methods
551    //--------------------------
552
553
554    protected void addRepository( ManagedRepositoryConfiguration repository, Configuration configuration )
555        throws RepositoryAdminException, IOException
556    {
557        try
558        {
559            getRepositoryRegistry().putRepository( repository, configuration );
560        }
561        catch ( RepositoryException e )
562        {
563            throw new RepositoryAdminException( "Could not add the repository to the registry. Cause: "+e.getMessage() );
564        }
565
566    }
567
568
569    public Boolean scanRepository( String repositoryId, boolean fullScan )
570    {
571        if ( getRepositoryTaskScheduler().isProcessingRepositoryTask( repositoryId ) )
572        {
573            log.info( "scanning of repository with id {} already scheduled", repositoryId );
574        }
575        RepositoryTask task = new RepositoryTask();
576        task.setRepositoryId( repositoryId );
577        task.setScanAll( fullScan );
578        try
579        {
580            getRepositoryTaskScheduler().queueTask( task );
581        }
582        catch ( TaskQueueException e )
583        {
584            log.error( "failed to schedule scanning of repo with id {}", repositoryId, e );
585            return false;
586        }
587        return true;
588    }
589
590
591    private void addRepositoryRoles( String repoId )
592        throws RoleManagerException
593    {
594        // TODO: double check these are configured on start up
595        // TODO: belongs in the business logic
596
597        if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
598        {
599            getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
600        }
601
602        if ( !getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
603        {
604            getRoleManager().createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
605        }
606    }
607
608    protected void removeRepositoryRoles( ManagedRepositoryConfiguration existingRepository )
609        throws RoleManagerException
610    {
611        String repoId = existingRepository.getId();
612
613        if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId ) )
614        {
615            getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, repoId );
616        }
617
618        if ( getRoleManager().templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId ) )
619        {
620            getRoleManager().removeTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, repoId );
621        }
622
623        log.debug( "removed user roles associated with repository {}", repoId );
624    }
625
626    //--------------------------
627    // setters/getters
628    //--------------------------
629
630
631    public RoleManager getRoleManager()
632    {
633        return roleManager;
634    }
635
636    public void setRoleManager( RoleManager roleManager )
637    {
638        this.roleManager = roleManager;
639    }
640
641    public RepositoryStatisticsManager getRepositoryStatisticsManager()
642    {
643        return repositoryStatisticsManager;
644    }
645
646    public void setRepositoryStatisticsManager( RepositoryStatisticsManager repositoryStatisticsManager )
647    {
648        this.repositoryStatisticsManager = repositoryStatisticsManager;
649    }
650
651    public RepositorySessionFactory getRepositorySessionFactory()
652    {
653        return repositorySessionFactory;
654    }
655
656    public void setRepositorySessionFactory( RepositorySessionFactory repositorySessionFactory )
657    {
658        this.repositorySessionFactory = repositorySessionFactory;
659    }
660
661
662    public RepositoryArchivaTaskScheduler getRepositoryTaskScheduler()
663    {
664        return repositoryTaskScheduler;
665    }
666
667    public void setRepositoryTaskScheduler( RepositoryArchivaTaskScheduler repositoryTaskScheduler )
668    {
669        this.repositoryTaskScheduler = repositoryTaskScheduler;
670    }
671
672
673    public RepositoryRegistry getRepositoryRegistry( )
674    {
675        return repositoryRegistry;
676    }
677
678    public void setRepositoryRegistry( RepositoryRegistry repositoryRegistry )
679    {
680        this.repositoryRegistry = repositoryRegistry;
681    }
682}