use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.
the class DefaultMergedRemoteIndexesScheduler method schedule.
@Override
public void schedule(RepositoryGroup repositoryGroup, StorageAsset directory) {
if (StringUtils.isEmpty(repositoryGroup.getSchedulingDefinition())) {
return;
}
CronTrigger cronTrigger = new CronTrigger(repositoryGroup.getSchedulingDefinition());
List<ManagedRepository> repositories = repositoryGroup.getRepositories();
if (repositoryGroup.supportsFeature(IndexCreationFeature.class)) {
IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature(IndexCreationFeature.class);
Path indexPath = indexCreationFeature.getLocalIndexPath().getFilePath();
if (indexPath != null) {
IndexMergerRequest indexMergerRequest = new IndexMergerRequest(repositories.stream().map(r -> r.getId()).collect(Collectors.toList()), true, repositoryGroup.getId(), indexPath.toString(), repositoryGroup.getMergedIndexTTL()).mergedIndexDirectory(directory);
MergedRemoteIndexesTaskRequest taskRequest = new MergedRemoteIndexesTaskRequest(indexMergerRequest, indexMerger);
logger.info("schedule merge remote index for group {} with cron {}", repositoryGroup.getId(), repositoryGroup.getSchedulingDefinition());
ScheduledFuture scheduledFuture = taskScheduler.schedule(new MergedRemoteIndexesTask(taskRequest), cronTrigger);
scheduledFutureMap.put(repositoryGroup.getId(), scheduledFuture);
} else {
logger.error("Requested index merger for repository group {} with non local index path {}", repositoryGroup.getId(), indexCreationFeature.getLocalIndexPath());
}
} else {
logger.error("Scheduling merged index for repository group {}, but it does not support IndexCreationFeature.", repositoryGroup.getId());
}
}
use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.
the class RepositoryGroupHandlerTest method testPutWithoutRegister.
@Test
void testPutWithoutRegister() throws RepositoryException {
RepositoryGroupHandler groupHandler = createHandler();
Configuration aCfg = new Configuration();
RepositoryGroupConfiguration configuration = new RepositoryGroupConfiguration();
final String id = "test-group-06";
configuration.setId(id);
configuration.setName("n-" + id);
ArrayList<String> repos = new ArrayList<>();
repos.add("internal");
configuration.setRepositories(repos);
groupHandler.put(configuration, aCfg);
RepositoryGroup repo = groupHandler.get(id);
assertNull(repo);
assertFalse(hasGroupInConfig(id));
assertTrue(aCfg.getRepositoryGroups().stream().anyMatch(g -> g != null && id.equals(g.getId())));
}
use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.
the class RepositoryGroupHandlerTest method validateRepositoryForUpdate.
@Test
void validateRepositoryForUpdate() throws IOException, RepositoryException {
final String id = "test-group-12";
try {
RepositoryGroupHandler groupHandler = createHandler();
EditableRepositoryGroup repositoryGroup = createRepository(id, "n-" + id);
repositoryGroup.setMergedIndexTTL(5);
groupHandler.put(repositoryGroup);
CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.validateRepositoryForUpdate(repositoryGroup);
assertNotNull(result);
assertEquals(0, result.getResult().size());
} finally {
removeGroupFromConfig(id);
}
}
use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.
the class RepositoryGroupHandlerTest method putWithCheck_invalid.
@Test
void putWithCheck_invalid() throws RepositoryException {
final String id = "test-group-07";
final String name = "n-" + id;
try {
RepositoryGroupHandler groupHandler = createHandler();
BasicRepositoryGroupValidator checker = new BasicRepositoryGroupValidator(configurationHandler);
RepositoryGroupConfiguration configuration = new RepositoryGroupConfiguration();
configuration.setId("");
configuration.setName(name);
ArrayList<String> repos = new ArrayList<>();
repos.add("internal");
configuration.setRepositories(repos);
CheckedResult<RepositoryGroup, Map<String, List<ValidationError>>> result = groupHandler.putWithCheck(configuration, checker);
assertNull(groupHandler.get(id));
assertNotNull(result.getResult());
assertNotNull(result.getResult().get("id"));
assertEquals(1, result.getResult().get("id").size());
assertEquals(ISEMPTY, result.getResult().get("id").get(0).getType());
assertFalse(hasGroupInConfig(id));
assertFalse(hasGroupInConfig(""));
} finally {
removeGroupFromConfig(id);
}
}
use of org.apache.archiva.repository.RepositoryGroup in project archiva by apache.
the class RepositoryGroupHandlerTest method newInstance.
@Test
void newInstance() throws RepositoryException {
String id = "test-group-03";
RepositoryGroupHandler groupHandler = createHandler();
RepositoryGroup instance = groupHandler.newInstance(RepositoryType.MAVEN, id);
assertNotNull(instance);
assertEquals(id, instance.getId());
assertFalse(groupHandler.hasRepository(id));
assertEquals(RepositoryState.REFERENCES_SET, instance.getLastState());
assertFalse(hasGroupInConfig(id));
}
Aggregations