@Override public void beginScan( ManagedRepository repo, Date whenGathered ) throws ConsumerException { repoId = repo.getId(); this.whenGathered = whenGathered; }
@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 { this.repository = repository; managedRepository = PathUtil.getPathFromUri( repository.getLocation() ); try { log.info( "Creating indexing context for repo : {}", repository.getId() ); if (repository.getType()== RepositoryType.MAVEN) { indexingContext = repository.getIndexingContext().getBaseContext(IndexingContext.class); } else { indexingContext= null; } } catch (UnsupportedBaseContextException e) { log.error("Bad repository type. Not nexus indexer compatible."); throw new ConsumerException("Bad repository type "+repository.getType()); } }
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { if (!isRunning) { isRunning = true; this.basePath = dir; log.info( "Walk Started: [{}] {}", this.repository.getId(), this.repository.getLocation() ); stats.triggerStart(); } return FileVisitResult.CONTINUE; }
@Override public ManagedRepositoryContent createManagedContent( ManagedRepository repository ) throws RepositoryException { if (!supports( repository.getType() )) { throw new RepositoryException( "Repository type "+repository.getType()+" is not supported by this implementation." ); } if (!supportsLayout( repository.getLayout() )) { throw new RepositoryException( "Repository layout "+repository.getLayout()+" is not supported by this implementation." ); } ManagedDefaultRepositoryContent content = new ManagedDefaultRepositoryContent(artifactMappingProviders, filetypes); content.setRepository( repository ); return content; }
cfg.setType(managedRepository.getType().toString()); cfg.setId(managedRepository.getId()); cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); cfg.setScanned(managedRepository.isScanned()); cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { cfg.setReleases(true); } else { cfg.setReleases(false); if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { cfg.setSnapshots(true); } else {
@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 ); }
Path repositoryDirectory = repository.getLocalPath(); if ( repository.supportsFeature( IndexCreationFeature.class ) ) try context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl ); context.setSearchable( repository.isScanned( ) ); repository.getId( ) ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( indexDirectory ); context = getIndexingContext( repository, repository.getId( ), repositoryDirectory, indexDirectory, indexUrl ); context.setSearchable( repository.isScanned( ) );
public ManagedRepositoryContent getManagedRepositoryContent( org.apache.archiva.repository.ManagedRepository mRepo ) throws RepositoryException { final String id = mRepo.getId(); ManagedRepositoryContent content = managedContentMap.get( id ); if ( content != null && content.getRepository()==mRepo) { return content; } RepositoryContentProvider contentProvider = getProvider( mRepo.getLayout( ), mRepo.getType( ) ); content = contentProvider.createManagedContent( mRepo ); if (content==null) { throw new RepositoryException( "Could not create repository content instance for "+mRepo.getId() ); } ManagedRepositoryContent previousContent = managedContentMap.put( id, content ); if (previousContent!=null) { previousContent.setRepository( null ); } return content; }
@Override public void beginScan( ManagedRepository repoConfig, Date whenGathered ) throws ConsumerException { try { ManagedRepository repo = repositoryRegistry.getManagedRepository( repoConfig.getId( ) ); if (repo==null) { throw new RepositoryNotFoundException( "Repository not found: "+repoConfig.getId() ); } this.repository = repo.getContent(); if (this.repository==null) { throw new RepositoryNotFoundException( "Repository content not found: "+repoConfig.getId() ); } this.repositoryDir = Paths.get( repository.getRepoRoot( ) ); this.scanStartTimestamp = System.currentTimeMillis( ); } catch ( RepositoryException e ) { throw new ConsumerException( e.getMessage( ), e ); } }
@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { this.repositoryDir = Paths.get( repository.getLocation( ) ); }
private String getLogicalResource( ArchivaDavResourceLocator archivaLocator, org.apache.archiva.repository.ManagedRepository managedRepository, boolean useOrigResourcePath ) { // FIXME remove this hack // but currently managedRepository can be null in case of group String layout = managedRepository == null ? "default" : managedRepository.getLayout(); RepositoryStorage repositoryStorage = this.applicationContext.getBean( "repositoryStorage#" + layout, RepositoryStorage.class ); String path = repositoryStorage.getFilePath( useOrigResourcePath ? archivaLocator.getOrigResourcePath() : archivaLocator.getResourcePath(), managedRepository ); log.debug( "found path {} for resourcePath: '{}' with managedRepo '{}' and layout '{}'", path, archivaLocator.getResourcePath(), managedRepository == null ? "null" : managedRepository.getId(), layout ); return path; }
Path artifactFile = source.getLocalPath().resolve( artifactSourcePath ); Path targetPath = target.getLocalPath().resolve( path ); if ( Files.exists(targetFile) && target.blocksRedeployments()) queueRepositoryTask( target.getId(), targetFile ); Path pomFile = source.getLocalPath().resolve( artifactSourcePath.substring( 0, artifactPath.lastIndexOf( '/' ) )).resolve( pomFilename ); queueRepositoryTask( target.getId(), targetPath.resolve( pomFilename ) );
try final String id = managedRepository.getId(); if (remoteRepositories.containsKey( id )) { throw new RepositoryException( "There exists a remote repository with id "+id+". Could not update with managed repository." ); originRepo.close(); RepositoryProvider provider = getProvider( managedRepository.getType() ); ManagedRepositoryConfiguration newCfg = provider.getManagedConfiguration( managedRepository ); Configuration configuration = getArchivaConfiguration( ).getConfiguration( );
public void removeRepository(ManagedRepository managedRepository, Configuration configuration) throws RepositoryException { final String id = managedRepository.getId(); ManagedRepository repo = getManagedRepository( id ); if (repo!=null) { rwLock.writeLock().lock(); try { repo = managedRepositories.remove( id ); if (repo!=null) { repo.close(); ManagedRepositoryConfiguration cfg = configuration.findManagedRepositoryById( id ); if (cfg!=null) { configuration.removeManagedRepository( cfg ); } } } finally { rwLock.writeLock().unlock(); } } }
"Invalid managed repository <" + repository + ">"); managedRepository = repo.getContent(); if (managedRepository==null) { log.error("Inconsistency detected. Repository content not found for '{}'",repository); IndexCreationFeature idf = managedRepository.getRepository().getFeature(IndexCreationFeature.class).get(); String repoIndexDirectory = idf.getIndexPath().toString(); if ( StringUtils.isNotEmpty( repoIndexDirectory ) ) repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve( StringUtils.isEmpty( repoIndexDirectory ) ? ".indexer" repoIndexDirectory = Paths.get( managedRepository.getRepository().getLocation() ).resolve( ".indexer" ).toAbsolutePath().toString();
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; }
log.info( "indexed maven repository: {}, onlyUpdate: {}, time {} ms", repository.getId( ), indexingTask.isOnlyUpdate( ), ( end - start ) ); log.debug( "Finishing indexing task on repo: {}", repository.getId( ) ); finishIndexingTask( indexingTask, repository, context ); ? "none" : indexingTask.getResourceFile( ) ) ); archivaContext = repository.getIndexingContext( ); context = archivaContext.getBaseContext( IndexingContext.class );
@Before @Override public void setUp() throws Exception { super.setUp(); org.apache.archiva.repository.ManagedRepository repoConfiguration = getRepoConfiguration( TEST_REPO_ID, TEST_REPO_NAME ); List<RepositoryListener> listeners = Collections.singletonList( listener ); ArtifactCleanupFeature acf = repoConfiguration.getFeature( ArtifactCleanupFeature.class ).get(); repoPurge = new RetentionCountRepositoryPurge( getRepository(), acf.getRetentionCount(), repositorySession, listeners ); }
buf.append( " \\.__________________________________________" ); buf.append( "\n Repository Dir : " ).append( repo.getLocation() ); buf.append( "\n Repository Name : " ).append( repo.getName() ); buf.append( "\n Repository Layout : " ).append( repo.getLayout() );