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()));
}
}
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());
}
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());
}
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());
}
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;
}
Aggregations