Search in sources :

Example 1 with MavenManagedRepository

use of org.apache.archiva.rest.api.v2.model.MavenManagedRepository in project archiva by apache.

the class DefaultMavenManagedRepositoryService method updateManagedRepository.

@Override
public MavenManagedRepository updateManagedRepository(final String repositoryId, final MavenManagedRepositoryUpdate managedRepository) throws ArchivaRestServiceException {
    org.apache.archiva.admin.model.beans.ManagedRepository repo = convert(managedRepository);
    try {
        managedRepositoryAdmin.updateManagedRepository(repo, managedRepository.hasStagingRepository(), getAuditInformation(), managedRepository.isResetStats());
        ManagedRepository newRepo = repositoryRegistry.getManagedRepository(managedRepository.getId());
        if (newRepo == null) {
            throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.REPOSITORY_UPDATE_FAILED, repositoryId));
        }
        return mapper.reverseMap(newRepo);
    } catch (RepositoryAdminException e) {
        throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.REPOSITORY_ADMIN_ERROR, e.getMessage()));
    }
}
Also used : ManagedRepository(org.apache.archiva.repository.ManagedRepository) MavenManagedRepository(org.apache.archiva.rest.api.v2.model.MavenManagedRepository) ArchivaRestServiceException(org.apache.archiva.rest.api.v2.svc.ArchivaRestServiceException) RepositoryAdminException(org.apache.archiva.admin.model.RepositoryAdminException)

Example 2 with MavenManagedRepository

use of org.apache.archiva.rest.api.v2.model.MavenManagedRepository 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 3 with MavenManagedRepository

use of org.apache.archiva.rest.api.v2.model.MavenManagedRepository in project archiva by apache.

the class MavenRepositoryMapperTest method map.

@Test
void map() {
    MavenRepositoryMapper mapper = new MavenRepositoryMapper();
    MavenManagedRepository repo = new MavenManagedRepository();
    repo.setId("repo01");
    repo.setName("Repo 01");
    repo.setDescription("This is repo 01");
    repo.setLocation("/data/repo01");
    repo.setHasStagingRepository(true);
    repo.setSchedulingDefinition("0,1,2 * * * *");
    repo.setPackedIndexPath(".index");
    repo.setIndexPath(".indexer");
    repo.setIndex(true);
    repo.setDeleteSnapshotsOfRelease(false);
    repo.setBlocksRedeployments(false);
    repo.setReleaseSchemes(Arrays.asList(ReleaseScheme.RELEASE.name(), ReleaseScheme.SNAPSHOT.name()));
    repo.setCharacteristic(Repository.CHARACTERISTIC_MANAGED);
    repo.setScanned(true);
    repo.setRetentionPeriod(Period.ofDays(10));
    repo.setRetentionCount(15);
    repo.setSkipPackedIndexCreation(false);
    repo.setStagingRepository("stage-repo01");
    ManagedRepositoryConfiguration result = mapper.map(repo);
    assertNotNull(result);
    assertEquals("repo01", result.getId());
    assertEquals("Repo 01", result.getName());
    assertEquals("This is repo 01", result.getDescription());
    assertEquals("/data/repo01", result.getLocation());
    assertTrue(result.isStageRepoNeeded());
    assertEquals("0,1,2 * * * *", result.getRefreshCronExpression());
    assertEquals(".indexer", result.getIndexDir());
    assertEquals(".index", result.getPackedIndexDir());
    assertFalse(result.isDeleteReleasedSnapshots());
    assertFalse(result.isBlockRedeployments());
    assertTrue(result.isSnapshots());
    assertTrue(result.isReleases());
    assertTrue(result.isScanned());
    assertEquals(10, result.getRetentionPeriod());
    assertEquals(15, result.getRetentionCount());
    assertFalse(result.isSkipPackedIndexCreation());
}
Also used : ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) MavenManagedRepository(org.apache.archiva.rest.api.v2.model.MavenManagedRepository) Test(org.junit.jupiter.api.Test)

Example 4 with MavenManagedRepository

use of org.apache.archiva.rest.api.v2.model.MavenManagedRepository 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 MavenManagedRepository

use of org.apache.archiva.rest.api.v2.model.MavenManagedRepository in project archiva by apache.

the class MavenRepositoryMapper method reverseMap.

@Override
public MavenManagedRepository reverseMap(ManagedRepository source) {
    MavenManagedRepository result = new MavenManagedRepository();
    reverseUpdate(source, result);
    return result;
}
Also used : MavenManagedRepository(org.apache.archiva.rest.api.v2.model.MavenManagedRepository)

Aggregations

MavenManagedRepository (org.apache.archiva.rest.api.v2.model.MavenManagedRepository)10 Test (org.junit.jupiter.api.Test)6 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)3 ManagedRepository (org.apache.archiva.repository.ManagedRepository)3 ArchivaRestServiceException (org.apache.archiva.rest.api.v2.svc.ArchivaRestServiceException)3 URI (java.net.URI)2 Path (java.nio.file.Path)2 DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)2 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)2 BasicManagedRepository (org.apache.archiva.repository.base.managed.BasicManagedRepository)2 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)2 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)2 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)2 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)2 JsonPath (io.restassured.path.json.JsonPath)1 Response (io.restassured.response.Response)1 RepositoryAdminException (org.apache.archiva.admin.model.RepositoryAdminException)1 Repository (org.apache.archiva.repository.Repository)1 RepositoryException (org.apache.archiva.repository.RepositoryException)1 Order (org.junit.jupiter.api.Order)1