Removing usage of Repository.getLocalPath

This commit is contained in:
Martin Stockhammer 2019-07-14 01:18:42 +02:00
parent 830ea54e0c
commit d599b89e3d
9 changed files with 27 additions and 27 deletions

View File

@ -526,7 +526,7 @@ public ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<Arc
private StorageAsset getIndexPath( Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
Path repoDir = repo.getLocalPath();
Path repoDir = repo.getAsset("").getFilePath();
URI indexDir = icf.getIndexPath();
String indexPath = indexDir.getPath();
Path indexDirectory = null;
@ -565,7 +565,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
// create remote repository path
Path repoDir = remoteRepository.getLocalPath();
Path repoDir = remoteRepository.getAsset("").getFilePath();
if ( !Files.exists( repoDir ) )
{
Files.createDirectories( repoDir );
@ -615,7 +615,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
IndexingContext context;
// take care first about repository location as can be relative
Path repositoryDirectory = repository.getLocalPath();
Path repositoryDirectory = repository.getAsset("").getFilePath();
if ( !Files.exists( repositoryDirectory ) )
{

View File

@ -626,12 +626,12 @@ private StorageAsset getIndexPath(URI indexDir, Path repoDir, String defaultDir)
private StorageAsset getIndexPath( Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
return getIndexPath( icf.getIndexPath(), repo.getLocalPath(), DEFAULT_INDEX_PATH);
return getIndexPath( icf.getIndexPath(), repo.getAsset( "" ).getFilePath(), DEFAULT_INDEX_PATH);
}
private StorageAsset getPackedIndexPath(Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
return getIndexPath(icf.getPackedIndexPath(), repo.getLocalPath(), DEFAULT_PACKED_INDEX_PATH);
return getIndexPath(icf.getPackedIndexPath(), repo.getAsset( "" ).getFilePath(), DEFAULT_PACKED_INDEX_PATH);
}
private IndexingContext createRemoteContext(RemoteRepository remoteRepository ) throws IOException
@ -642,7 +642,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
// create remote repository path
Path repoDir = remoteRepository.getLocalPath();
Path repoDir = remoteRepository.getAsset( "" ).getFilePath();
if ( !Files.exists( repoDir ) )
{
Files.createDirectories( repoDir );
@ -701,7 +701,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
IndexingContext context;
// take care first about repository location as can be relative
Path repositoryDirectory = repository.getLocalPath();
Path repositoryDirectory = repository.getAsset( "" ).getFilePath();
if ( !Files.exists( repositoryDirectory ) )
{

View File

@ -93,7 +93,7 @@ public void tearDown() {
@Test
public void pack() throws Exception {
createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-webapp/1.0");
Path destDir = repository.getAsset( "" ).getFilePath().resolve("org/apache/archiva/archiva-webapp/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-webapp/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(),destDir.toFile());
mavenIndexManager.scan(ctx);
@ -110,7 +110,7 @@ public void pack() throws Exception {
@Test
public void scan() throws Exception {
createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-webapp/1.0");
Path destDir = repository.getAsset("").getFilePath().resolve("org/apache/archiva/archiva-webapp/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-webapp/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(),destDir.toFile());
mavenIndexManager.scan(ctx);
@ -138,7 +138,7 @@ public void update() throws Exception {
public void addArtifactsToIndex() throws Exception {
ArchivaIndexingContext ctx = createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
Path destDir = repository.getAsset( "" ).getFilePath().resolve("org/apache/archiva/archiva-search/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
List<URI> uriList = new ArrayList<>();
@ -156,7 +156,7 @@ public void addArtifactsToIndex() throws Exception {
@Test
public void removeArtifactsFromIndex() throws Exception {
ArchivaIndexingContext ctx = createTestContext();
Path destDir = repository.getLocalPath().resolve("org/apache/archiva/archiva-search/1.0");
Path destDir = repository.getAsset( "" ).getFilePath().resolve("org/apache/archiva/archiva-search/1.0");
Path srcDir = Paths.get("src/test/maven-search-test-repo/org/apache/archiva/archiva-search/1.0");
org.apache.commons.io.FileUtils.copyDirectory(srcDir.toFile(), destDir.toFile());
List<URI> uriList = new ArrayList<>();

View File

@ -233,7 +233,7 @@ private ManagedRepository findArtifactInRepositories( List<String> repositoryIds
for ( String repoId : repositoryIds )
{
ManagedRepository managedRepo = repositoryRegistry.getManagedRepository(repoId);
Path repoDir = managedRepo.getLocalPath();
Path repoDir = managedRepo.getAsset("").getFilePath();
Path file = pathTranslator.toFile( repoDir, projectArtifact.getGroupId(), projectArtifact.getArtifactId(),
projectArtifact.getBaseVersion(),

View File

@ -123,7 +123,7 @@ public RepositoryModelResolver(ManagedRepository managedRepository, RepositoryPa
this.targetRepository = targetRepository;
this.session = MavenSystemManager.newRepositorySystemSession( managedRepository.getLocalPath().toString() );
this.session = MavenSystemManager.newRepositorySystemSession( managedRepository.getAsset("").getFilePath().toString() );
this.versionRangeResolver = mavenSystemManager.getLocator().getService(VersionRangeResolver.class);
@ -300,7 +300,7 @@ private boolean getModelFromProxy( RemoteRepository remoteRepository, String gro
Path tmpSha1 = null;
Path tmpResource = null;
String artifactPath = pathTranslator.toPath( groupId, artifactId, version, filename );
Path resource = targetRepository.getLocalPath().resolve( artifactPath );
Path resource = targetRepository.getAsset("").getFilePath().resolve( artifactPath );
Path workingDirectory = createWorkingDirectory( targetRepository.getLocation().toString() );
try

View File

@ -168,14 +168,14 @@ public void updateManagedInstance(EditableManagedRepository repo, ManagedReposit
throw new RepositoryException("The location entry is not a valid uri: " + cfg.getLocation());
}
setBaseConfig(repo, cfg);
Path repoDir = repo.getLocalPath();
Path repoDir = repo.getAsset("").getFilePath();
if (!Files.exists(repoDir)) {
log.debug("Creating repo directory {}", repoDir);
try {
Files.createDirectories(repoDir);
} catch (IOException e) {
log.error("Could not create directory {} for repository {}", repo.getLocalPath(), repo.getId(), e);
throw new RepositoryException("Could not create directory for repository " + repo.getLocalPath());
log.error("Could not create directory {} for repository {}", repoDir, repo.getId(), e);
throw new RepositoryException("Could not create directory for repository " + repoDir);
}
}
repo.setSchedulingDefinition(cfg.getRefreshCronExpression());

View File

@ -529,7 +529,7 @@ public ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<Arc
private StorageAsset getIndexPath( Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
Path repoDir = repo.getLocalPath();
Path repoDir = repo.getAsset( "" ).getFilePath();
URI indexDir = icf.getIndexPath();
String indexPath = indexDir.getPath();
Path indexDirectory = null;
@ -568,7 +568,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
// create remote repository path
Path repoDir = remoteRepository.getLocalPath();
Path repoDir = remoteRepository.getAsset("").getFilePath();
if ( !Files.exists( repoDir ) )
{
Files.createDirectories( repoDir );
@ -618,7 +618,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
IndexingContext context;
// take care first about repository location as can be relative
Path repositoryDirectory = repository.getLocalPath();
Path repositoryDirectory = repository.getAsset("").getFilePath();
if ( !Files.exists( repositoryDirectory ) )
{

View File

@ -132,7 +132,7 @@ protected IndexingContext getIndexingContext() throws UnsupportedBaseContextExce
public void testAddArtifactToIndex()
throws Exception
{
Path basePath = repo.getLocalPath();
Path basePath = repo.getAsset("").getFilePath();
Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
@ -174,7 +174,7 @@ public void testAddArtifactToIndex()
public void testUpdateArtifactInIndex()
throws Exception
{
Path basePath = repo.getLocalPath();
Path basePath = repo.getAsset("").getFilePath();
Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
@ -211,7 +211,7 @@ public void testUpdateArtifactInIndex()
public void testRemoveArtifactFromIndex()
throws Exception
{
Path basePath = repo.getLocalPath();
Path basePath = repo.getAsset("").getFilePath();
Path artifactFile = basePath.resolve(
"org/apache/archiva/archiva-index-methods-jar-test/1.0/archiva-index-methods-jar-test-1.0.jar" );
@ -274,7 +274,7 @@ public void testPackagedIndex()
throws Exception
{
Path basePath = repo.getLocalPath();
Path basePath = repo.getAsset("").getFilePath();
IndexCreationFeature icf = repo.getFeature( IndexCreationFeature.class ).get();
StorageAsset packedIndexDirectory = icf.getLocalPackedIndexPath();
StorageAsset indexerDirectory = icf.getLocalIndexPath();

View File

@ -513,7 +513,7 @@ public ArchivaIndexingContext mergeContexts(Repository destinationRepo, List<Arc
private StorageAsset getIndexPath( Repository repo) throws IOException {
IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
Path repoDir = repo.getLocalPath();
Path repoDir = repo.getAsset("").getFilePath();
URI indexDir = icf.getIndexPath();
String indexPath = indexDir.getPath();
Path indexDirectory = null;
@ -552,7 +552,7 @@ private IndexingContext createRemoteContext(RemoteRepository remoteRepository )
// create remote repository path
Path repoDir = remoteRepository.getLocalPath();
Path repoDir = remoteRepository.getAsset("").getFilePath();
if ( !Files.exists( repoDir ) )
{
Files.createDirectories( repoDir );
@ -602,7 +602,7 @@ private IndexingContext createManagedContext( ManagedRepository repository ) thr
IndexingContext context;
// take care first about repository location as can be relative
Path repositoryDirectory = repository.getLocalPath();
Path repositoryDirectory = repository.getAsset("").getFilePath();
if ( !Files.exists( repositoryDirectory ) )
{