Search in sources :

Example 36 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager 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 37 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager 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 38 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager 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 39 with DefaultFileLockManager

use of org.apache.archiva.common.filelock.DefaultFileLockManager 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)

Example 40 with DefaultFileLockManager

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

the class MavenContentHelperTest method getLatestArtifactSnapshotVersion.

@Test
void getLatestArtifactSnapshotVersion() throws URISyntaxException, IOException {
    MavenContentHelper mavenContentHelper = new MavenContentHelper();
    MavenMetadataReader reader = new MavenMetadataReader();
    mavenContentHelper.setMetadataReader(reader);
    Path testRepoPath = Paths.get(Thread.currentThread().getContextClassLoader().getResource("repositories/default-repository").toURI());
    FilesystemStorage storage = new FilesystemStorage(testRepoPath, new DefaultFileLockManager());
    // Directory without metadata file
    assertEquals("2.1-20090808.085535-2", mavenContentHelper.getLatestArtifactSnapshotVersion(storage.getAsset("org/apache/archiva/sample-parent/2.1-SNAPSHOT"), "2.1-SNAPSHOT"));
    // Directory with metadata file
    assertEquals("1.3-20070802.113139-29", mavenContentHelper.getLatestArtifactSnapshotVersion(storage.getAsset("org/apache/axis2/axis2/1.3-SNAPSHOT"), "1.3-SNAPSHOT"));
}
Also used : Path(java.nio.file.Path) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) MavenMetadataReader(org.apache.archiva.maven.metadata.MavenMetadataReader) Test(org.junit.jupiter.api.Test)

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