Search in sources :

Example 1 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class ArchivaIndexingTaskExecutorTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    Path baseDir = Paths.get(System.getProperty("basedir"), "target/test-classes").toAbsolutePath();
    BasicManagedRepository repositoryConfig = BasicManagedRepository.newFilesystemInstance("test-repo", "Test Repository", baseDir.resolve("test-repo"));
    Path repoLocation = baseDir.resolve("test-repo");
    repositoryConfig.setLocation(repoLocation.toUri());
    repositoryConfig.setLayout("default");
    repositoryConfig.setScanned(true);
    repositoryConfig.addActiveReleaseScheme(ReleaseScheme.RELEASE);
    repositoryConfig.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
    repositoryRegistry.putRepository(repositoryConfig);
    repo = repositoryRegistry.getManagedRepository(repositoryConfig.getId());
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) Before(org.junit.Before)

Example 2 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class RepositoryProviderMock method createManagedInstance.

@Override
public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration configuration) throws RepositoryException {
    BasicManagedRepository managedRepository = null;
    try {
        managedRepository = BasicManagedRepository.newFilesystemInstance(configuration.getId(), configuration.getName(), Paths.get("target/repositories").resolve(configuration.getId()));
    } catch (IOException e) {
        throw new RepositoryException(e);
    }
    updateManagedInstance(managedRepository, configuration);
    return managedRepository;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) IOException(java.io.IOException)

Example 3 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class MavenRepositoryMapperTest method reverseMap.

@Test
void reverseMap() throws IOException, URISyntaxException, UnsupportedURIException {
    MavenRepositoryMapper mapper = new MavenRepositoryMapper();
    Path tmpDir = Files.createTempDirectory("mapper-test");
    FilesystemStorage fsStorage = new FilesystemStorage(tmpDir, new DefaultFileLockManager());
    EditableManagedRepository repository = new BasicManagedRepository(Locale.getDefault(), RepositoryType.MAVEN, "repo02", "Repo 02", fsStorage);
    repository.setDescription(Locale.getDefault(), "This is repo 02");
    repository.setBlocksRedeployment(false);
    repository.setLocation(new URI("test-path"));
    repository.setScanned(true);
    repository.setLayout("maven2");
    repository.setSchedulingDefinition("* 3,5,10 * * *");
    IndexCreationFeature icf = repository.getFeature(IndexCreationFeature.class);
    icf.setIndexPath(new URI(".indexer"));
    icf.setPackedIndexPath(new URI(".index"));
    icf.setSkipPackedIndexCreation(false);
    ArtifactCleanupFeature acf = repository.getFeature(ArtifactCleanupFeature.class);
    acf.setDeleteReleasedSnapshots(false);
    acf.setRetentionPeriod(Period.ofDays(5));
    acf.setRetentionCount(17);
    StagingRepositoryFeature srf = repository.getFeature(StagingRepositoryFeature.class);
    srf.setStageRepoNeeded(false);
    MavenManagedRepository result = mapper.reverseMap(repository);
    assertEquals("repo02", result.getId());
    assertEquals("Repo 02", result.getName());
    assertEquals("This is repo 02", result.getDescription());
    assertFalse(result.isBlocksRedeployments());
    assertEquals("test-path", result.getLocation());
    assertTrue(result.isScanned());
    assertEquals("maven2", result.getLayout());
    assertEquals("* 3,5,10 * * *", result.getSchedulingDefinition());
    assertEquals(".indexer", result.getIndexPath());
    assertEquals(".index", result.getPackedIndexPath());
    assertFalse(result.isSkipPackedIndexCreation());
    assertFalse(result.isDeleteSnapshotsOfRelease());
    assertEquals(Period.ofDays(5), result.getRetentionPeriod());
    assertEquals(17, result.getRetentionCount());
    assertFalse(result.hasStagingRepository());
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) MavenManagedRepository(org.apache.archiva.rest.api.v2.model.MavenManagedRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 4 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class MavenRepositoryMapperTest method reverseUpdate.

@Test
void reverseUpdate() throws IOException, URISyntaxException, UnsupportedURIException {
    MavenRepositoryMapper mapper = new MavenRepositoryMapper();
    MavenManagedRepository result = new MavenManagedRepository();
    Path tmpDir = Files.createTempDirectory("mapper-test");
    FilesystemStorage fsStorage = new FilesystemStorage(tmpDir, new DefaultFileLockManager());
    EditableManagedRepository repository = new BasicManagedRepository(Locale.getDefault(), RepositoryType.MAVEN, "repo02", "Repo 02", fsStorage);
    repository.setDescription(Locale.getDefault(), "This is repo 02");
    repository.setBlocksRedeployment(false);
    repository.setLocation(new URI("test-path"));
    repository.setScanned(true);
    repository.setLayout("maven2");
    repository.setSchedulingDefinition("* 3,5,10 * * *");
    IndexCreationFeature icf = repository.getFeature(IndexCreationFeature.class);
    icf.setIndexPath(new URI(".indexer"));
    icf.setPackedIndexPath(new URI(".index"));
    icf.setSkipPackedIndexCreation(false);
    ArtifactCleanupFeature acf = repository.getFeature(ArtifactCleanupFeature.class);
    acf.setDeleteReleasedSnapshots(false);
    acf.setRetentionPeriod(Period.ofDays(5));
    acf.setRetentionCount(17);
    StagingRepositoryFeature srf = repository.getFeature(StagingRepositoryFeature.class);
    srf.setStageRepoNeeded(false);
    mapper.reverseUpdate(repository, result);
    assertEquals("repo02", result.getId());
    assertEquals("Repo 02", result.getName());
    assertEquals("This is repo 02", result.getDescription());
    assertFalse(result.isBlocksRedeployments());
    assertEquals("test-path", result.getLocation());
    assertTrue(result.isScanned());
    assertEquals("maven2", result.getLayout());
    assertEquals("* 3,5,10 * * *", result.getSchedulingDefinition());
    assertEquals(".indexer", result.getIndexPath());
    assertEquals(".index", result.getPackedIndexPath());
    assertFalse(result.isSkipPackedIndexCreation());
    assertFalse(result.isDeleteSnapshotsOfRelease());
    assertEquals(Period.ofDays(5), result.getRetentionPeriod());
    assertEquals(17, result.getRetentionCount());
    assertFalse(result.hasStagingRepository());
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) MavenManagedRepository(org.apache.archiva.rest.api.v2.model.MavenManagedRepository) EditableManagedRepository(org.apache.archiva.repository.EditableManagedRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature) URI(java.net.URI) Test(org.junit.jupiter.api.Test)

Example 5 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class RepositoryProviderMock method createManagedInstance.

@Override
public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration configuration) throws RepositoryException {
    BasicManagedRepository managedRepository;
    try {
        managedRepository = BasicManagedRepository.newFilesystemInstance(configuration.getId(), configuration.getName(), Paths.get("target/repositories"));
    } catch (IOException e) {
        throw new RepositoryException(e);
    }
    updateManagedInstance(managedRepository, configuration);
    return managedRepository;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) IOException(java.io.IOException)

Aggregations

BasicManagedRepository (org.apache.archiva.repository.base.managed.BasicManagedRepository)20 IOException (java.io.IOException)8 RepositoryException (org.apache.archiva.repository.RepositoryException)8 DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)6 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)6 Path (java.nio.file.Path)4 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)4 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)3 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)3 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 FileLockManager (org.apache.archiva.common.filelock.FileLockManager)2 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)2 MavenManagedRepository (org.apache.archiva.rest.api.v2.model.MavenManagedRepository)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)1 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)1 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)1 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)1