Search in sources :

Example 16 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager in project archiva by apache.

the class ChecksumPolicyTest method createTestableFiles.

private StorageAsset createTestableFiles(String md5State, String sha1State) throws Exception {
    FilesystemStorage fs = new FilesystemStorage(Paths.get("target/checksum-tests"), new DefaultFileLockManager());
    StorageAsset sourceDir = getTestFile("src/test/resources/checksums/");
    StorageAsset destDir = getTestFile("target/checksum-tests/" + name.getMethodName() + "/");
    FileUtils.copyFileToDirectory(sourceDir.getFilePath().resolve("artifact.jar").toFile(), destDir.getFilePath().toFile());
    if (md5State != null) {
        Path md5File = sourceDir.getFilePath().resolve("artifact.jar.md5-" + md5State);
        assertTrue("Testable file exists: " + md5File.getFileName() + ":", Files.exists(md5File) && Files.isRegularFile(md5File));
        Path destFile = destDir.getFilePath().resolve("artifact.jar.md5");
        FileUtils.copyFile(md5File.toFile(), destFile.toFile());
    }
    if (sha1State != null) {
        Path sha1File = sourceDir.getFilePath().resolve("artifact.jar.sha1-" + sha1State);
        assertTrue("Testable file exists: " + sha1File.getFileName() + ":", Files.exists(sha1File) && Files.isRegularFile(sha1File));
        Path destFile = destDir.getFilePath().resolve("artifact.jar.sha1");
        FileUtils.copyFile(sha1File.toFile(), destFile.toFile());
    }
    StorageAsset localAsset = destDir.resolve("artifact.jar");
    return localAsset;
}
Also used : Path(java.nio.file.Path) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) StorageAsset(org.apache.archiva.repository.storage.StorageAsset) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

Example 17 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager in project archiva by apache.

the class ArchivaIndexManagerMock method getIndexPath.

private StorageAsset getIndexPath(Repository repo) throws IOException {
    IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class);
    Path repoDir = repo.getRoot().getFilePath();
    URI indexDir = icf.getIndexPath();
    String indexPath = indexDir.getPath();
    Path indexDirectory = null;
    FilesystemStorage filesystemStorage = (FilesystemStorage) repo.getRoot().getStorage();
    if (!StringUtils.isEmpty(indexDir.toString())) {
        indexDirectory = PathUtil.getPathFromUri(indexDir);
        // not absolute so create it in repository directory
        if (indexDirectory.isAbsolute()) {
            indexPath = indexDirectory.getFileName().toString();
            filesystemStorage = new FilesystemStorage(indexDirectory.getParent(), new DefaultFileLockManager());
        } else {
            indexDirectory = repoDir.resolve(indexDirectory);
        }
    } else {
        indexDirectory = repoDir.resolve(".index");
        indexPath = ".index";
    }
    if (!Files.exists(indexDirectory)) {
        Files.createDirectories(indexDirectory);
    }
    return new FilesystemAsset(filesystemStorage, indexPath, indexDirectory);
}
Also used : Path(java.nio.file.Path) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) URI(java.net.URI)

Example 18 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager in project archiva by apache.

the class RepositoryGroupHandlerTest method getRemote.

protected RemoteRepository getRemote(String id, String name) throws IOException {
    Path path = getRepoBaseDir().resolve("../remote");
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(path.toAbsolutePath(), lockManager);
    return new BasicRemoteRepository(id, name, storage);
}
Also used : Path(java.nio.file.Path) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) BasicRemoteRepository(org.apache.archiva.repository.base.remote.BasicRemoteRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

Example 19 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager in project archiva by apache.

the class RepositoryGroupHandlerTest method getManaged.

protected ManagedRepository getManaged(String id, String name) throws IOException {
    Path path = getRepoBaseDir().resolve("../managed");
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(path.toAbsolutePath(), lockManager);
    return new BasicManagedRepository(id, name, storage);
}
Also used : Path(java.nio.file.Path) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

Example 20 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager in project archiva by apache.

the class ManagedRepositoryHandlerTest 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());
    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)

Aggregations

DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)42 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)41 Path (java.nio.file.Path)23 FileLockManager (org.apache.archiva.common.filelock.FileLockManager)14 FilesystemAsset (org.apache.archiva.repository.storage.fs.FilesystemAsset)12 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)7 StorageAsset (org.apache.archiva.repository.storage.StorageAsset)7 BasicManagedRepository (org.apache.archiva.repository.base.managed.BasicManagedRepository)6 ArtifactContentEntry (org.apache.archiva.rest.api.model.ArtifactContentEntry)6 IOException (java.io.IOException)5 URI (java.net.URI)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)4 ArrayList (java.util.ArrayList)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 DavException (org.apache.jackrabbit.webdav.DavException)3 Before (org.junit.Before)3 Date (java.util.Date)2 MavenMetadataReader (org.apache.archiva.maven.metadata.MavenMetadataReader)2 ArchivaRepositoryMetadata (org.apache.archiva.model.ArchivaRepositoryMetadata)2