use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandler method newInstancesFromConfig.
@Override
public Map<String, ManagedRepository> newInstancesFromConfig() {
try {
List<ManagedRepositoryConfiguration> managedRepoConfigs = new ArrayList<>(getConfigurationHandler().getBaseConfiguration().getManagedRepositories());
if (managedRepoConfigs == null) {
return Collections.emptyMap();
}
Map<String, ManagedRepository> result = new HashMap<>();
for (ManagedRepositoryConfiguration repoConfig : managedRepoConfigs) {
ManagedRepository repo = newInstance(repoConfig);
result.put(repo.getId(), repo);
if (repo.supportsFeature(StagingRepositoryFeature.class)) {
StagingRepositoryFeature stagF = repo.getFeature(StagingRepositoryFeature.class);
if (stagF.getStagingRepository() != null) {
ManagedRepository stagingRepo = getStagingRepository(repo);
if (stagingRepo != null) {
result.put(stagingRepo.getId(), stagingRepo);
}
}
}
}
return result;
} catch (Throwable e) {
log.error("Could not initialize repositories from config: {}", e.getMessage(), e);
return new HashMap<>();
}
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandler method updateReferences.
@Override
public void updateReferences(ManagedRepository repo, ManagedRepositoryConfiguration repositoryConfiguration) throws RepositoryException {
log.debug("Updating references of repo {}", repo.getId());
if (repo.supportsFeature(StagingRepositoryFeature.class)) {
Configuration configuration = getConfigurationHandler().getBaseConfiguration();
RepositoryProvider provider = getProvider(repo.getType());
StagingRepositoryFeature feature = repo.getFeature(StagingRepositoryFeature.class);
if (feature.isStageRepoNeeded() && feature.getStagingRepository() == null) {
ManagedRepository stageRepo = get(getStagingId(repo.getId()));
if (stageRepo == null) {
stageRepo = getStagingRepository(repo);
getRepositories().put(stageRepo.getId(), stageRepo);
if (configuration != null) {
replaceOrAddRepositoryConfig(provider.getManagedConfiguration(stageRepo), configuration);
}
pushEvent(new LifecycleEvent(LifecycleEvent.REGISTERED, this, stageRepo));
}
feature.setStagingRepository(stageRepo);
}
}
if (repo instanceof EditableManagedRepository) {
EditableManagedRepository editableRepo = (EditableManagedRepository) repo;
if (repo.getContent() == null) {
editableRepo.setContent(repositoryContentFactory.getManagedRepositoryContent(repo));
editableRepo.getContent().setRepository(editableRepo);
}
log.debug("Index repo: " + repo.hasIndex());
if (repo.hasIndex() && (repo.getIndexingContext() == null || !repo.getIndexingContext().isOpen())) {
log.debug("Creating indexing context for {}", repo.getId());
createIndexingContext(editableRepo);
}
}
repo.registerEventHandler(RepositoryEvent.ANY, repositoryHandlerManager);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration 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.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryMapper method map.
@Override
public ManagedRepositoryConfiguration map(MavenManagedRepository source) {
ManagedRepositoryConfiguration target = new ManagedRepositoryConfiguration();
update(source, target);
return target;
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryProviderMock method getManagedConfiguration.
@Override
public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(managedRepository.getId());
configuration.setName(managedRepository.getName());
configuration.setLocation(managedRepository.getLocation() == null ? "" : managedRepository.getLocation().toString());
configuration.setBlockRedeployments(managedRepository.blocksRedeployments());
configuration.setDescription(managedRepository.getDescription());
configuration.setLayout(managedRepository.getLayout());
configuration.setScanned(managedRepository.isScanned());
configuration.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
configuration.setReleases(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
configuration.setSnapshots(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
ArtifactCleanupFeature acf = managedRepository.getFeature(ArtifactCleanupFeature.class);
configuration.setRetentionPeriod(acf.getRetentionPeriod().getDays());
configuration.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
configuration.setRetentionCount(acf.getRetentionCount());
IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class);
configuration.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
configuration.setIndexDir(icf.getIndexPath() == null ? "" : icf.getIndexPath().toString());
StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class);
configuration.setStageRepoNeeded(srf.isStageRepoNeeded());
return configuration;
}
Aggregations