aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2019-07-11 23:28:01 +0200
committerMartin Stockhammer <martin_s@apache.org>2019-07-11 23:28:01 +0200
commit830ea54e0c64bb5c7fe5b2006c171ebd2625e287 (patch)
treec6e65a81b5e92e6aa2f662398e1f32de5c7e8875
parent38b10a09f4c91ba6249baf95b1e4f487cb80ac79 (diff)
downloadarchiva-830ea54e0c64bb5c7fe5b2006c171ebd2625e287.tar.gz
archiva-830ea54e0c64bb5c7fe5b2006c171ebd2625e287.zip
Moving storage api to repository level
-rw-r--r--archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java4
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java40
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java2
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java5
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java34
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java3
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractManagedRepository.java20
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java12
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java80
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java44
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicManagedRepository.java24
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicRemoteRepository.java18
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java4
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/RepositoryRegistryTest.java12
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java29
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java39
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java10
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java10
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java11
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java39
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java2
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java6
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java2
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java2
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java29
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java33
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java47
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java55
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java18
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java32
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java52
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java15
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/content/maven2/MavenRepositoryRequestInfoTest.java8
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java15
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java12
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/scheduler/indexing/maven/ArchivaIndexingTaskExecutorTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java14
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java6
-rw-r--r--archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java2
44 files changed, 423 insertions, 380 deletions
diff --git a/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java b/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java
index d8078a981..3ff6b3f26 100644
--- a/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java
+++ b/archiva-cli/src/main/java/org/apache/archiva/cli/ArchivaCli.java
@@ -164,9 +164,9 @@ public class ArchivaCli
}
private void doScan( String path, String[] consumers )
- throws ConsumerException, MalformedURLException
+ throws ConsumerException, IOException
{
- BasicManagedRepository repo = new BasicManagedRepository( Paths.get(path).getFileName().toString(), "Archiva CLI Provided Repo", Paths.get(path).getParent());
+ BasicManagedRepository repo = BasicManagedRepository.newFilesystemInstance( Paths.get(path).getFileName().toString(), "Archiva CLI Provided Repo", Paths.get(path).getParent());
repo.setLocation( Paths.get(path).toUri() );
List<KnownRepositoryContentConsumer> knownConsumerList = new ArrayList<>();
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java
index 7f72c4205..15cf17e25 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/RepositoryProviderMock.java
@@ -42,6 +42,7 @@ import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.springframework.stereotype.Service;
+import java.io.IOException;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
@@ -73,19 +74,32 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public EditableManagedRepository createManagedInstance( String id, String name )
{
- return new BasicManagedRepository( id, name, Paths.get("target/repositories") );
+ try {
+ return BasicManagedRepository.newFilesystemInstance(id, name, Paths.get("target/repositories"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
public EditableRemoteRepository createRemoteInstance( String id, String name )
{
- return new BasicRemoteRepository( id, name , Paths.get("target/remotes"));
+ try {
+ return BasicRemoteRepository.newFilesystemInstance(id, name, Paths.get("target/remotes"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicManagedRepository managedRepository = new BasicManagedRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories") );
+ BasicManagedRepository managedRepository;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance(configuration.getId(), configuration.getName(), Paths.get("target/repositories"));
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -132,17 +146,25 @@ public class RepositoryProviderMock implements RepositoryProvider
public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
- BasicManagedRepository managedRepository = new BasicManagedRepository( id, configuration.getName( ), Paths.get("target/repositories") );
- updateManagedInstance( managedRepository, configuration );
- return managedRepository;
+ try {
+ BasicManagedRepository managedRepository = BasicManagedRepository.newFilesystemInstance(id, configuration.getName(), Paths.get("target/repositories"));
+ updateManagedInstance(managedRepository, configuration);
+ return managedRepository;
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
}
@Override
public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicRemoteRepository remoteRepository = new BasicRemoteRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
- updateRemoteInstance( remoteRepository, configuration );
- return remoteRepository;
+ try {
+ BasicRemoteRepository remoteRepository = BasicRemoteRepository.newFilesystemInstance(configuration.getId(), configuration.getName(), Paths.get("target/remotes"));
+ updateRemoteInstance(remoteRepository, configuration);
+ return remoteRepository;
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
}
@Override
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
index 54ec5d0a3..6f45b2051 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resources/archetype-resources/src/test/java/SimpleArtifactConsumerTest.java
@@ -82,7 +82,7 @@ public class SimpleArtifactConsumerTest
Files.createDirectories( repoDir );
repoDir.toFile().deleteOnExit();
- testRepository = new BasicManagedRepository("test-consumer-repository","Test-Consumer-Repository", Paths.get("target/repositories") );
+ testRepository = BasicManagedRepository.newFilesystemInstance("test-consumer-repository","Test-Consumer-Repository", Paths.get("target/repositories") );
testRepository.setLocation( repoDir.toAbsolutePath().toUri() );
repositoryRegistry.putRepository(testRepository);
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
index 0cd2488ae..4c0e24a3d 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/ArtifactMissingChecksumsConsumerTest.java
@@ -49,7 +49,7 @@ public class ArtifactMissingChecksumsConsumerTest
super.setUp();
Path basePath = Paths.get("target/test-classes");
- repoConfig = new BasicManagedRepository( "test-repo", "Test Repository", basePath);
+ repoConfig = BasicManagedRepository.newFilesystemInstance( "test-repo", "Test Repository", basePath);
repoConfig.setLayout( "default" );
repoConfig.setLocation(basePath.resolve("test-repo/" ).toUri() );
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
index 27173cf9a..04b5a6d8a 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/AbstractRepositoryPurgeTest.java
@@ -146,10 +146,9 @@ public abstract class AbstractRepositoryPurgeTest
return path;
}
- public org.apache.archiva.repository.ManagedRepository getRepoConfiguration( String repoId, String repoName ) throws URISyntaxException
- {
+ public org.apache.archiva.repository.ManagedRepository getRepoConfiguration( String repoId, String repoName ) throws URISyntaxException, IOException {
Path basePath = Paths.get("target/test-" + getName()).toAbsolutePath();
- config = new BasicManagedRepository( repoId, repoName, basePath);
+ config = BasicManagedRepository.newFilesystemInstance( repoId, repoName, basePath);
config.addActiveReleaseScheme( ReleaseScheme.RELEASE );
config.addActiveReleaseScheme( ReleaseScheme.SNAPSHOT );
ArtifactCleanupFeature atf = config.getFeature( ArtifactCleanupFeature.class ).get();
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
index b4df20d33..92b5996f0 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
@@ -43,6 +43,7 @@ import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.springframework.stereotype.Service;
+import java.io.IOException;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
@@ -74,13 +75,21 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public EditableManagedRepository createManagedInstance( String id, String name )
{
- return new BasicManagedRepository( id, name, Paths.get("target/repositories") );
+ try {
+ return BasicManagedRepository.newFilesystemInstance( id, name, Paths.get("target/repositories") );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
public EditableRemoteRepository createRemoteInstance( String id, String name )
{
- return new BasicRemoteRepository( id, name, Paths.get("target/remotes") );
+ try {
+ return BasicRemoteRepository.newFilesystemInstance( id, name, Paths.get("target/remotes") );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
@@ -93,7 +102,12 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicManagedRepository managedRepository = new BasicManagedRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories") );
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -140,7 +154,12 @@ public class RepositoryProviderMock implements RepositoryProvider
public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
- BasicManagedRepository managedRepository = new BasicManagedRepository( id, configuration.getName( ), Paths.get("target/repositories") );
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( id, configuration.getName( ), Paths.get("target/repositories") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -148,7 +167,12 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicRemoteRepository remoteRepository = new BasicRemoteRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ BasicRemoteRepository remoteRepository = null;
+ try {
+ remoteRepository = BasicRemoteRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateRemoteInstance( remoteRepository, configuration );
return remoteRepository;
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
index e52baa30d..ba8c79f05 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
@@ -116,7 +116,7 @@ public class NexusIndexerConsumerTest
// initialize to set the file types to be processed
nexusIndexerConsumer.initialize();
- repositoryConfig = new BasicManagedRepository( "test-repo", "Test Repository", Paths.get("target/test-classes") );
+ repositoryConfig = BasicManagedRepository.newFilesystemInstance( "test-repo", "Test Repository", Paths.get("target/test-classes") );
repositoryConfig.setLocation( new URI("target/test-classes/test-repo") );
repositoryConfig.setLayout( "default" );
repositoryConfig.setScanned( true );
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
index a496f83d0..1bab4a8ff 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/ManagedRepositoryContent.java
@@ -42,7 +42,7 @@ import java.util.function.Function;
*
* This interface
*/
-public interface ManagedRepositoryContent extends RepositoryContent, RepositoryStorage
+public interface ManagedRepositoryContent extends RepositoryContent
{
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java
index 384639821..453badc2d 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/Repository.java
@@ -20,6 +20,7 @@ package org.apache.archiva.repository;
*/
import org.apache.archiva.indexer.ArchivaIndexingContext;
+import org.apache.archiva.repository.content.RepositoryStorage;
import org.apache.archiva.repository.features.RepositoryFeature;
import java.net.URI;
@@ -33,7 +34,7 @@ import java.util.Set;
*
* Created by Martin Stockhammer on 21.09.17.
*/
-public interface Repository extends RepositoryEventHandler {
+public interface Repository extends RepositoryEventHandler, RepositoryStorage {
/**
* Return the identifier of the repository. Repository identifier should be unique at least
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java
index abbb8c46c..1f26a5d5e 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/RepositoryProvider.java
@@ -23,6 +23,7 @@ import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.configuration.RepositoryGroupConfiguration;
+import java.io.IOException;
import java.util.Set;
/**
@@ -57,7 +58,7 @@ public interface RepositoryProvider extends RepositoryEventListener
* @param name the repository name
* @return a new created managed repository instance
*/
- EditableManagedRepository createManagedInstance(String id, String name);
+ EditableManagedRepository createManagedInstance(String id, String name) throws IOException;
/**
* Creates a editable remote repository instance. The provider must not check the uniqueness of the
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractManagedRepository.java
index 06cab6b53..41d703ab2 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractManagedRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractManagedRepository.java
@@ -20,11 +20,17 @@ package org.apache.archiva.repository;
*/
+import org.apache.archiva.repository.content.RepositoryStorage;
+import org.apache.archiva.repository.content.StorageAsset;
+
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
+import java.util.function.Consumer;
/**
* Simple implementation of a managed repository.
@@ -36,14 +42,18 @@ public abstract class AbstractManagedRepository extends AbstractRepository imple
private Set<ReleaseScheme> activeReleaseSchemes = new HashSet<>( );
private Set<ReleaseScheme> uActiveReleaseSchemes = Collections.unmodifiableSet( activeReleaseSchemes );
- public AbstractManagedRepository( RepositoryType type, String id, String name, Path basePath )
+ private RepositoryStorage storage;
+
+ public AbstractManagedRepository(RepositoryType type, String id, String name, RepositoryStorage storage)
{
- super( type, id, name, basePath );
+ super( type, id, name, storage );
+ this.storage = storage;
}
- public AbstractManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path basePath )
+ public AbstractManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
{
- super( primaryLocale, type, id, name, basePath );
+ super( primaryLocale, type, id, name, storage );
+ this.storage = storage;
}
@Override
@@ -92,4 +102,6 @@ public abstract class AbstractManagedRepository extends AbstractRepository imple
{
this.activeReleaseSchemes.clear();
}
+
+
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java
index 5c3aebaae..ff2ac062a 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRemoteRepository.java
@@ -20,6 +20,8 @@ package org.apache.archiva.repository;
*/
+import org.apache.archiva.repository.content.RepositoryStorage;
+
import java.nio.file.Path;
import java.time.Duration;
import java.util.Collections;
@@ -44,14 +46,14 @@ public abstract class AbstractRemoteRepository extends AbstractRepository implem
private String proxyId;
private RemoteRepositoryContent content;
- public AbstractRemoteRepository( RepositoryType type, String id, String name , Path repositoryBase)
+ public AbstractRemoteRepository(RepositoryType type, String id, String name , RepositoryStorage storage)
{
- super( type, id, name, repositoryBase );
+ super( type, id, name, storage );
}
- public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path repositoryBase )
+ public AbstractRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
{
- super( primaryLocale, type, id, name, repositoryBase );
+ super( primaryLocale, type, id, name, storage );
}
@Override
@@ -145,7 +147,7 @@ public abstract class AbstractRemoteRepository extends AbstractRepository implem
*/
@Override
public Path getLocalPath() {
- return repositoryBase.resolve(getId());
+ return getStorage().getAsset("").getFilePath();
}
@Override
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java
index 1627ddfaa..de57977f2 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepository.java
@@ -25,6 +25,8 @@ import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.indexer.ArchivaIndexingContext;
+import org.apache.archiva.repository.content.RepositoryStorage;
+import org.apache.archiva.repository.content.StorageAsset;
import org.apache.archiva.repository.features.RepositoryFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.apache.commons.lang.StringUtils;
@@ -32,6 +34,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -42,6 +45,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.function.Consumer;
/**
* Implementation of a repository with the necessary fields for a bare repository.
@@ -73,22 +77,22 @@ public abstract class AbstractRepository implements EditableRepository, Reposito
Map<Class<? extends RepositoryFeature<?>>, RepositoryFeature<?>> featureMap = new HashMap<>( );
- protected Path repositoryBase;
private ArchivaIndexingContext indexingContext;
+ private RepositoryStorage storage;
- public AbstractRepository(RepositoryType type, String id, String name, Path repositoryBase) {
+ public AbstractRepository(RepositoryType type, String id, String name, RepositoryStorage repositoryStorage) {
this.id = id;
this.names.put( primaryLocale, name);
this.type = type;
- this.repositoryBase=repositoryBase;
+ this.storage = repositoryStorage;
}
- public AbstractRepository(Locale primaryLocale, RepositoryType type, String id, String name, Path repositoryBase) {
+ public AbstractRepository(Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage repositoryStorage) {
setPrimaryLocale( primaryLocale );
this.id = id;
this.names.put( primaryLocale, name);
this.type = type;
- this.repositoryBase=repositoryBase;
+ this.storage = repositoryStorage;
}
protected void setPrimaryLocale(Locale locale) {
@@ -139,17 +143,18 @@ public abstract class AbstractRepository implements EditableRepository, Reposito
@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());
- }
+ return storage.getAsset("").getFilePath();
+// 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());
+// }
}
@Override
@@ -324,8 +329,47 @@ public abstract class AbstractRepository implements EditableRepository, Reposito
this.listeners.clear();
}
- protected Path getRepositoryBase() {
- return repositoryBase;
+ @Override
+ public StorageAsset getAsset(String path )
+ {
+ return storage.getAsset(path);
+ }
+
+ @Override
+ public StorageAsset addAsset( String path, boolean container )
+ {
+ return storage.addAsset(path, container);
+ }
+
+ @Override
+ public void removeAsset( StorageAsset asset ) throws IOException
+ {
+ storage.removeAsset(asset);
}
+ @Override
+ public StorageAsset moveAsset( StorageAsset origin, String destination ) throws IOException
+ {
+ return storage.moveAsset(origin, destination);
+ }
+
+ @Override
+ public StorageAsset copyAsset( StorageAsset origin, String destination ) throws IOException
+ {
+ return storage.copyAsset(origin, destination);
+ }
+
+ @Override
+ public void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock ) throws IOException
+ {
+ storage.consumeData(asset, consumerFunction, readLock);
+ }
+
+ protected void setStorage(RepositoryStorage storage) {
+ this.storage = storage;
+ }
+
+ protected RepositoryStorage getStorage() {
+ return storage;
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java
index 48d2d2b0c..2011d4a5c 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/AbstractRepositoryGroup.java
@@ -44,16 +44,14 @@ public class AbstractRepositoryGroup extends AbstractRepository implements Edita
private final ReadWriteLock rwl = new ReentrantReadWriteLock();
- private RepositoryStorage storage;
-
private RepositoryCapabilities capabilities;
- public AbstractRepositoryGroup(RepositoryType type, String id, String name, Path repositoryBase) {
- super(type, id, name, repositoryBase);
+ public AbstractRepositoryGroup(RepositoryType type, String id, String name, RepositoryStorage storage) {
+ super(type, id, name, storage);
}
- public AbstractRepositoryGroup(Locale primaryLocale, RepositoryType type, String id, String name, Path repositoryBase) {
- super(primaryLocale, type, id, name, repositoryBase);
+ public AbstractRepositoryGroup(Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage) {
+ super(primaryLocale, type, id, name, storage);
}
@Override
@@ -173,40 +171,6 @@ public class AbstractRepositoryGroup extends AbstractRepository implements Edita
return mergedIndexTTL;
}
- @Override
- public StorageAsset getAsset(String path) {
- return storage.getAsset(path);
- }
-
- @Override
- public void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException {
- storage.consumeData(asset, consumerFunction, readLock);
- }
-
- @Override
- public StorageAsset addAsset(String path, boolean container) {
- return storage.addAsset(path, container);
- }
-
- @Override
- public void removeAsset(StorageAsset asset) throws IOException {
- storage.removeAsset(asset);
- }
-
- @Override
- public StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException {
- return storage.moveAsset(origin, destination);
- }
-
- @Override
- public StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException {
- return storage.copyAsset(origin, destination);
- }
-
- protected void setStorage(RepositoryStorage storage) {
- this.storage = storage;
- }
-
protected void setCapabilities(RepositoryCapabilities capabilities) {
this.capabilities = capabilities;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicManagedRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicManagedRepository.java
index d45daead6..a16630b4a 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicManagedRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicManagedRepository.java
@@ -19,14 +19,22 @@ package org.apache.archiva.repository;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.common.filelock.FileLockManager;
+import org.apache.archiva.repository.content.FilesystemStorage;
+import org.apache.archiva.repository.content.RepositoryStorage;
+import org.apache.archiva.repository.content.StorageAsset;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.InputStream;
import java.nio.file.Path;
import java.util.Locale;
+import java.util.function.Consumer;
/**
*
@@ -41,7 +49,6 @@ public class BasicManagedRepository extends AbstractManagedRepository
ArtifactCleanupFeature artifactCleanupFeature = new ArtifactCleanupFeature( );
StagingRepositoryFeature stagingRepositoryFeature = new StagingRepositoryFeature( );
-
static final StandardCapabilities CAPABILITIES = new StandardCapabilities( new ReleaseScheme[] {
ReleaseScheme.RELEASE, ReleaseScheme.SNAPSHOT
}, new String[] {"default"}, new String[0], new String[] {
@@ -49,15 +56,15 @@ public class BasicManagedRepository extends AbstractManagedRepository
StagingRepositoryFeature.class.toString()
}, true, true, true, true, true );
- public BasicManagedRepository( String id, String name, Path basePath )
+ public BasicManagedRepository( String id, String name, RepositoryStorage repositoryStorage )
{
- super( RepositoryType.MAVEN, id, name, basePath );
+ super( RepositoryType.MAVEN, id, name, repositoryStorage );
initFeatures();
}
- public BasicManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path basePath )
+ public BasicManagedRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage repositoryStorage )
{
- super( primaryLocale, type, id, name, basePath );
+ super( primaryLocale, type, id, name, repositoryStorage);
initFeatures();
}
@@ -85,4 +92,11 @@ public class BasicManagedRepository extends AbstractManagedRepository
public RepositoryRequestInfo getRequestInfo() {
return null;
}
+
+ public static BasicManagedRepository newFilesystemInstance(String id, String name, Path basePath) throws IOException {
+ FileLockManager lockManager = new DefaultFileLockManager();
+ FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
+ return new BasicManagedRepository(id, name, storage);
+ }
+
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicRemoteRepository.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicRemoteRepository.java
index 81c7b3925..acca83a76 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicRemoteRepository.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/BasicRemoteRepository.java
@@ -19,11 +19,16 @@ package org.apache.archiva.repository;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.common.filelock.FileLockManager;
+import org.apache.archiva.repository.content.FilesystemStorage;
+import org.apache.archiva.repository.content.RepositoryStorage;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
import java.nio.file.Path;
import java.util.Locale;
@@ -49,15 +54,15 @@ public class BasicRemoteRepository extends AbstractRemoteRepository
IndexCreationFeature.class.toString()
}, true, true, true, true, true );
- public BasicRemoteRepository( String id, String name, Path basePath )
+ public BasicRemoteRepository( String id, String name, RepositoryStorage storage)
{
- super( RepositoryType.MAVEN, id, name, basePath);
+ super( RepositoryType.MAVEN, id, name, storage);
initFeatures();
}
- public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, Path basePath )
+ public BasicRemoteRepository( Locale primaryLocale, RepositoryType type, String id, String name, RepositoryStorage storage )
{
- super( primaryLocale, type, id, name, basePath );
+ super( primaryLocale, type, id, name, storage );
initFeatures();
}
@@ -79,4 +84,9 @@ public class BasicRemoteRepository extends AbstractRemoteRepository
}
+ public static BasicRemoteRepository newFilesystemInstance(String id, String name, Path basePath) throws IOException {
+ FileLockManager lockManager = new DefaultFileLockManager();
+ FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
+ return new BasicRemoteRepository(id, name, storage);
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java
index 25e0bc506..344ebe633 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/main/java/org/apache/archiva/repository/content/FilesystemStorage.java
@@ -180,4 +180,8 @@ public class FilesystemStorage implements RepositoryStorage {
return newAsset;
}
+ public FileLockManager getFileLockManager() {
+ return fileLockManager;
+ }
+
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/RepositoryRegistryTest.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/RepositoryRegistryTest.java
index b125f819f..3e66c09c6 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/RepositoryRegistryTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/RepositoryRegistryTest.java
@@ -192,14 +192,14 @@ public class RepositoryRegistryTest
@Test
public void putManagedRepository( ) throws Exception
{
- BasicManagedRepository managedRepository = new BasicManagedRepository( "test001", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
+ BasicManagedRepository managedRepository = BasicManagedRepository.newFilesystemInstance( "test001", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
managedRepository.setDescription( managedRepository.getPrimaryLocale(), "This is just a test" );
repositoryRegistry.putRepository(managedRepository);
assertNotNull(managedRepository.getContent());
assertEquals(6, repositoryRegistry.getRepositories().size());
- managedRepository = new BasicManagedRepository( "central", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
+ managedRepository = BasicManagedRepository.newFilesystemInstance( "central", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
managedRepository.setDescription( managedRepository.getPrimaryLocale(), "This is just a test" );
ManagedRepository updatedRepo = null;
try {
@@ -208,7 +208,7 @@ public class RepositoryRegistryTest
} catch (RepositoryException e) {
// OK
}
- managedRepository = new BasicManagedRepository( "internal", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
+ managedRepository = BasicManagedRepository.newFilesystemInstance( "internal", "Test repo", archivaConfiguration.getRepositoryBaseDir() );
managedRepository.setDescription( managedRepository.getPrimaryLocale(), "This is just a test" );
updatedRepo = repositoryRegistry.putRepository( managedRepository );
@@ -283,7 +283,7 @@ public class RepositoryRegistryTest
@Test
public void putRemoteRepository( ) throws Exception
{
- BasicRemoteRepository remoteRepository = new BasicRemoteRepository( "test001", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
+ BasicRemoteRepository remoteRepository = BasicRemoteRepository.newFilesystemInstance( "test001", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), "This is just a test" );
RemoteRepository newRepo = repositoryRegistry.putRepository(remoteRepository);
@@ -291,7 +291,7 @@ public class RepositoryRegistryTest
assertNotNull(remoteRepository.getContent());
assertEquals(6, repositoryRegistry.getRepositories().size());
- remoteRepository = new BasicRemoteRepository( "internal", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
+ remoteRepository = BasicRemoteRepository.newFilesystemInstance( "internal", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), "This is just a test" );
RemoteRepository updatedRepo = null;
try
@@ -302,7 +302,7 @@ public class RepositoryRegistryTest
// OK
}
- remoteRepository = new BasicRemoteRepository( "central", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
+ remoteRepository = BasicRemoteRepository.newFilesystemInstance( "central", "Test repo", archivaConfiguration.getRemoteRepositoryBaseDir() );
remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), "This is just a test" );
updatedRepo = repositoryRegistry.putRepository( remoteRepository );
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
index 91d584b46..0eb574ed4 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
@@ -171,33 +171,4 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
return null;
}
- @Override
- public StorageAsset getAsset(String path) {
- return null;
- }
-
- @Override
- public void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException {
-
- }
-
- @Override
- public StorageAsset addAsset(String path, boolean container) {
- return null;
- }
-
- @Override
- public void removeAsset(StorageAsset asset) throws IOException {
-
- }
-
- @Override
- public StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException {
- return null;
- }
-
- @Override
- public StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException {
- return null;
- }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
index 36d6a99f2..5d2cd7bff 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
@@ -29,6 +29,7 @@ import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.springframework.stereotype.Service;
+import java.io.IOException;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
@@ -58,15 +59,18 @@ public class RepositoryProviderMock implements RepositoryProvider
}
@Override
- public EditableManagedRepository createManagedInstance( String id, String name )
- {
- return new BasicManagedRepository( id, name, Paths.get("target/repositories") );
+ public EditableManagedRepository createManagedInstance( String id, String name ) throws IOException {
+ return BasicManagedRepository.newFilesystemInstance( id, name, Paths.get("target/repositories") );
}
@Override
public EditableRemoteRepository createRemoteInstance( String id, String name )
{
- return new BasicRemoteRepository( id, name , Paths.get("target/remotes"));
+ try {
+ return BasicRemoteRepository.newFilesystemInstance( id, name , Paths.get("target/remotes"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
@@ -75,9 +79,13 @@ public class RepositoryProviderMock implements RepositoryProvider
}
@Override
- public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
- {
- BasicManagedRepository managedRepository = new BasicManagedRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories") );
+ public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException {
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/repositories") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -121,10 +129,14 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
- public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
- {
+ public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException {
String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
- BasicManagedRepository managedRepository = new BasicManagedRepository( id, configuration.getName( ) , Paths.get("target/repositories"));
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( id, configuration.getName( ) , Paths.get("target/repositories"));
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
managedRepository.getFeature(StagingRepositoryFeature.class).get().setStageRepoNeeded(false);
return managedRepository;
@@ -133,7 +145,12 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicRemoteRepository remoteRepository = new BasicRemoteRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ BasicRemoteRepository remoteRepository = null;
+ try {
+ remoteRepository = BasicRemoteRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateRemoteInstance( remoteRepository, configuration );
return remoteRepository;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
index d09863eee..b26bea9bd 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/main/java/org/apache/archiva/repository/scanner/DefaultRepositoryScanner.java
@@ -35,13 +35,7 @@ import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* DefaultRepositoryScanner
@@ -97,7 +91,7 @@ public class DefaultRepositoryScanner
throw new IllegalArgumentException( "Unable to operate on a null repository." );
}
- StorageAsset repositoryBase = repository.getContent().getAsset("");
+ StorageAsset repositoryBase = repository.getAsset("");
//MRM-1342 Repository statistics report doesn't appear to be working correctly
//create the repo if not existing to have an empty stats
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
index 2537a62ab..3be2e2961 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryContentConsumersTest.java
@@ -76,16 +76,14 @@ public class RepositoryContentConsumersTest
@Inject
ApplicationContext applicationContext;
- protected ManagedRepository createRepository( String id, String name, Path location )
- {
- BasicManagedRepository repo = new BasicManagedRepository( id, name , location.getParent() );
+ protected ManagedRepository createRepository( String id, String name, Path location ) throws IOException {
+ BasicManagedRepository repo = BasicManagedRepository.newFilesystemInstance( id, name , location.getParent() );
repo.setLocation( location.toAbsolutePath().toUri() );
return repo;
}
- protected RemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
- {
- BasicRemoteRepository repo = new BasicRemoteRepository(id, name, Paths.get("remotes"));
+ protected RemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException, IOException {
+ BasicRemoteRepository repo = BasicRemoteRepository.newFilesystemInstance(id, name, Paths.get("remotes"));
repo.setLocation( new URI( url ) );
return repo;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java
index 9e08f64a0..5f6f7e0d5 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/RepositoryScannerTest.java
@@ -67,17 +67,16 @@ public class RepositoryScannerTest
ApplicationContext applicationContext;
protected EditableManagedRepository createRepository( String id, String name, Path location ) throws IOException {
- BasicManagedRepository repo = new BasicManagedRepository(id, name, location.getParent());
- repo.setLocation( location.toAbsolutePath().toUri());
FileLockManager lockManager = new DefaultFileLockManager();
FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
- repo.setContent(new ManagedRepositoryContentMock(repo, storage));
+ BasicManagedRepository repo = new BasicManagedRepository(id, name, storage);
+ repo.setLocation( location.toAbsolutePath().toUri());
+ repo.setContent(new ManagedRepositoryContentMock(repo));
return repo;
}
- protected EditableRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
- {
- BasicRemoteRepository repo = new BasicRemoteRepository(id, name, Paths.get("remotes"));
+ protected EditableRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException, IOException {
+ BasicRemoteRepository repo = BasicRemoteRepository.newFilesystemInstance(id, name, Paths.get("remotes"));
repo.setLocation( new URI( url ) );
return repo;
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
index 6cac73d51..e814a496c 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
@@ -27,20 +27,14 @@ import org.apache.archiva.model.ArtifactReference;
import org.apache.archiva.model.ProjectReference;
import org.apache.archiva.model.VersionedReference;
import org.apache.archiva.repository.*;
-import org.apache.archiva.repository.content.FilesystemAsset;
import org.apache.archiva.repository.content.FilesystemStorage;
-import org.apache.archiva.repository.content.StorageAsset;
import org.apache.commons.lang.StringUtils;
-import org.springframework.stereotype.Service;
-import java.io.IOException;
-import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -55,11 +49,9 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
private ManagedRepository repository;
- private FilesystemStorage storage;
- public ManagedRepositoryContentMock(ManagedRepository repo, FilesystemStorage storage) {
+ public ManagedRepositoryContentMock(ManagedRepository repo) {
this.repository = repo;
- this.storage = storage;
}
@Override
@@ -391,33 +383,4 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
return null;
}
- @Override
- public StorageAsset getAsset(String path) {
- return storage.getAsset(path);
- }
-
- @Override
- public void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException {
- storage.consumeData(asset, consumerFunction, readLock);
- }
-
- @Override
- public StorageAsset addAsset(String path, boolean container) {
- return storage.addAsset(path, container);
- }
-
- @Override
- public void removeAsset(StorageAsset asset) throws IOException {
- storage.removeAsset(asset);
- }
-
- @Override
- public StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException {
- return storage.moveAsset(origin, destination);
- }
-
- @Override
- public StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException {
- return storage.copyAsset(origin, destination);
- }
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java b/archiva-modules/archiva-maven/archiva-maven-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
index 209fa8f99..25a3f9d64 100644
--- a/archiva-modules/archiva-maven/archiva-maven-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
+++ b/archiva-modules/archiva-maven/archiva-maven-converter/src/main/java/org/apache/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java
@@ -99,7 +99,7 @@ public class DefaultLegacyRepositoryConverter
{
String defaultRepositoryUrl = PathUtil.toUrl( repositoryDirectory );
- BasicManagedRepository legacyRepository = new BasicManagedRepository( "legacy", "Legacy Repository", repositoryDirectory.getParent());
+ BasicManagedRepository legacyRepository = BasicManagedRepository.newFilesystemInstance( "legacy", "Legacy Repository", repositoryDirectory.getParent());
legacyRepository.setLocation( legacyRepositoryDirectory.toAbsolutePath().toUri() );
legacyRepository.setLayout( "legacy" );
DefaultFileLockManager lockManager = new DefaultFileLockManager();
diff --git a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
index 71363dc33..ae512f14d 100644
--- a/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-indexer/src/test/java/org/apache/archiva/indexer/maven/MavenIndexManagerTest.java
@@ -183,8 +183,8 @@ public class MavenIndexManagerTest {
private ArchivaIndexingContext createTestContext() throws URISyntaxException, IndexCreationFailedException, IOException {
indexPath = Paths.get("target/repositories/test-repo/.index-test");
FileUtils.deleteDirectory(indexPath);
- repository = new MavenManagedRepository("test-repo", "Test Repo", Paths.get("target/repositories"));
- repository.setLocation(new URI("test-repo"));
+ repository = MavenManagedRepository.newLocalInstance("test-repo", "Test Repo", Paths.get("target/repositories"));
+ // repository.setLocation(new URI("test-repo"));
IndexCreationFeature icf = repository.getFeature(IndexCreationFeature.class).get();
icf.setIndexPath(new URI(".index-test"));
ctx = mavenIndexManager.createContext(repository);
@@ -194,7 +194,7 @@ public class MavenIndexManagerTest {
private ArchivaIndexingContext createTestContextForRemote() throws URISyntaxException, IndexCreationFailedException, IOException {
indexPath = Paths.get("target/repositories/test-repo/.index-test");
Path repoPath = Paths.get("target/repositories").toAbsolutePath();
- repositoryRemote = new MavenRemoteRepository("test-repo", "Test Repo", repoPath);
+ repositoryRemote = MavenRemoteRepository.newLocalInstance("test-repo", "Test Repo", repoPath);
repositoryRemote.setLocation(repoPath.resolve("test-repo").toUri());
RemoteIndexFeature icf = repositoryRemote.getFeature(RemoteIndexFeature.class).get();
icf.setIndexUri(new URI(".index-test"));
diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
index 30f780c70..7e53c1d7d 100644
--- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
+++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/AbstractProxyTestCase.java
@@ -319,7 +319,7 @@ public abstract class AbstractProxyTestCase
protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
throws Exception
{
- ManagedRepository repo = new BasicManagedRepository(id, name, Paths.get(path));
+ ManagedRepository repo = BasicManagedRepository.newFilesystemInstance(id, name, Paths.get(path));
repositoryRegistry.putRepository(repo);
return repositoryRegistry.getManagedRepository(id).getContent();
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
index c3d7c1108..5d2c93b4f 100644
--- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/proxy/HttpProxyTransferTest.java
@@ -94,7 +94,7 @@ public class HttpProxyTransferTest
protected ManagedRepositoryContent createRepository( String id, String name, String path, String layout )
throws Exception
{
- ManagedRepository repo = new BasicManagedRepository(id, name, Paths.get(path));
+ ManagedRepository repo = BasicManagedRepository.newFilesystemInstance(id, name, Paths.get(path));
repositoryRegistry.putRepository(repo);
return repositoryRegistry.getManagedRepository(id).getContent();
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
index 376bc00bb..2f10b16b5 100644
--- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
+++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
@@ -389,33 +389,4 @@ public class ManagedRepositoryContentMock implements ManagedRepositoryContent
return null;
}
- @Override
- public StorageAsset getAsset(String path) {
- return null;
- }
-
- @Override
- public void consumeData(StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock) throws IOException {
-
- }
-
- @Override
- public StorageAsset addAsset(String path, boolean container) {
- return null;
- }
-
- @Override
- public void removeAsset(StorageAsset asset) throws IOException {
-
- }
-
- @Override
- public StorageAsset moveAsset(StorageAsset origin, String destination) throws IOException {
- return null;
- }
-
- @Override
- public StorageAsset copyAsset(StorageAsset origin, String destination) throws IOException {
- return null;
- }
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
index cae8337b3..747f64e30 100644
--- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
+++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/RepositoryProviderMock.java
@@ -43,6 +43,7 @@ import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.features.StagingRepositoryFeature;
import org.springframework.stereotype.Service;
+import java.io.IOException;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
@@ -72,15 +73,18 @@ public class RepositoryProviderMock implements RepositoryProvider
}
@Override
- public EditableManagedRepository createManagedInstance( String id, String name )
- {
- return new BasicManagedRepository( id, name , Paths.get("target/repositories"));
+ public EditableManagedRepository createManagedInstance( String id, String name ) throws IOException {
+ return BasicManagedRepository.newFilesystemInstance( id, name , Paths.get("target/repositories"));
}
@Override
public EditableRemoteRepository createRemoteInstance( String id, String name )
{
- return new BasicRemoteRepository( id, name, Paths.get("target/remotes") );
+ try {
+ return BasicRemoteRepository.newFilesystemInstance( id, name, Paths.get("target/remotes") );
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
@Override
@@ -92,7 +96,12 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public ManagedRepository createManagedInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicManagedRepository managedRepository = new BasicManagedRepository( configuration.getId( ), configuration.getName( ) , Paths.get("target/repositories"));
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ) , Paths.get("target/repositories"));
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -139,7 +148,12 @@ public class RepositoryProviderMock implements RepositoryProvider
public ManagedRepository createStagingInstance( ManagedRepositoryConfiguration configuration ) throws RepositoryException
{
String id = configuration.getId( ) + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
- BasicManagedRepository managedRepository = new BasicManagedRepository( id, configuration.getName( ), Paths.get("target/repositories") );
+ BasicManagedRepository managedRepository = null;
+ try {
+ managedRepository = BasicManagedRepository.newFilesystemInstance( id, configuration.getName( ), Paths.get("target/repositories") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateManagedInstance( managedRepository, configuration );
return managedRepository;
}
@@ -147,7 +161,12 @@ public class RepositoryProviderMock implements RepositoryProvider
@Override
public RemoteRepository createRemoteInstance( RemoteRepositoryConfiguration configuration ) throws RepositoryException
{
- BasicRemoteRepository remoteRepository = new BasicRemoteRepository( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ BasicRemoteRepository remoteRepository = null;
+ try {
+ remoteRepository = BasicRemoteRepository.newFilesystemInstance( configuration.getId( ), configuration.getName( ), Paths.get("target/remotes") );
+ } catch (IOException e) {
+ throw new RepositoryException(e);
+ }
updateRemoteInstance( remoteRepository, configuration );
return remoteRepository;
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java
index e76b92c55..01e429e6d 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/content/maven2/ManagedDefaultRepositoryContent.java
@@ -67,8 +67,6 @@ public class ManagedDefaultRepositoryContent
implements ManagedRepositoryContent
{
- private FilesystemStorage storage;
-
private FileTypes filetypes;
public void setFileTypes(FileTypes fileTypes) {
@@ -421,13 +419,6 @@ public class ManagedDefaultRepositoryContent
if (repository instanceof EditableManagedRepository) {
((EditableManagedRepository) repository).setContent(this);
}
- final Path repositoryDir = getRepoDir();
- try {
- storage = new FilesystemStorage(repositoryDir, this.lockManager);
- } catch (IOException e) {
- log.error("Could not initialize the filesystem storage to repository {}: {}", repositoryDir, e.getMessage(), e);
- throw new RuntimeException("Fatal error. Could not initialize the filesystem storage for "+repositoryDir+": "+e.getMessage());
- }
}
}
@@ -545,42 +536,4 @@ public class ManagedDefaultRepositoryContent
}
- @Override
- public void consumeData( StorageAsset asset, Consumer<InputStream> consumerFunction, boolean readLock ) throws IOException
- {
- storage.consumeData(asset, consumerFunction, readLock);
- }
-
-
- @Override
- public StorageAsset getAsset( String path )
- {
- return storage.getAsset(path);
- }
-
- @Override
- public StorageAsset addAsset( String path, boolean container )
- {
- return storage.addAsset(path, container);
- }
-
- @Override
- public void removeAsset( StorageAsset asset ) throws IOException
- {
- storage.removeAsset(asset);
- }
-
- @Override
- public StorageAsset moveAsset( StorageAsset origin, String destination ) throws IOException
- {
- return storage.moveAsset(origin, destination);
- }
-
- @Override
- public StorageAsset copyAsset( StorageAsset origin, String destination ) throws IOException
- {
- return storage.copyAsset(origin, destination);
- }
-
-
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java
index be4756b42..026990e87 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenManagedRepository.java
@@ -19,8 +19,12 @@ package org.apache.archiva.repository.maven2;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.repository.*;
+import org.apache.archiva.repository.content.FilesystemStorage;
+import org.apache.archiva.repository.content.RepositoryStorage;
import org.apache.archiva.repository.content.maven2.MavenRepositoryRequestInfo;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
@@ -65,17 +69,18 @@ public class MavenManagedRepository extends AbstractManagedRepository
false
);
- public MavenManagedRepository( String id, String name, Path basePath )
+ public MavenManagedRepository(String id, String name, FilesystemStorage storage)
{
- super( RepositoryType.MAVEN, id, name, basePath);
+
+ super( RepositoryType.MAVEN, id, name, storage);
this.indexCreationFeature = new IndexCreationFeature(this, this);
- setLocation(basePath.resolve(id).toUri());
+ setLocation(storage.getAsset("").getFilePath().toUri());
}
- public MavenManagedRepository( Locale primaryLocale, String id, String name, Path basePath )
+ public MavenManagedRepository( Locale primaryLocale, String id, String name, FilesystemStorage storage )
{
- super( primaryLocale, RepositoryType.MAVEN, id, name, basePath );
- setLocation(basePath.resolve(id).toUri());
+ super( primaryLocale, RepositoryType.MAVEN, id, name, storage );
+ setLocation(storage.getAsset("").getFilePath().toUri());
}
@Override
@@ -121,22 +126,44 @@ public class MavenManagedRepository extends AbstractManagedRepository
@Override
public void setLocation( URI location )
{
- super.setLocation( location );
+ URI previousLocation = super.getLocation();
+ Path previousLoc = PathUtil.getPathFromUri(previousLocation);
Path newLoc = PathUtil.getPathFromUri( location );
- if (!Files.exists( newLoc )) {
- try
- {
- Files.createDirectories( newLoc );
+ if (!newLoc.toAbsolutePath().equals(previousLoc.toAbsolutePath())) {
+ super.setLocation(location);
+ if (!Files.exists(newLoc)) {
+ try {
+ Files.createDirectories(newLoc);
+ } catch (IOException e) {
+ log.error("Could not create directory {}", location, e);
+ }
}
- catch ( IOException e )
- {
- log.error("Could not create directory {}",location, e);
+ FilesystemStorage previous = (FilesystemStorage) getStorage();
+ try {
+ FilesystemStorage fs = new FilesystemStorage(newLoc, previous.getFileLockManager());
+ setStorage(fs);
+ } catch (IOException e) {
+ log.error("Could not create new filesystem storage at {}", newLoc);
+ try {
+ Path tmpDir = Files.createTempDirectory("tmp-repo-"+getId());
+ FilesystemStorage fs = new FilesystemStorage(tmpDir, previous.getFileLockManager());
+ setStorage(fs);
+ } catch (IOException ex) {
+ throw new RuntimeException("Could not setup storage for repository "+getId());
+ }
}
}
+
}
@Override
public RepositoryRequestInfo getRequestInfo() {
return new MavenRepositoryRequestInfo(this);
}
+
+ public static MavenManagedRepository newLocalInstance(String id, String name, Path basePath) throws IOException {
+ FileLockManager lockManager = new DefaultFileLockManager();
+ FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
+ return new MavenManagedRepository(id, name, storage);
+ }
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java
index 1933554ac..f3380c0ec 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRemoteRepository.java
@@ -1,5 +1,7 @@
package org.apache.archiva.repository.maven2;
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
+import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.repository.AbstractRemoteRepository;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RemoteRepository;
@@ -7,12 +9,14 @@ import org.apache.archiva.repository.RepositoryCapabilities;
import org.apache.archiva.repository.RepositoryType;
import org.apache.archiva.repository.StandardCapabilities;
import org.apache.archiva.repository.UnsupportedFeatureException;
+import org.apache.archiva.repository.content.FilesystemStorage;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.archiva.repository.features.RepositoryFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
import java.nio.file.Path;
import java.util.Locale;
@@ -59,16 +63,16 @@ public class MavenRemoteRepository extends AbstractRemoteRepository
false
);
- public MavenRemoteRepository( String id, String name, Path basePath )
+ public MavenRemoteRepository(String id, String name, FilesystemStorage storage)
{
- super( RepositoryType.MAVEN, id, name, basePath );
+ super( RepositoryType.MAVEN, id, name, storage );
this.indexCreationFeature = new IndexCreationFeature(this, this);
}
- public MavenRemoteRepository( Locale primaryLocale, String id, String name, Path basePath )
+ public MavenRemoteRepository( Locale primaryLocale, String id, String name, FilesystemStorage storage )
{
- super( primaryLocale, RepositoryType.MAVEN, id, name, basePath );
+ super( primaryLocale, RepositoryType.MAVEN, id, name, storage );
this.indexCreationFeature = new IndexCreationFeature(this, this);
}
@@ -111,4 +115,10 @@ public class MavenRemoteRepository extends AbstractRemoteRepository
public String toString() {
return super.toString()+", remoteIndexFeature="+remoteIndexFeature.toString()+", indexCreationFeature="+indexCreationFeature.toString();
}
+
+ public static MavenRemoteRepository newLocalInstance(String id, String name, Path basePath) throws IOException {
+ FileLockManager lockManager = new DefaultFileLockManager();
+ FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
+ return new MavenRemoteRepository(id, name, storage);
+ }
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java
index 094d18275..56e65a2bd 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryGroup.java
@@ -19,6 +19,7 @@ package org.apache.archiva.repository.maven2;
* under the License.
*/
+import org.apache.archiva.common.filelock.DefaultFileLockManager;
import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.FilesystemStorage;
@@ -47,41 +48,32 @@ public class MavenRepositoryGroup extends AbstractRepositoryGroup implements Edi
private final Logger log = LoggerFactory.getLogger(MavenRepositoryGroup.class);
- private FileLockManager lockManager;
- private FilesystemStorage fsStorage;
private IndexCreationFeature indexCreationFeature;
- public MavenRepositoryGroup(String id, String name, Path repositoryBase, FileLockManager lockManager) {
- super(RepositoryType.MAVEN, id, name, repositoryBase);
- this.lockManager = lockManager;
+ public MavenRepositoryGroup(String id, String name, FilesystemStorage storage) {
+ super(RepositoryType.MAVEN, id, name, storage);
init();
}
- public MavenRepositoryGroup(Locale primaryLocale, String id, String name, Path repositoryBase, FileLockManager lockManager) {
- super(primaryLocale, RepositoryType.MAVEN, id, name, repositoryBase);
- this.lockManager = lockManager;
+ public MavenRepositoryGroup(Locale primaryLocale, String id, String name, FilesystemStorage storage) {
+ super(primaryLocale, RepositoryType.MAVEN, id, name, storage);
init();
}
private Path getRepositoryPath() {
- return getRepositoryBase().resolve(getId());
+ return getStorage().getAsset("").getFilePath();
}
private void init() {
setCapabilities(CAPABILITIES);
- try {
- Path repoPath = getRepositoryPath();
- if (!Files.exists(repoPath)) {
- Files.createDirectories(repoPath);
- }
- fsStorage = new FilesystemStorage(getRepositoryPath(), lockManager);
- } catch (IOException e) {
- log.error("IOException while initializing repository group with path {}",getRepositoryBase());
- throw new RuntimeException("Fatal error while accessing repository path "+ getRepositoryBase(), e);
- }
- setStorage(fsStorage);
this.indexCreationFeature = new IndexCreationFeature(this, this);
addFeature( this.indexCreationFeature );
}
+
+ public static MavenRepositoryGroup newLocalInstance(String id, String name, Path basePath) throws IOException {
+ FileLockManager lockManager = new DefaultFileLockManager();
+ FilesystemStorage storage = new FilesystemStorage(basePath.resolve(id), lockManager);
+ return new MavenRepositoryGroup(id, name, storage);
+ }
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java
index 211c2e720..ee21a79f6 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven2/MavenRepositoryProvider.java
@@ -23,6 +23,7 @@ import org.apache.archiva.common.filelock.FileLockManager;
import org.apache.archiva.configuration.*;
import org.apache.archiva.repository.*;
import org.apache.archiva.repository.content.FilesystemAsset;
+import org.apache.archiva.repository.content.FilesystemStorage;
import org.apache.archiva.repository.features.ArtifactCleanupFeature;
import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
@@ -76,18 +77,51 @@ public class MavenRepositoryProvider implements RepositoryProvider {
}
@Override
- public EditableManagedRepository createManagedInstance(String id, String name) {
- return new MavenManagedRepository(id, name, archivaConfiguration.getRepositoryBaseDir());
+ public MavenManagedRepository createManagedInstance(String id, String name) {
+ return createManagedInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir());
+ }
+
+ public MavenManagedRepository createManagedInstance(String id, String name, Path baseDir) {
+ FilesystemStorage storage = null;
+ try {
+ storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
+ } catch (IOException e) {
+ log.error("Could not initialize fileystem for repository {}", id);
+ throw new RuntimeException(e);
+ }
+ return new MavenManagedRepository(id, name, storage);
}
@Override
- public EditableRemoteRepository createRemoteInstance(String id, String name) {
- return new MavenRemoteRepository(id, name, archivaConfiguration.getRemoteRepositoryBaseDir());
+ public MavenRemoteRepository createRemoteInstance(String id, String name) {
+ return createRemoteInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir());
+ }
+
+ public MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir) {
+ FilesystemStorage storage = null;
+ try {
+ storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
+ } catch (IOException e) {
+ log.error("Could not initialize fileystem for repository {}", id);
+ throw new RuntimeException(e);
+ }
+ return new MavenRemoteRepository(id, name, storage);
}
@Override
public EditableRepositoryGroup createRepositoryGroup(String id, String name) {
- return new MavenRepositoryGroup(id, name, archivaConfiguration.getRepositoryBaseDir(), fileLockManager);
+ return createRepositoryGroup(id, name, archivaConfiguration.getRepositoryBaseDir());
+ }
+
+ public MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir) {
+ FilesystemStorage storage = null;
+ try {
+ storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
+ } catch (IOException e) {
+ log.error("Could not initialize fileystem for repository {}", id);
+ throw new RuntimeException(e);
+ }
+ return new MavenRepositoryGroup(id, name, storage);
}
private URI getURIFromString(String uriStr) throws RepositoryException {
@@ -121,7 +155,7 @@ public class MavenRepositoryProvider implements RepositoryProvider {
@Override
public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg) throws RepositoryException {
- MavenManagedRepository repo = new MavenManagedRepository(cfg.getId(), cfg.getName(), archivaConfiguration.getRepositoryBaseDir());
+ MavenManagedRepository repo = createManagedInstance(cfg.getId(), cfg.getName(), Paths.get(cfg.getLocation()).getParent());
updateManagedInstance(repo, cfg);
return repo;
}
@@ -181,7 +215,7 @@ public class MavenRepositoryProvider implements RepositoryProvider {
@Override
public RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg) throws RepositoryException {
- MavenRemoteRepository repo = new MavenRemoteRepository(cfg.getId(), cfg.getName(), archivaConfiguration.getRemoteRepositoryBaseDir());
+ MavenRemoteRepository repo = createRemoteInstance(cfg.getId(), cfg.getName(), archivaConfiguration.getRemoteRepositoryBaseDir());
updateRemoteInstance(repo, cfg);
return repo;
}
@@ -249,8 +283,8 @@ public class MavenRepositoryProvider implements RepositoryProvider {
@Override
public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException {
Path repositoryGroupBase = getArchivaConfiguration().getRepositoryGroupBaseDir();
- MavenRepositoryGroup newGrp = new MavenRepositoryGroup(configuration.getId(), configuration.getName(),
- repositoryGroupBase, fileLockManager);
+ MavenRepositoryGroup newGrp = createRepositoryGroup(configuration.getId(), configuration.getName(),
+ repositoryGroupBase);
updateRepositoryGroupInstance(newGrp, configuration);
return newGrp;
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java
index 0c2fdbd78..2dce57074 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java
@@ -29,6 +29,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
@@ -49,16 +50,14 @@ public abstract class AbstractRepositoryLayerTestCase
@Inject
protected ApplicationContext applicationContext;
- protected MavenManagedRepository createRepository( String id, String name, Path location )
- {
- MavenManagedRepository repo = new MavenManagedRepository( id, name, location.getParent().toAbsolutePath());
+ protected MavenManagedRepository createRepository( String id, String name, Path location ) throws IOException {
+ MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent().toAbsolutePath());
repo.setLocation( location.toAbsolutePath().toUri() );
return repo;
}
- protected MavenRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException
- {
- MavenRemoteRepository repo = new MavenRemoteRepository(id, name, Paths.get("target/remotes"));
+ protected MavenRemoteRepository createRemoteRepository( String id, String name, String url ) throws URISyntaxException, IOException {
+ MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance(id, name, Paths.get("target/remotes"));
repo.setLocation( new URI( url ) );
return repo;
}
@@ -67,7 +66,7 @@ public abstract class AbstractRepositoryLayerTestCase
String layout )
throws Exception
{
- MavenManagedRepository repo = new MavenManagedRepository( id, name, location.getParent() );
+ MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent() );
repo.setLocation( location.toAbsolutePath().toUri() );
repo.setLayout( layout );
@@ -81,7 +80,7 @@ public abstract class AbstractRepositoryLayerTestCase
protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout )
throws Exception
{
- MavenRemoteRepository repo = new MavenRemoteRepository(id, name, Paths.get("target/remotes"));
+ MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance(id, name, Paths.get("target/remotes"));
repo.setLocation( new URI( url ) );
repo.setLayout( layout );
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/content/maven2/MavenRepositoryRequestInfoTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/content/maven2/MavenRepositoryRequestInfoTest.java
index 783970784..85ed97d6e 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/content/maven2/MavenRepositoryRequestInfoTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/content/maven2/MavenRepositoryRequestInfoTest.java
@@ -40,6 +40,7 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import javax.inject.Named;
+import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
@@ -74,9 +75,8 @@ public class MavenRepositoryRequestInfoTest
private MavenRepositoryRequestInfo repoRequest;
- protected MavenManagedRepository createRepository( String id, String name, Path location )
- {
- MavenManagedRepository repo = new MavenManagedRepository( id, name, location.getParent().toAbsolutePath());
+ protected MavenManagedRepository createRepository( String id, String name, Path location ) throws IOException {
+ MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, location.getParent().toAbsolutePath());
repo.setLocation( location.toAbsolutePath().toUri() );
return repo;
}
@@ -549,7 +549,7 @@ public class MavenRepositoryRequestInfoTest
String layout )
throws Exception
{
- MavenManagedRepository repo = new MavenManagedRepository( id, name, archivaConfiguration.getRepositoryBaseDir());
+ MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( id, name, archivaConfiguration.getRepositoryBaseDir());
repo.setLocation( location.toAbsolutePath().toUri() );
repo.setLayout( layout );
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java
index 39396d6d5..3fa8cfa33 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven2/MavenRepositoryProviderTest.java
@@ -36,6 +36,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
@@ -217,7 +218,7 @@ public class MavenRepositoryProviderTest
@Test
public void getManagedConfiguration() throws Exception {
- MavenManagedRepository repo = new MavenManagedRepository( "test01", "My Test repo", Paths.get("target/repositories") );
+ MavenManagedRepository repo = MavenManagedRepository.newLocalInstance( "test01", "My Test repo", Paths.get("target/repositories") );
repo.setLocation( new URI("file:///this.is/a/test") );
repo.setScanned( true );
@@ -262,7 +263,7 @@ public class MavenRepositoryProviderTest
@Test
public void getRemoteConfiguration() throws Exception {
- MavenRemoteRepository repo = new MavenRemoteRepository( "test01", "My Test repo", Paths.get("target/remotes") );
+ MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance( "test01", "My Test repo", Paths.get("target/remotes") );
repo.setLocation( new URI("https://this.is/a/test") );
repo.setScanned( true );
@@ -296,12 +297,10 @@ public class MavenRepositoryProviderTest
}
@Test
- public void getRepositoryGroupConfiguration() throws RepositoryException, URISyntaxException
- {
- MavenRepositoryGroup repositoryGroup = new MavenRepositoryGroup("group1","group1",Paths.get("target/groups"),
- new DefaultFileLockManager());
- MavenManagedRepository repo1 = new MavenManagedRepository( "test01", "My Test repo", Paths.get("target/repositories") );
- MavenManagedRepository repo2 = new MavenManagedRepository( "test02", "My Test repo", Paths.get("target/repositories") );
+ public void getRepositoryGroupConfiguration() throws RepositoryException, URISyntaxException, IOException {
+ MavenRepositoryGroup repositoryGroup = MavenRepositoryGroup.newLocalInstance("group1","group1",Paths.get("target/groups"));
+ MavenManagedRepository repo1 = MavenManagedRepository.newLocalInstance( "test01", "My Test repo", Paths.get("target/repositories") );
+ MavenManagedRepository repo2 = MavenManagedRepository.newLocalInstance( "test02", "My Test repo", Paths.get("target/repositories") );
repositoryGroup.setDescription(repositoryGroup.getPrimaryLocale(), "Repository group");
diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java
index dd4ecd91c..2adc0fc06 100644
--- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/metadata/Maven2RepositoryStorageTest.java
@@ -29,6 +29,7 @@ import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
import javax.inject.Named;
+import java.io.IOException;
import java.nio.file.Paths;
/**
@@ -43,21 +44,20 @@ public class Maven2RepositoryStorageTest
RepositoryStorage repositoryStorage;
@Test
- public void testGetLogicalPath()
- {
+ public void testGetLogicalPath() throws IOException {
String href = "/repository/internal/org/apache/maven/someartifact.jar";
Assert.assertEquals( "/org/apache/maven/someartifact.jar",
- repositoryStorage.getFilePath( href, new MavenManagedRepository( "repo01", "repo01", Paths.get("target/repositories")) ) );
+ repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance( "repo01", "repo01", Paths.get("target/repositories")) ) );
href = "repository/internal/org/apache/maven/someartifact.jar";
Assert.assertEquals( "/org/apache/maven/someartifact.jar",
- repositoryStorage.getFilePath( href, new MavenManagedRepository( "repo01", "repo01", Paths.get("target/repositories") ) ) );
+ repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance( "repo01", "repo01", Paths.get("target/repositories") ) ) );
href = "repository/internal/org/apache/maven/";
- Assert.assertEquals( "/org/apache/maven/", repositoryStorage.getFilePath( href, new MavenManagedRepository("repo01", "repo01", Paths.get("target/repositories")) ) );
+ Assert.assertEquals( "/org/apache/maven/", repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance("repo01", "repo01", Paths.get("target/repositories")) ) );
href = "mypath";
- Assert.assertEquals( "/", repositoryStorage.getFilePath( href, new MavenManagedRepository("repo01", "repo01", Paths.get("target/repositories")) ) );
+ Assert.assertEquals( "/", repositoryStorage.getFilePath( href, MavenManagedRepository.newLocalInstance("repo01", "repo01", Paths.get("target/repositories")) ) );
}
diff --git a/archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/scheduler/indexing/maven/ArchivaIndexingTaskExecutorTest.java b/archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/scheduler/indexing/maven/ArchivaIndexingTaskExecutorTest.java
index a8ace80c1..80f70ac42 100644
--- a/archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/scheduler/indexing/maven/ArchivaIndexingTaskExecutorTest.java
+++ b/archiva-modules/archiva-maven/archiva-maven-scheduler/src/test/java/org/apache/archiva/scheduler/indexing/maven/ArchivaIndexingTaskExecutorTest.java
@@ -89,7 +89,7 @@ public class ArchivaIndexingTaskExecutorTest
super.setUp();
Path baseDir = Paths.get(System.getProperty("basedir"), "target/test-classes").toAbsolutePath();
- BasicManagedRepository repositoryConfig = new BasicManagedRepository( "test-repo", "Test Repository", baseDir);
+ BasicManagedRepository repositoryConfig = BasicManagedRepository.newFilesystemInstance( "test-repo", "Test Repository", baseDir);
Path repoLocation = baseDir.resolve("test-repo" );
repositoryConfig.setLocation(repoLocation.toUri() );
repositoryConfig.setLayout( "default" );
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
index 62fc14922..46c920c9a 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java
@@ -574,12 +574,12 @@ public class ArchivaDavResourceFactory
path = path.substring( 1 );
}
LogicalResource logicalResource = new LogicalResource( path );
- StorageAsset repoAsset = managedRepositoryContent.getAsset( path );
+ StorageAsset repoAsset = managedRepository.getAsset( path );
// Path resourceFile = Paths.get( managedRepositoryContent.getRepoRoot(), path );
try
{
resource =
- new ArchivaDavResource( repoAsset, path, managedRepositoryContent,
+ new ArchivaDavResource( repoAsset, path, managedRepository,
request.getRemoteAddr(), activePrincipal, request.getDavSession(),
archivaLocator, this, mimeTypes, auditListeners, scheduler );
}
@@ -612,10 +612,10 @@ public class ArchivaDavResourceFactory
// Perform an adjustment of the resource to the managed
// repository expected path.
// String localResourcePath = managedRepository.getRequestInfo().toNativePath( logicalResource.getPath() );
- resourceAsset = managedRepositoryContent.getAsset( logicalResource.getPath() );
+ resourceAsset = managedRepository.getAsset( logicalResource.getPath() );
resource =
new ArchivaDavResource( resourceAsset, logicalResource.getPath(),
- managedRepositoryContent,
+ managedRepository,
request.getRemoteAddr(), activePrincipal,
request.getDavSession(), archivaLocator, this, mimeTypes,
auditListeners, scheduler );
@@ -740,11 +740,11 @@ public class ArchivaDavResourceFactory
{
logicalResource = logicalResource.substring( 1 );
}
- StorageAsset resourceAsset = managedRepositoryContent.getAsset( logicalResource );
+ StorageAsset resourceAsset = repo.getAsset( logicalResource );
try
{
resource = new ArchivaDavResource( resourceAsset, logicalResource,
- repo.getContent(), davSession, archivaLocator,
+ repo, davSession, archivaLocator,
this, mimeTypes, auditListeners, scheduler);
}
catch ( LayoutException e )
@@ -1108,7 +1108,7 @@ public class ArchivaDavResourceFactory
"Invalid managed repository <" + repo.getId() + ">");
}
// Path resourceFile = Paths.get( managedRepository.getRepoRoot(), logicalResource.getPath() );
- StorageAsset resourceFile = managedRepository.getAsset(logicalResource.getPath());
+ StorageAsset resourceFile = repo.getAsset(logicalResource.getPath());
if ( resourceFile.exists() && managedRepository.getRepository().supportsFeature( IndexCreationFeature.class ))
{
// in case of group displaying index directory doesn't have sense !!
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
index b9d05aa89..8e09cd08c 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/RepositoryServlet.java
@@ -184,7 +184,7 @@ public class RepositoryServlet
fillRepositoryMap();
for (ManagedRepository repo : repositoryMap.values()) {
- StorageAsset repoDir = repo.getContent().getAsset("");
+ StorageAsset repoDir = repo.getAsset("");
if (!repoDir.exists()) {
try {
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
index 97fb811cb..6eb286729 100644
--- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
+++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/DavResourceTest.java
@@ -97,7 +97,7 @@ public class DavResourceTest
baseDir = Paths.get( "target/DavResourceTest" );
Files.createDirectories( baseDir );
Files.createDirectories( baseDir.resolve( "conf" ) );
- repository = new MavenManagedRepository( "repo001", "repo001", baseDir);
+ repository = MavenManagedRepository.newLocalInstance( "repo001", "repo001", baseDir);
repositoryRegistry.putRepository( repository );
myResource = baseDir.resolve( "myresource.jar" );
@@ -127,7 +127,7 @@ public class DavResourceTest
private DavResource getDavResource( String logicalPath, Path file ) throws LayoutException
{
- return new ArchivaDavResource( new FilesystemAsset( logicalPath, file.toAbsolutePath()) , logicalPath, repository.getContent(), session, resourceLocator,
+ return new ArchivaDavResource( new FilesystemAsset( logicalPath, file.toAbsolutePath()) , logicalPath, repository, session, resourceLocator,
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(), null);
}
@@ -349,7 +349,7 @@ public class DavResourceTest
{
try
{
- return new ArchivaDavResource( new FilesystemAsset( "/" , baseDir.toAbsolutePath()), "/", repository.getContent(), session, resourceLocator,
+ return new ArchivaDavResource( new FilesystemAsset( "/" , baseDir.toAbsolutePath()), "/", repository, session, resourceLocator,
resourceFactory, mimeTypes, Collections.<AuditListener> emptyList(),
null );
}
diff --git a/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java b/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
index 5781dc579..97a2be68e 100644
--- a/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
+++ b/archiva-modules/plugins/problem-reports/src/test/java/org/apache/archiva/reports/consumers/DuplicateArtifactsConsumerTest.java
@@ -95,7 +95,7 @@ public class DuplicateArtifactsConsumerTest
assertNotNull( consumer );
- config = new BasicManagedRepository(TEST_REPO, TEST_REPO, Paths.get("target"));
+ config = BasicManagedRepository.newFilesystemInstance(TEST_REPO, TEST_REPO, Paths.get("target"));
config.setLocation( Paths.get( "target/test-repository" ).toAbsolutePath().toUri() );
metadataRepository = mock( MetadataRepository.class );