use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryRegistry method replaceOrAddRepositoryConfig.
private void replaceOrAddRepositoryConfig(ManagedRepositoryConfiguration managedRepositoryConfiguration, Configuration configuration) {
ManagedRepositoryConfiguration oldCfg = configuration.findManagedRepositoryById(managedRepositoryConfiguration.getId());
if (oldCfg != null) {
configuration.removeManagedRepository(oldCfg);
}
configuration.addManagedRepository(managedRepositoryConfiguration);
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryRegistryTest method putManagedRepositoryFromConfig.
@Test
public void putManagedRepositoryFromConfig() throws Exception {
ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
cfg.setId("test002");
cfg.setName("This is test 002");
ManagedRepository repo = repositoryRegistry.putRepository(cfg);
assertNotNull(repo);
assertEquals("test002", repo.getId());
assertEquals("This is test 002", repo.getName());
assertNotNull(repo.getContent());
archivaConfiguration.reload();
Collection<ManagedRepository> repos = repositoryRegistry.getManagedRepositories();
assertEquals(5, repos.size());
ManagedRepository internalRepo = repositoryRegistry.getManagedRepository("internal");
cfg = new ManagedRepositoryConfiguration();
cfg.setId("internal");
cfg.setName("This is internal test 002");
repo = repositoryRegistry.putRepository(cfg);
assertTrue(internalRepo == repo);
assertEquals("This is internal test 002", repo.getName());
assertEquals(5, repositoryRegistry.getManagedRepositories().size());
repositoryRegistry.reload();
assertEquals(5, repositoryRegistry.getManagedRepositories().size());
}
use of org.apache.archiva.configuration.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).get();
configuration.setRetentionPeriod(acf.getRetentionPeriod().getDays());
configuration.setDeleteReleasedSnapshots(acf.isDeleteReleasedSnapshots());
configuration.setRetentionCount(acf.getRetentionCount());
IndexCreationFeature icf = managedRepository.getFeature(IndexCreationFeature.class).get();
configuration.setSkipPackedIndexCreation(icf.isSkipPackedIndexCreation());
configuration.setIndexDir(icf.getIndexPath() == null ? "" : icf.getIndexPath().toString());
StagingRepositoryFeature srf = managedRepository.getFeature(StagingRepositoryFeature.class).get();
configuration.setStageRepoNeeded(srf.isStageRepoNeeded());
return configuration;
}
use of org.apache.archiva.configuration.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");
org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoDir);
assertFalse("Default Test Repository should not exist.", Files.exists(repoDir));
Files.createDirectories(repoDir);
FileUtils.copyDirectoryStructure(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.ManagedRepositoryConfiguration in project archiva by apache.
the class FileMetadataRepository method getBaseDirectory.
private Path getBaseDirectory(String repoId) throws IOException {
// TODO: should be configurable, like the index
ManagedRepositoryConfiguration managedRepositoryConfiguration = configuration.getConfiguration().getManagedRepositoriesAsMap().get(repoId);
if (managedRepositoryConfiguration == null) {
return Files.createTempDirectory(repoId);
}
String basedir = managedRepositoryConfiguration.getLocation();
return Paths.get(basedir, ".archiva");
}
Aggregations