use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method remove.
@Test
void remove() throws RepositoryException {
final String id = "test-repo-08";
ManagedRepositoryHandler repoHandler = createHandler();
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration);
assertTrue(hasRepositoryInConfig(id));
assertNotNull(repoHandler.get(id));
repoHandler.remove(id);
assertNull(repoHandler.get(id));
assertFalse(hasRepositoryInConfig(id));
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method testPutWithoutRegister.
@Test
void testPutWithoutRegister() throws RepositoryException {
final String id = "test-repo-06";
ManagedRepositoryHandler repoHandler = createHandler();
Configuration aCfg = new Configuration();
ManagedRepositoryConfiguration configuration = new ManagedRepositoryConfiguration();
configuration.setId(id);
configuration.setName("n-" + id);
repoHandler.put(configuration, aCfg);
ManagedRepository repo = repoHandler.get(id);
assertNull(repo);
assertFalse(hasRepositoryInConfig(id));
assertTrue(aCfg.getManagedRepositories().stream().anyMatch(g -> g != null && id.equals(g.getId())));
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class ManagedRepositoryHandlerTest method removeRepositoryFromConfig.
// Helper method that removes a repo from the configuration
private void removeRepositoryFromConfig(String id) {
Configuration configuration = configurationHandler.getBaseConfiguration();
Iterator<ManagedRepositoryConfiguration> iter = configuration.getManagedRepositories().iterator();
while (iter.hasNext()) {
ManagedRepositoryConfiguration repo = iter.next();
if (id.equals(repo.getId())) {
iter.remove();
break;
}
}
try {
configurationHandler.save(configuration);
} catch (Throwable e) {
System.err.println("Could not remove repo from config " + id);
}
}
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;
}
use of org.apache.archiva.configuration.model.ManagedRepositoryConfiguration in project archiva by apache.
the class MavenRepositoryProvider method getStageRepoConfig.
private ManagedRepositoryConfiguration getStageRepoConfig(ManagedRepositoryConfiguration repository) {
ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
stagingRepository.setId(repository.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
stagingRepository.setLayout(repository.getLayout());
stagingRepository.setName(repository.getName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
stagingRepository.setBlockRedeployments(repository.isBlockRedeployments());
stagingRepository.setRetentionPeriod(repository.getRetentionPeriod());
stagingRepository.setDeleteReleasedSnapshots(repository.isDeleteReleasedSnapshots());
stagingRepository.setStageRepoNeeded(false);
String path = repository.getLocation();
int lastIndex = path.replace('\\', '/').lastIndexOf('/');
stagingRepository.setLocation(path.substring(0, lastIndex) + "/" + stagingRepository.getId());
if (StringUtils.isNotBlank(repository.getIndexDir())) {
Path indexDir;
try {
if (repository.getIndexDir().startsWith("file:")) {
indexDir = Paths.get(new URI(repository.getIndexDir()));
} else {
indexDir = Paths.get(repository.getIndexDir());
}
if (indexDir.isAbsolute()) {
Path newDir = indexDir.getParent().resolve(indexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
log.debug("Changing index directory {} -> {}", indexDir, newDir);
stagingRepository.setIndexDir(newDir.toString());
} else {
log.debug("Keeping index directory {}", repository.getIndexDir());
stagingRepository.setIndexDir(repository.getIndexDir());
}
} catch (URISyntaxException e) {
log.error("Could not parse index path as uri {}", repository.getIndexDir());
stagingRepository.setIndexDir("");
}
// in case of absolute dir do not use the same
}
if (StringUtils.isNotBlank(repository.getPackedIndexDir())) {
Path packedIndexDir;
packedIndexDir = Paths.get(repository.getPackedIndexDir());
if (packedIndexDir.isAbsolute()) {
Path newDir = packedIndexDir.getParent().resolve(packedIndexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
log.debug("Changing index directory {} -> {}", packedIndexDir, newDir);
stagingRepository.setPackedIndexDir(newDir.toString());
} else {
log.debug("Keeping index directory {}", repository.getPackedIndexDir());
stagingRepository.setPackedIndexDir(repository.getPackedIndexDir());
}
// in case of absolute dir do not use the same
}
stagingRepository.setRefreshCronExpression(repository.getRefreshCronExpression());
stagingRepository.setReleases(repository.isReleases());
stagingRepository.setRetentionCount(repository.getRetentionCount());
stagingRepository.setScanned(repository.isScanned());
stagingRepository.setSnapshots(repository.isSnapshots());
stagingRepository.setSkipPackedIndexCreation(repository.isSkipPackedIndexCreation());
// stagingRepository.getDescription("")
return stagingRepository;
}
Aggregations