Search in sources :

Example 26 with CommonException

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);
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ActivityPerformanceInformation(com.evolveum.midpoint.schema.util.task.ActivityPerformanceInformation)

Example 27 with CommonException

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);
    }
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 28 with CommonException

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);
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException)

Example 29 with CommonException

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;
}
Also used : SystemException(com.evolveum.midpoint.util.exception.SystemException) ArrayList(java.util.ArrayList) CommonException(com.evolveum.midpoint.util.exception.CommonException) SystemException(com.evolveum.midpoint.util.exception.SystemException) ConnectException(java.net.ConnectException) FileNotFoundException(java.io.FileNotFoundException)

Example 30 with CommonException

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;
}
Also used : MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) CommonException(com.evolveum.midpoint.util.exception.CommonException) ModelService(com.evolveum.midpoint.model.api.ModelService)

Aggregations

CommonException (com.evolveum.midpoint.util.exception.CommonException)71 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)44 Task (com.evolveum.midpoint.task.api.Task)33 PrismObject (com.evolveum.midpoint.prism.PrismObject)14 SystemException (com.evolveum.midpoint.util.exception.SystemException)14 ArrayList (java.util.ArrayList)12 ModelService (com.evolveum.midpoint.model.api.ModelService)11 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)8 NotNull (org.jetbrains.annotations.NotNull)7 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)5 RestartResponseException (org.apache.wicket.RestartResponseException)5 ModelInteractionService (com.evolveum.midpoint.model.api.ModelInteractionService)4 ModelContext (com.evolveum.midpoint.model.api.context.ModelContext)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)4 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)4