Search in sources :

Example 46 with FilesystemStorage

use of org.apache.archiva.repository.storage.fs.FilesystemStorage 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)

Example 47 with FilesystemStorage

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

the class NewVersionsOfArtifactRssFeedProcessorTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    newVersionsProcessor = new NewVersionsOfArtifactRssFeedProcessor();
    newVersionsProcessor.setGenerator(new RssFeedGenerator());
    metadataRepository = mock(MetadataRepository.class);
    sessionFactory = mock(RepositorySessionFactory.class);
    session = mock(RepositorySession.class);
    when(sessionFactory.createSession()).thenReturn(session);
    when(session.getRepository()).thenReturn(metadataRepository);
    repositoryRegistry = mock(ArchivaRepositoryRegistry.class);
    List<Repository> reg = new ArrayList<>();
    reg.add(new BasicManagedRepository(TEST_REPO, TEST_REPO, new FilesystemStorage(Paths.get("target/test-storage"), new DefaultFileLockManager())));
    when(repositoryRegistry.getRepositories()).thenReturn(reg);
    newVersionsProcessor.setRepositorySessionFactory(sessionFactory);
    newVersionsProcessor.setRepositoryRegistry(repositoryRegistry);
}
Also used : MetadataRepository(org.apache.archiva.metadata.repository.MetadataRepository) Repository(org.apache.archiva.repository.Repository) MetadataRepository(org.apache.archiva.metadata.repository.MetadataRepository) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) RepositorySessionFactory(org.apache.archiva.metadata.repository.RepositorySessionFactory) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) ArrayList(java.util.ArrayList) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) RepositorySession(org.apache.archiva.metadata.repository.RepositorySession) RssFeedGenerator(org.apache.archiva.rss.RssFeedGenerator) ArchivaRepositoryRegistry(org.apache.archiva.repository.base.ArchivaRepositoryRegistry) Before(org.junit.Before)

Example 48 with FilesystemStorage

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

the class ArtifactBuilderTest method getFile.

StorageAsset getFile(String path) throws IOException {
    Path filePath = Paths.get(path);
    FilesystemStorage filesystemStorage = new FilesystemStorage(filePath.getParent(), new DefaultFileLockManager());
    return new FilesystemAsset(filesystemStorage, filePath.getFileName().toString(), filePath);
}
Also used : Path(java.nio.file.Path) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) FilesystemAsset(org.apache.archiva.repository.storage.fs.FilesystemAsset) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

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