@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { this.repositoryDir = Paths.get( repository.getLocation( ) ); }
@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { this.repositoryDir = Paths.get( repository.getLocation( ) ); }
@Override public void beginScan( ManagedRepository repo, Date whenGathered ) throws ConsumerException { this.repositoryDir = Paths.get( repo.getLocation( ) ); }
@Override public void beginScan( ManagedRepository repository, Date whenGathered ) throws ConsumerException { this.repositoryDir = Paths.get( repository.getLocation( ) ); }
@Override public String getRepoRoot() { return convertUriToPath( repository.getLocation() ); }
private Path getRepositoryBasedir( String repoId ) throws RepositoryStorageRuntimeException { ManagedRepository repositoryConfiguration = repositoryRegistry.getManagedRepository( repoId ); return Paths.get( repositoryConfiguration.getLocation() ); }
@Override public void beginScan( ManagedRepository repository, Date whenGathered, boolean executeOnEntireRepo ) throws ConsumerException { if ( executeOnEntireRepo ) { beginScan( repository, whenGathered ); } else { this.repository = repository; managedRepository = Paths.get( repository.getLocation() ); } }
@Override public Path toFile( ArchivaArtifact reference ) { return PathUtil.getPathFromUri( repository.getLocation()).resolve( toPath( reference ) ); }
@Override public Path toFile( ArtifactReference reference ) { return PathUtil.getPathFromUri( repository.getLocation()).resolve( toPath( reference ) ); }
@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 void beginScan( ManagedRepository repo, Date whenGathered ) throws ConsumerException { repoId = repo.getId(); this.repositoryDir = Paths.get( repo.getLocation() ); repositorySession = repositorySessionFactory.createSession(); }
/** * Convert a path to an artifact reference. * * @param path the path to convert. (relative or full location path) * @throws LayoutException if the path cannot be converted to an artifact reference. */ @Override public ArtifactReference toArtifactReference( String path ) throws LayoutException { String repoPath = convertUriToPath( repository.getLocation() ); if ( ( path != null ) && path.startsWith( repoPath ) && repoPath.length() > 0 ) { return super.toArtifactReference( path.substring( repoPath.length() + 1 ) ); } return super.toArtifactReference( path ); }
Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = repoBase.resolve( path );
public RepositoryModelResolver( ManagedRepository managedRepository, RepositoryPathTranslator pathTranslator, WagonFactory wagonFactory, List<RemoteRepository> remoteRepositories, Map<String, NetworkProxy> networkProxiesMap, ManagedRepository targetRepository, MavenSystemManager mavenSystemManager) { this( Paths.get( managedRepository.getLocation() ), pathTranslator ); this.managedRepository = managedRepository; this.wagonFactory = wagonFactory; this.remoteRepositories = remoteRepositories; this.networkProxyMap = networkProxiesMap; this.targetRepository = targetRepository; this.session = MavenSystemManager.newRepositorySystemSession( managedRepository.getLocalPath().toString() ); this.versionRangeResolver = mavenSystemManager.getLocator().getService(VersionRangeResolver.class); this.mavenSystemManager = mavenSystemManager; }
Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = artifactFile.getParent().toAbsolutePath();
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (excludeMatcher.stream().noneMatch(m -> m.matches(file)) && includeMatcher.stream().allMatch(m -> m.matches(file))) { log.debug( "Walk Step: {}, {}", file ); stats.increaseFileCount(); // consume files regardless - the predicate will check the timestamp Path repoPath = PathUtil.getPathFromUri( repository.getLocation() ); BaseFile basefile = new BaseFile( repoPath.toString(), file.toFile() ); // Timestamp finished points to the last successful scan, not this current one. if ( Files.getLastModifiedTime(file).toMillis() >= changesSince ) { stats.increaseNewFileCount(); } consumerProcessFile.setBasefile( basefile ); consumerWantsFile.setBasefile( basefile ); Closure<RepositoryContentConsumer> processIfWanted = IfClosure.ifClosure( consumerWantsFile, consumerProcessFile ); IterableUtils.forEach( this.knownConsumers, processIfWanted ); if ( consumerWantsFile.getWantedFileCount() <= 0 ) { // Nothing known processed this file. It is invalid! IterableUtils.forEach( this.invalidConsumers, consumerProcessFile ); } } return FileVisitResult.CONTINUE; }
private void finishWalk() { this.isRunning = false; TriggerScanCompletedClosure scanCompletedClosure = new TriggerScanCompletedClosure( repository, true ); IterableUtils.forEach( knownConsumers, scanCompletedClosure ); IterableUtils.forEach( invalidConsumers, scanCompletedClosure ); stats.setConsumerTimings( consumerTimings ); stats.setConsumerCounts( consumerCounts ); log.info( "Walk Finished: [{}] {}", this.repository.getId(), this.repository.getLocation() ); stats.triggerFinished(); this.basePath = null; } }
@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()); } }
cfg.setName(managedRepository.getName()); cfg.setDescription(managedRepository.getDescription()); cfg.setLocation(convertUriToPath(managedRepository.getLocation())); cfg.setLayout(managedRepository.getLayout()); cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
@Override public ManagedRepositoryConfiguration getManagedConfiguration( ManagedRepository managedRepository ) { ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration( ); configuration.setId( managedRepository.getId( ) ); configuration.setName(managedRepository.getName()); configuration.setLocation( managedRepository.getLocation( ) == null ? "" : managedRepository.getLocation().toString( ) ); configuration.setBlockRedeployments( managedRepository.blocksRedeployments( ) ); configuration.setDescription( managedRepository.getDescription( ) ); configuration.setScanned( managedRepository.isScanned( ) ); configuration.setRefreshCronExpression( managedRepository.getSchedulingDefinition( ) ); configuration.setReleases( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE) ); configuration.setSnapshots( managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT) ); configuration.setLayout( managedRepository.getLayout() ); ArtifactCleanupFeature acf = managedRepository.getFeature( ArtifactCleanupFeature.class ).get( ); configuration.setRetentionPeriod( acf.getRetentionPeriod( ).getDays( ) ); configuration.setDeleteReleasedSnapshots( acf.isDeleteReleasedSnapshots( ) ); configuration.setRetentionCount( acf.getRetentionCount( ) ); IndexCreationFeature icf = managedRepository.getFeature( IndexCreationFeature.class ).get( ); configuration.setSkipPackedIndexCreation( icf.isSkipPackedIndexCreation( ) ); configuration.setIndexDir( icf.getIndexPath( ) == null ? "" : icf.getIndexPath().toString( ) ); StagingRepositoryFeature srf = managedRepository.getFeature( StagingRepositoryFeature.class ).get( ); configuration.setStageRepoNeeded( srf.isStageRepoNeeded( ) ); return configuration; }