use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProvider method getManagedConfiguration.
@Override
public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository)) {
log.error("Wrong remote repository type " + managedRepository.getClass().getName());
throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName());
}
ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
cfg.setType(managedRepository.getType().toString());
cfg.setId(managedRepository.getId());
cfg.setName(managedRepository.getName());
cfg.setDescription(managedRepository.getDescription());
cfg.setLocation(convertUriToPath(managedRepository.getLocation()));
cfg.setLayout(managedRepository.getLayout());
cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
cfg.setScanned(managedRepository.isScanned());
cfg.setBlockRedeployments(managedRepository.blocksRedeployments());
StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class);
cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded());
IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class);
cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation());
ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class);
cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount());
cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays());
cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots());
cfg.setReleases(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
cfg.setSnapshots(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
return cfg;
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
c.setVersion("2.0");
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(true);
c.addManagedRepository(testRepo);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
c.setRepositoryScanning(scCfg);
configuration.save(c);
assertFalse(configuration.isDefaulted());
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class DefaultRepositoryArchivaTaskScheduler method configurationEvent.
@Override
public void configurationEvent(ConfigurationEvent event) {
if (event.getType() == ConfigurationEvent.SAVED) {
for (String job : jobs) {
try {
scheduler.unscheduleJob(job, REPOSITORY_SCAN_GROUP);
} catch (SchedulerException e) {
log.error("Error restarting the repository scanning job after property change.");
}
}
jobs.clear();
List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
for (ManagedRepositoryConfiguration repoConfig : repositories) {
if (repoConfig.getRefreshCronExpression() != null) {
try {
scheduleRepositoryJobs(repoConfig);
} catch (SchedulerException e) {
log.error("error restarting job: '{}' : '{}'", REPOSITORY_JOB, repoConfig.getId());
}
}
}
}
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractArchivaRepositoryScanningTaskExecutorTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
Path sourceRepoDir = Paths.get("src/test/repositories/default-repository");
repoDir = Paths.get("target/default-repository");
FileUtils.deleteDirectory(repoDir);
assertFalse("Default Test Repository should not exist.", Files.exists(repoDir));
Files.createDirectories(repoDir);
org.apache.commons.io.FileUtils.copyDirectory(sourceRepoDir.toFile(), repoDir.toFile());
// set the timestamps to a time well in the past
Calendar cal = Calendar.getInstance();
cal.add(Calendar.YEAR, -1);
try (Stream<Path> stream = Files.walk(repoDir, FileVisitOption.FOLLOW_LINKS)) {
stream.forEach(path -> {
try {
Files.setLastModifiedTime(path, FileTime.fromMillis(cal.getTimeInMillis()));
} catch (IOException e) {
e.printStackTrace();
}
});
}
PathMatcher m = FileSystems.getDefault().getPathMatcher("glob:**/.svn");
Files.walk(repoDir, FileVisitOption.FOLLOW_LINKS).filter(Files::isDirectory).sorted(Comparator.reverseOrder()).filter(path -> m.matches(path)).forEach(path -> org.apache.archiva.common.utils.FileUtils.deleteQuietly(path));
assertTrue("Default Test Repository should exist.", Files.exists(repoDir) && Files.isDirectory(repoDir));
assertNotNull(archivaConfig);
// Create it
ManagedRepositoryConfiguration repositoryConfiguration = new ManagedRepositoryConfiguration();
repositoryConfiguration.setId(TEST_REPO_ID);
repositoryConfiguration.setName("Test Repository");
repositoryConfiguration.setLocation(repoDir.toAbsolutePath().toString());
for (ManagedRepository repo : repositoryRegistry.getManagedRepositories()) {
repositoryRegistry.removeRepository(repo);
}
repositoryRegistry.putRepository(repositoryConfiguration);
metadataRepository = mock(MetadataRepository.class);
factory.setRepository(metadataRepository);
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryMapperTest method updateWithNullValues.
@Test
void updateWithNullValues() {
MavenRepositoryMapper mapper = new MavenRepositoryMapper();
MavenManagedRepository repo = new MavenManagedRepository();
ManagedRepositoryConfiguration result = new ManagedRepositoryConfiguration();
repo.setId("repo01");
repo.setName("Repo 01");
repo.setDescription("This is repo 01");
repo.setLocation(null);
repo.setHasStagingRepository(true);
repo.setSchedulingDefinition("0,1,2 * * * *");
repo.setPackedIndexPath(null);
repo.setIndexPath(null);
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(null);
repo.setRetentionCount(15);
repo.setSkipPackedIndexCreation(false);
repo.setStagingRepository(null);
mapper.update(repo, result);
assertNotNull(result);
assertEquals("repo01", result.getId());
assertEquals("Repo 01", result.getName());
assertEquals("This is repo 01", result.getDescription());
assertNotNull(result.getLocation());
assertTrue(result.isStageRepoNeeded());
assertEquals("0,1,2 * * * *", result.getRefreshCronExpression());
assertEquals("", result.getIndexDir());
assertEquals("", result.getPackedIndexDir());
assertFalse(result.isDeleteReleasedSnapshots());
assertFalse(result.isBlockRedeployments());
assertTrue(result.isSnapshots());
assertTrue(result.isReleases());
assertTrue(result.isScanned());
assertEquals(100, result.getRetentionPeriod());
assertEquals(15, result.getRetentionCount());
assertFalse(result.isSkipPackedIndexCreation());
}
Aggregations