diff options
author | Martin Stockhammer <martin_s@apache.org> | 2019-07-11 23:28:01 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2019-07-11 23:28:01 +0200 |
commit | 830ea54e0c64bb5c7fe5b2006c171ebd2625e287 (patch) | |
tree | c6e65a81b5e92e6aa2f662398e1f32de5c7e8875 /archiva-modules/archiva-base/archiva-repository-layer | |
parent | 38b10a09f4c91ba6249baf95b1e4f487cb80ac79 (diff) | |
download | archiva-830ea54e0c64bb5c7fe5b2006c171ebd2625e287.tar.gz archiva-830ea54e0c64bb5c7fe5b2006c171ebd2625e287.zip |
Moving storage api to repository level
Diffstat (limited to 'archiva-modules/archiva-base/archiva-repository-layer')
10 files changed, 160 insertions, 122 deletions
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; } |