use of org.apache.archiva.repository.EditableRemoteRepository in project archiva by apache.
the class RemoteRepositoryHandler method newOrUpdateInstancesFromConfig.
public Map<String, RemoteRepository> newOrUpdateInstancesFromConfig(Map<String, RemoteRepository> currentInstances) {
try {
List<RemoteRepositoryConfiguration> remoteRepoConfigs = new ArrayList<>(getConfigurationHandler().getBaseConfiguration().getRemoteRepositories());
if (remoteRepoConfigs == null) {
return Collections.emptyMap();
}
Map<String, RemoteRepository> result = new HashMap<>();
for (RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs) {
String id = repoConfig.getId();
if (result.containsKey(id)) {
log.error("There are repositories with the same id in the configuration: {}", id);
continue;
}
RemoteRepository repo;
if (currentInstances.containsKey(id)) {
repo = currentInstances.remove(id);
getProvider(repo.getType()).updateRemoteInstance((EditableRemoteRepository) repo, repoConfig);
updateReferences(repo, repoConfig);
} else {
repo = newInstance(repoConfig);
}
result.put(id, repo);
}
return result;
} catch (Throwable e) {
log.error("Could not initialize repositories from config: {}", e.getMessage(), e);
return new HashMap<>();
}
}
use of org.apache.archiva.repository.EditableRemoteRepository in project archiva by apache.
the class RemoteRepositoryHandler method updateReferences.
@Override
public void updateReferences(RemoteRepository repo, RemoteRepositoryConfiguration repositoryConfiguration) throws RepositoryException {
if (repo instanceof EditableRemoteRepository && repo.getContent() == null) {
EditableRemoteRepository editableRepo = (EditableRemoteRepository) repo;
editableRepo.setContent(repositoryContentFactory.getRemoteRepositoryContent(repo));
if (repo.supportsFeature(IndexCreationFeature.class) && repo.getIndexingContext() == null) {
createIndexingContext(editableRepo);
}
}
repo.registerEventHandler(RepositoryEvent.ANY, repositoryHandlerManager);
}
use of org.apache.archiva.repository.EditableRemoteRepository in project archiva by apache.
the class BasicRemoteRepositoryValidatorTest method apply.
@Test
void apply() throws IOException {
BasicRemoteRepositoryValidator validator = new BasicRemoteRepositoryValidator(configurationHandler);
validator.setRepositoryRegistry(repositoryRegistry);
Path repoDir = getRepoBaseDir().resolve("test");
EditableRemoteRepository repo = createRepository("test", "test", repoDir);
ValidationResponse<RemoteRepository> result = validator.apply(repo);
assertTrue(result.isValid());
}
use of org.apache.archiva.repository.EditableRemoteRepository in project archiva by apache.
the class BasicRemoteRepositoryValidatorTest method applyUpdateWithExistingRepo.
@Test
void applyUpdateWithExistingRepo() throws IOException, RepositoryException {
BasicRemoteRepositoryValidator validator = new BasicRemoteRepositoryValidator(configurationHandler);
validator.setRepositoryRegistry(repositoryRegistry);
Path repoDir = getRepoBaseDir().resolve("test");
EditableRemoteRepository repo = createRepository("test", "test", repoDir);
Path repoDir2 = getRepoBaseDir().resolve("test2");
EditableRemoteRepository repo2 = createRepository("test", "test", repoDir2);
repositoryRegistry.putRepository(repo);
ValidationResponse<RemoteRepository> result = validator.applyForUpdate(repo);
assertTrue(result.isValid());
assertEquals(0, result.getResult().size());
}
use of org.apache.archiva.repository.EditableRemoteRepository in project archiva by apache.
the class BasicRemoteRepositoryValidatorTest method applyWithBadSchedulingExpression.
@Test
void applyWithBadSchedulingExpression() throws IOException {
BasicRemoteRepositoryValidator validator = new BasicRemoteRepositoryValidator(configurationHandler);
validator.setRepositoryRegistry(repositoryRegistry);
Path repoDir = getRepoBaseDir().resolve("test");
EditableRemoteRepository repo = createRepository("test", "test", repoDir);
repo.setSchedulingDefinition("xxxxx");
ValidationResponse<RemoteRepository> result = validator.apply(repo);
assertFalse(result.isValid());
assertEquals(1, result.getResult().size());
assertEquals("invalid_scheduling_exp", result.getResult().get("scheduling_definition").get(0).getType());
}
Aggregations