use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchIterativeTest method test102SimpleSequentialIterationWithMaxSize.
@Test
public void test102SimpleSequentialIterationWithMaxSize() throws Exception {
OperationResult result = new OperationResult("test102SimpleSequentialIterationWithMaxSize");
final List<PrismObject<UserType>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
return true;
};
SearchOpAsserter asserter = new SearchOpAsserter();
ObjectQuery query = prismContext.queryFactory().createQuery(prismContext.queryFactory().createPaging(null, 70));
repositoryService.searchObjectsIterative(UserType.class, query, handler, null, true, result);
result.recomputeStatus();
// assuming 50 + 20
asserter.assertIncrement(2);
assertTrue(result.isSuccess());
assertObjects(objects, 70);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class SearchTest method test110IterateSet.
@Test
public void test110IterateSet() throws Exception {
OperationResult result = new OperationResult("search set");
final List<PrismObject<?>> objects = new ArrayList<>();
ResultHandler<UserType> handler = (object, parentResult) -> {
objects.add(object);
return true;
};
repositoryService.searchObjectsIterative(UserType.class, null, handler, null, false, result);
result.recomputeStatus();
assertTrue(result.isSuccess());
assertEquals(4, objects.size());
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class DeleteRepositoryAction method deleteByFilter.
private void deleteByFilter(ObjectTypes type, ObjectQuery query, OperationStatus operation, OperationResult result) throws SchemaException {
ResultHandler<?> handler = (prismObject, operationResult) -> {
try {
State state = options.isAsk() ? askForState(prismObject) : State.DELETE;
switch(state) {
case SKIP:
operation.incrementSkipped();
return true;
case STOP:
return false;
case DELETE:
default:
}
RepositoryService repository = context.getRepository();
repository.deleteObject(prismObject.getCompileTimeClass(), prismObject.getOid(), operationResult);
operation.incrementTotal();
} catch (ObjectNotFoundException ex) {
// object was already gone
} catch (IOException ex) {
context.getLog().error("Couldn't delete object {}, reason: {}", ex, prismObject, ex.getMessage());
operation.incrementError();
}
return true;
};
Collection<SelectorOptions<GetOperationOptions>> opts = new ArrayList<>();
if (options.isRaw()) {
opts.add(new SelectorOptions<>(GetOperationOptions.createRaw()));
}
RepositoryService repository = context.getRepository();
repository.searchObjectsIterative(type.getClassDefinition(), query, handler, opts, true, result);
}
use of com.evolveum.midpoint.schema.ResultHandler in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method reconcileAllOrgs.
protected void reconcileAllOrgs() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
final Task task = getTestTask();
OperationResult result = task.getResult();
ResultHandler<OrgType> handler = (object, parentResult) -> {
try {
display("reconciling " + object);
reconcileOrg(object.getOid(), task, parentResult);
} catch (SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectNotFoundException | ObjectAlreadyExistsException | CommunicationException | ConfigurationException | SecurityViolationException e) {
throw new SystemException(e.getMessage(), e);
}
return true;
};
display("Reconciling all orgs");
modelService.searchObjectsIterative(OrgType.class, null, handler, null, task, result);
}
Aggregations