if ( repository.supportsFeature( IndexCreationFeature.class ) )
if ( managedRepository.supportsFeature( IndexCreationFeature.class ) )
context.optimize( ); if ( repository.supportsFeature( IndexCreationFeature.class ) )
private ManagedRepository getStagingRepository(RepositoryProvider provider, ManagedRepositoryConfiguration baseRepoCfg, Configuration configuration) throws RepositoryException { ManagedRepository stageRepo = getManagedRepository( baseRepoCfg.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX ); if ( stageRepo == null ) { stageRepo = provider.createStagingInstance( baseRepoCfg ); if (stageRepo.supportsFeature(StagingRepositoryFeature.class)) { stageRepo.getFeature(StagingRepositoryFeature.class).get().setStageRepoNeeded(false); } ManagedRepositoryConfiguration stageCfg = provider.getManagedConfiguration( stageRepo ); updateRepositoryReferences( provider, stageRepo, stageCfg, configuration); } return stageRepo; }
@SuppressWarnings( "unchecked" ) private void updateRepositoryReferences(RepositoryProvider provider, ManagedRepository repo, ManagedRepositoryConfiguration cfg, Configuration configuration) throws RepositoryException { log.debug("Updating references of repo {}",repo.getId()); if ( repo.supportsFeature( StagingRepositoryFeature.class ) ) { StagingRepositoryFeature feature = repo.getFeature( StagingRepositoryFeature.class ).get( ); if ( feature.isStageRepoNeeded( ) && feature.getStagingRepository() == null) { ManagedRepository stageRepo = getStagingRepository( provider, cfg, configuration); managedRepositories.put(stageRepo.getId(), stageRepo); feature.setStagingRepository( stageRepo ); if (configuration!=null) { replaceOrAddRepositoryConfig( provider.getManagedConfiguration( stageRepo ), configuration ); } } } if ( repo instanceof EditableManagedRepository) { EditableManagedRepository editableRepo = (EditableManagedRepository) repo; if (repo.getContent()==null) { editableRepo.setContent(repositoryContentFactory.getManagedRepositoryContent(repo)); } log.debug("Index repo: "+repo.hasIndex()); if (repo.hasIndex() && repo.getIndexingContext()==null) { log.debug("Creating indexing context for {}", repo.getId()); createIndexingContext(editableRepo); } } }
@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { ManagedRepositoryContent repositoryContent; repositoryContent = repository.getContent(); repositorySession = repositorySessionFactory.createSession( ); if (repository.supportsFeature( ArtifactCleanupFeature.class )) { ArtifactCleanupFeature acf = repository.getFeature( ArtifactCleanupFeature.class ).get(); int retentionPeriodInDays = acf.getRetentionPeriod( ).getDays( ); int retentionCount = acf.getRetentionCount(); if ( retentionPeriodInDays != 0 ) { repoPurge = new DaysOldRepositoryPurge( repositoryContent, retentionPeriodInDays, retentionCount, repositorySession, listeners ); } else { repoPurge = new RetentionCountRepositoryPurge( repositoryContent, retentionCount, repositorySession, listeners ); } deleteReleasedSnapshots = acf.isDeleteReleasedSnapshots( ); } else { throw new ConsumerException( "The repository does not support the ArtifactCleanup feature "+repository.getId() ); } cleanUp = new CleanupReleasedSnapshotsRepositoryPurge( repositoryContent, metadataTools, repositoryRegistry, repositorySession, listeners ); }