use of com.evolveum.midpoint.task.api.TaskRunResult in project midpoint by Evolveum.
the class ImportAccountsFromResourceTaskHandler method importSingleShadow.
/**
* Imports a single shadow. Synchronously. The task is NOT switched to background by default.
*/
public boolean importSingleShadow(String shadowOid, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, shadowOid, null, task, parentResult);
PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, ShadowUtil.getResourceOid(shadow), null, task, parentResult);
// Create a result handler just for one object. Invoke the handle() method manually.
TaskRunResult runResult = new TaskRunResult();
SynchronizeAccountResultHandler resultHandler = createHandler(resource.asObjectable(), shadow, runResult, task, parentResult);
if (resultHandler == null) {
return false;
}
// This is required for proper error reporting
resultHandler.setStopOnError(true);
boolean cont = initializeRun(resultHandler, runResult, task, parentResult);
if (!cont) {
return false;
}
cont = resultHandler.handle(shadow, parentResult);
if (!cont) {
return false;
}
finish(resultHandler, runResult, task, parentResult);
return true;
}
use of com.evolveum.midpoint.task.api.TaskRunResult in project midpoint by Evolveum.
the class MockTaskHandler method run.
@Override
public TaskRunResult run(@NotNull RunningTask task) {
OperationResult result = task.getResult();
TaskRunResult runResult = new TaskRunResult();
PrismProperty<Integer> delayProp = task.getExtensionPropertyOrClone(ITEM_DELAY);
PrismProperty<Integer> stepsProp = task.getExtensionPropertyOrClone(ITEM_STEPS);
int delay = MoreObjects.firstNonNull(delayProp != null ? delayProp.getRealValue() : null, 0);
int steps = MoreObjects.firstNonNull(stepsProp != null ? stepsProp.getRealValue() : null, 1);
LOGGER.info("Run starting; progress = {}, steps to be executed = {}, delay for one step = {}, in task {}", task.getLegacyProgress(), steps, delay, task);
for (int i = 0; i < steps; i++) {
LOGGER.info("Executing step {} (numbered from one) of {} in task {}", i + 1, steps, task);
MiscUtil.sleepNonInterruptibly(delay);
try {
task.incrementLegacyProgressAndStoreStatisticsIfTimePassed(result);
} catch (SchemaException | ObjectNotFoundException e) {
throw new SystemException(e);
}
if (!task.canRun()) {
LOGGER.info("Got a shutdown request, finishing task {}", task);
break;
}
}
LOGGER.info("Run finishing; progress = {} in task {}", task.getLegacyProgress(), task);
hasRun.set(true);
result.computeStatusIfUnknown();
runResult.setRunResultStatus(TaskRunResultStatus.FINISHED);
return runResult;
}
use of com.evolveum.midpoint.task.api.TaskRunResult in project midpoint by Evolveum.
the class TaskCycleExecutor method executeTaskCycleRun.
/**
* Task is refreshed after returning from this method.
*/
private TaskRunResult executeTaskCycleRun(OperationResult result) throws StopTaskException {
processCycleRunStart(result);
TaskRunResult runResult = executeHandler(result);
processCycleRunFinish(runResult, result);
return runResult;
}
Aggregations