Search in sources :

Example 41 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.

the class BasicManagedRepositoryValidatorTest method createRepository.

protected EditableManagedRepository createRepository(String id, String name, Path location) throws IOException {
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
    BasicManagedRepository repo = new BasicManagedRepository(id, name, storage);
    repo.setLocation(location.toAbsolutePath().toUri());
    repo.setContent(new ManagedRepositoryContentMock());
    return repo;
}
Also used : FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) ManagedRepositoryContentMock(org.apache.archiva.repository.mock.ManagedRepositoryContentMock)

Example 42 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.

the class BasicRemoteRepositoryValidatorTest method createRepository.

protected EditableRemoteRepository createRepository(String id, String name, Path location) throws IOException {
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
    BasicRemoteRepository repo = new BasicRemoteRepository(id, name, storage);
    repo.setLocation(location.toAbsolutePath().toUri());
    repo.setContent(new RemoteRepositoryContentMock());
    return repo;
}
Also used : FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) RemoteRepositoryContentMock(org.apache.archiva.repository.mock.RemoteRepositoryContentMock) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

Example 43 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.

the class MavenIndexContext method getPath.

@Override
public StorageAsset getPath() {
    if (dir == null) {
        StorageAsset repositoryDirAsset = repository.getRoot();
        Path repositoryDir = repositoryDirAsset.getFilePath().toAbsolutePath();
        Path indexDir = delegate.getIndexDirectoryFile().toPath();
        if (indexDir.startsWith(repositoryDir)) {
            dir = repository.getAsset(repositoryDir.relativize(indexDir).toString());
        } else {
            try {
                FilesystemStorage storage = new FilesystemStorage(indexDir, new DefaultFileLockManager());
                dir = storage.getRoot();
            } catch (IOException e) {
                log.error("Error occured while creating storage for index dir");
            }
        }
    }
    return dir;
}
Also used : Path(java.nio.file.Path) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) IOException(java.io.IOException)

Example 44 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.

the class FilesystemAssetTest method list.

@Test
public void list() throws IOException {
    FilesystemAsset asset = new FilesystemAsset(filesystemStorage, "/test1234", assetPathFile);
    Assert.assertEquals(0, asset.list().size());
    FilesystemAsset asset2 = new FilesystemAsset(filesystemStorage, "/test1235", assetPathDir);
    Assert.assertEquals(1, asset2.list().size());
    Path f1 = Files.createTempFile(assetPathDir, "testfile", "dat");
    Path f2 = Files.createTempFile(assetPathDir, "testfile", "dat");
    Path d1 = Files.createTempDirectory(assetPathDir, "testdir");
    Assert.assertEquals(4, asset2.list().size());
    Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f1.getFileName().toString())));
    Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(f2.getFileName().toString())));
    Assert.assertTrue(asset2.list().stream().anyMatch(p -> p.getName().equals(d1.getFileName().toString())));
    Files.deleteIfExists(f1);
    Files.deleteIfExists(f2);
    Files.deleteIfExists(d1);
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) Files(java.nio.file.Files) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) IOException(java.io.IOException) Instant(java.time.Instant) IOUtils(org.apache.commons.io.IOUtils) Paths(java.nio.file.Paths) After(org.junit.After) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Assert(org.junit.Assert) Path(java.nio.file.Path) Before(org.junit.Before) InputStream(java.io.InputStream) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) Test(org.junit.Test)

Example 45 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage in project archiva by apache.

the class FilesystemAssetTest method init.

@Before
public void init() throws IOException {
    assetPathDir = Files.createTempDirectory("assetDir");
    assetPathFile = Files.createTempFile(assetPathDir, "assetFile", "dat");
    filesystemStorage = new FilesystemStorage(assetPathDir, new DefaultFileLockManager());
}
Also used : FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) Before(org.junit.Before)

Aggregations

FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)48 DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)42 Path (java.nio.file.Path)26 FileLockManager (org.apache.archiva.common.filelock.FileLockManager)14 FilesystemAsset (org.apache.archiva.repository.storage.fs.FilesystemAsset)13 IOException (java.io.IOException)11 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)9 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)8 BasicManagedRepository (org.apache.archiva.repository.base.managed.BasicManagedRepository)6 ArtifactContentEntry (org.apache.archiva.rest.api.model.ArtifactContentEntry)6 Test (org.junit.Test)6 URI (java.net.URI)5 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 Test (org.junit.jupiter.api.Test)3 Date (java.util.Date)2 MavenMetadataReader (org.apache.archiva.maven.metadata.MavenMetadataReader)2 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)2 UnauthorizedException (org.apache.archiva.redback.authorization.UnauthorizedException)2