private Path getIndexPath( ArchivaIndexingContext ctx ) { return PathUtil.getPathFromUri( ctx.getPath( ) ); }
@Override public void setLocation( URI location ) { super.setLocation( location ); Path newLoc = PathUtil.getPathFromUri( location ); if (!Files.exists( newLoc )) { try { Files.createDirectories( newLoc ); } catch ( IOException e ) { log.error("Could not create directory {}",location, e); } } }
@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 Path getLocalPath() { Path localPath; if (StringUtils.isEmpty(getLocation().getScheme()) || "file".equals(getLocation().getScheme()) ) { localPath = PathUtil.getPathFromUri(getLocation()); if (localPath.isAbsolute()) { return localPath; } else { return repositoryBase.resolve(localPath); } } else { return repositoryBase.resolve(getId()); } }
private Path getPackedIndexPath(Repository repo) throws IOException { IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); Path repoDir = repo.getLocalPath(); URI indexDir = icf.getPackedIndexPath(); Path indexDirectory = null; if ( ! StringUtils.isEmpty(indexDir.toString( ) ) ) { indexDirectory = PathUtil.getPathFromUri( indexDir ); // not absolute so create it in repository directory if ( !indexDirectory.isAbsolute( ) ) { indexDirectory = repoDir.resolve( indexDirectory ); } } else { indexDirectory = repoDir.resolve( DEFAULT_PACKED_INDEX_DIR ); } if ( !Files.exists( indexDirectory ) ) { Files.createDirectories( indexDirectory ); } return indexDirectory; }
Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = repoBase.resolve( path );
private Path getIndexPath(Repository repo) throws IOException { IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); Path repoDir = repo.getLocalPath(); URI indexDir = icf.getIndexPath(); Path indexDirectory = null; if ( ! StringUtils.isEmpty(indexDir.toString( ) ) ) { indexDirectory = PathUtil.getPathFromUri( indexDir ); // not absolute so create it in repository directory if ( !indexDirectory.isAbsolute( ) ) { indexDirectory = repoDir.resolve( indexDirectory ); } } else { indexDirectory = repoDir.resolve( DEFAULT_INDEXER_DIR ); } if ( !Files.exists( indexDirectory ) ) { Files.createDirectories( indexDirectory ); } return indexDirectory; }
private Path getIndexPath(Repository repo) throws IOException { IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get(); Path repoDir = repo.getLocalPath(); URI indexDir = icf.getIndexPath(); Path indexDirectory = null; if ( ! StringUtils.isEmpty(indexDir.toString( ) ) ) { indexDirectory = PathUtil.getPathFromUri( indexDir ); // not absolute so create it in repository directory if ( !indexDirectory.isAbsolute( ) ) { indexDirectory = repoDir.resolve( indexDirectory ); } } else { indexDirectory = repoDir.resolve( DEFAULT_INDEXER_DIR); } if ( !Files.exists( indexDirectory ) ) { Files.createDirectories( indexDirectory ); } return indexDirectory; }
Path repoBase = PathUtil.getPathFromUri(repository.getLocation()); Path repoDir = repoBase.resolve( path );
Path repoDir = PathUtil.getPathFromUri( repository.getLocation() ).resolve( path );
@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; }
Path repoBase = PathUtil.getPathFromUri(repository.getLocation()).toAbsolutePath(); Path repoDir = artifactFile.getParent().toAbsolutePath();
@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()); } }
@Test public void testNoExistingChecksums() throws Exception { String path = "no-checksums-artifact/1.0/no-checksums-artifact-1.0.jar"; Path basePath = PathUtil.getPathFromUri( repoConfig.getLocation() ); Path sha1Path = basePath.resolve(path + ".sha1" ); Path md5FilePath = basePath.resolve(path + ".md5" ); Files.deleteIfExists( sha1Path ); Files.deleteIfExists( md5FilePath ); Assertions.assertThat( sha1Path.toFile() ).doesNotExist(); Assertions.assertThat( md5FilePath.toFile() ).doesNotExist(); consumer.beginScan( repoConfig, Calendar.getInstance().getTime() ); consumer.processFile( path ); Assertions.assertThat( sha1Path.toFile() ).exists(); long sha1LastModified = sha1Path.toFile().lastModified(); Assertions.assertThat( md5FilePath.toFile() ).exists(); long md5LastModified = md5FilePath.toFile().lastModified(); Thread.sleep( 1000 ); consumer.processFile( path ); Assertions.assertThat( sha1Path.toFile() ).exists(); Assertions.assertThat( md5FilePath.toFile() ).exists(); Assertions.assertThat( sha1Path.toFile().lastModified() ).isEqualTo( sha1LastModified ); Assertions.assertThat( md5FilePath.toFile().lastModified() ).isEqualTo( md5LastModified ); }
FileUtils.copyDirectory( Paths.get(repoConfig.getLocation() ).toFile(), newLocation.toFile() ); repoConfig.setLocation( newLocation.toAbsolutePath().toUri() ); Path basePath = PathUtil.getPathFromUri( repoConfig.getLocation() );
Path repoPath = PathUtil.getPathFromUri( repository.getLocation() ); BaseFile baseFile = new BaseFile( repoPath.toString(), localFile.toFile() ); ConsumerWantsFilePredicate predicate = new ConsumerWantsFilePredicate( repository );