use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class TestSystemPerformance method recordProgress.
private void recordProgress(String label, Task task) {
Long start = task.getLastRunStartTimestamp();
long progress = task.getLegacyProgress();
if (start == null || progress == lastProgress) {
return;
}
lastProgress = progress;
progressOutputFile.recordProgress(label, task);
OperationStatsType stats = task.getStoredOperationStatsOrClone();
logger.info("\n{}", TaskOperationStatsUtil.format(stats));
// TODO remove fake result + remove getting the task!
OperationResult tempResult = new OperationResult("temp");
TreeNode<ActivityPerformanceInformation> performanceInformation;
try {
performanceInformation = activityManager.getPerformanceInformation(task.getOid(), tempResult);
} catch (CommonException e) {
throw new SystemException(e);
}
displayDumpable("performance: " + label + task.getName(), performanceInformation);
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class ItemProcessingConditionEvaluator method evaluateConditionDefaultTrue.
boolean evaluateConditionDefaultTrue(@Nullable ExpressionType expression, @Nullable AdditionalVariableProvider additionalVariableProvider, OperationResult result) {
VariablesMap variables = new VariablesMap();
variables.put(ExpressionConstants.VAR_REQUEST, request, ItemProcessingRequest.class);
variables.put(ExpressionConstants.VAR_ITEM, request.getItem(), request.getItem().getClass());
if (additionalVariableProvider != null) {
additionalVariableProvider.provide(variables);
}
try {
return ExpressionUtil.evaluateConditionDefaultTrue(variables, expression, null, activityRun.getBeans().expressionFactory, "item condition expression", activityRun.getRunningTask(), result);
} catch (CommonException e) {
throw new SystemException("Couldn't evaluate 'before item' condition: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class ItemProcessingGatekeeper method process.
boolean process(OperationResult parentResult) {
OperationResult result = parentResult.subresult(OP_PROCESS).build();
try {
workerTask.setExecutionSupport(activityRun);
logOperationStart();
operation = updateStatisticsOnStart();
itemProcessingMonitor.startProfilingAndTracingIfNeeded(result);
try {
startLocalConnIdListeningIfNeeded(result);
processingResult = doProcessItem(result);
} finally {
stopLocalConnIdOperationListening();
}
updateStatisticsOnEnd(result);
storeTraceIfRequested(result);
updateReports(result);
itemProcessingMonitor.stopProfilingAndTracing();
writeOperationExecutionRecord(result);
if (isError()) {
canContinue = handleError(result) && canContinue;
}
acknowledgeItemProcessed(result);
logOperationEnd();
return canContinue;
} catch (RuntimeException | CommonException e) {
result.recordFatalError(e);
// This is unexpected exception. We should perhaps stop the whole processing.
// Just throwing the exception would simply kill one worker thread. This is something
// that would easily be lost in the logs.
activityRun.getErrorState().setStoppingException(e);
LoggingUtils.logUnexpectedException(LOGGER, "Fatal error while doing administration over " + "processing item {} in {}:{}. Stopping the whole processing.", e, request.getItem(), coordinatorTask, workerTask);
acknowledgeItemProcessedAsEmergency();
return false;
} finally {
result.close();
cleanupAndSummarizeResults(parentResult);
workerTask.setExecutionSupport(null);
}
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class DummyObjectsCreator method execute.
public List<O> execute() throws CommonException, ConflictException, FileNotFoundException, SchemaViolationException, ObjectAlreadyExistsException, InterruptedException, ConnectException {
List<O> objects = new ArrayList<>(objectCount);
for (int i = 0; i < objectCount; i++) {
O object;
try {
object = type.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new SystemException(e);
}
object.setName(createName(i));
if (customizer != null) {
customizer.customize(object, i);
}
addObject(object);
objects.add(object);
}
System.out.printf("Created %d objects\n", objectCount);
return objects;
}
use of com.evolveum.midpoint.util.exception.CommonException in project midpoint by Evolveum.
the class ObjectChangesExecutorImpl method executeChangesSync.
private Collection<ObjectDeltaOperation<? extends ObjectType>> executeChangesSync(Collection<ObjectDelta<? extends ObjectType>> deltas, ModelExecuteOptions options, Task task, OperationResult result) {
try {
MidPointApplication application = MidPointApplication.get();
ModelService service = application.getModel();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = service.executeChanges(deltas, options, task, result);
result.computeStatusIfUnknown();
return executedDeltas;
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Error executing changes", e);
if (!result.isFatalError()) {
// just to be sure the exception is recorded into the result
result.recordFatalError(e.getMessage(), e);
}
}
return null;
}
Aggregations