Search in sources :

Example 1 with ActivityRunException

use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.

the class ImportFromResourceLauncher method importSingleShadow.

public boolean importSingleShadow(String shadowOid, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createSubresult(OP_IMPORT_SINGLE_SHADOW);
    try {
        ShadowType shadow = provisioningService.getObject(ShadowType.class, shadowOid, createReadOnlyCollection(), task, result).asObjectable();
        ResourceObjectClass spec = syncTaskHelper.createObjectClassForShadow(shadow, task, result);
        Synchronizer synchronizer = new Synchronizer(spec.getResource(), spec.getResourceObjectDefinitionRequired(), new NullSynchronizationObjectFilterImpl(), eventDispatcher, SchemaConstants.CHANNEL_IMPORT, false, true);
        synchronizer.synchronize(shadow.asPrismObject(), null, task, result);
        result.computeStatusIfUnknown();
        return !result.isError();
    } catch (ActivityRunException t) {
        result.recordStatus(t.getOpResultStatus(), t.getMessage(), t);
        // FIXME unwrap the exception
        throw new SystemException(t);
    } catch (Throwable t) {
        result.recordFatalError(t);
        throw t;
    } finally {
        // just for sure
        result.computeStatusIfUnknown();
    }
}
Also used : Synchronizer(com.evolveum.midpoint.model.impl.sync.tasks.Synchronizer) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) NullSynchronizationObjectFilterImpl(com.evolveum.midpoint.model.impl.sync.tasks.NullSynchronizationObjectFilterImpl) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceObjectClass(com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)

Example 2 with ActivityRunException

use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.

the class SyncTaskHelper method createResourceObjectClass.

@NotNull
private ResourceObjectClass createResourceObjectClass(@NotNull ResourceObjectSetType resourceObjectSet, boolean checkForMaintenance, Task task, OperationResult opResult) throws ActivityRunException {
    String resourceOid = getResourceOid(resourceObjectSet);
    ResourceType resource = getResource(resourceOid, task, opResult);
    if (checkForMaintenance) {
        checkNotInMaintenance(resource);
    }
    ResourceSchema refinedResourceSchema = getRefinedResourceSchema(resource);
    ResourceObjectDefinition objectClassDefinition;
    try {
        objectClassDefinition = ModelImplUtils.determineObjectDefinition(refinedResourceSchema, resourceObjectSet, task);
    } catch (SchemaException e) {
        throw new ActivityRunException("Schema error", FATAL_ERROR, PERMANENT_ERROR, e);
    }
    if (objectClassDefinition == null) {
        LOGGER.debug("Processing all object classes");
    }
    return new ResourceObjectClass(resource, objectClassDefinition, resourceObjectSet.getKind(), resourceObjectSet.getIntent());
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceObjectDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectDefinition) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ActivityRunException

use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.

the class DistributedReportExportActivitySupport method fetchGlobalReportDataRef.

@NotNull
private ObjectReferenceType fetchGlobalReportDataRef(OperationResult result) throws SchemaException, ObjectNotFoundException, ActivityRunException {
    ActivityState activityState = ActivityState.getActivityStateUpwards(activity.getPath().allExceptLast(), runningTask, ReportExportWorkStateType.COMPLEX_TYPE, beans, result);
    ObjectReferenceType globalReportDataRef = activityState.getWorkStateReferenceRealValue(F_REPORT_DATA_REF);
    if (globalReportDataRef == null) {
        throw new ActivityRunException("No global report data reference in " + activityState, FATAL_ERROR, PERMANENT_ERROR);
    }
    return globalReportDataRef;
}
Also used : ActivityState(com.evolveum.midpoint.repo.common.activity.run.state.ActivityState) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ActivityRunException

use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.

the class ClassicReportImportActivityRun method beforeRun.

@Override
public void beforeRun(OperationResult result) throws CommonException, ActivityRunException {
    support.beforeExecution(result);
    ReportType report = support.getReport();
    support.stateCheck(result);
    controller = new ImportController(report, reportService, support.existCollectionConfiguration() ? support.getCompiledCollectionView(result) : null);
    controller.initialize();
    try {
        variables = controller.parseColumnsAsVariablesFromFile(support.getReportData());
    } catch (IOException e) {
        String message = "Couldn't read content of imported file: " + e.getMessage();
        result.recordFatalError(message, e);
        throw new ActivityRunException(message, FATAL_ERROR, PERMANENT_ERROR, e);
    }
}
Also used : ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) ImportController(com.evolveum.midpoint.report.impl.controller.ImportController) IOException(java.io.IOException)

Example 5 with ActivityRunException

use of com.evolveum.midpoint.repo.common.activity.run.ActivityRunException in project midpoint by Evolveum.

the class ActivityBasedTaskRun method run.

@NotNull
@Override
public TaskRunResult run(OperationResult result) throws TaskException {
    try {
        activityTree = ActivityTree.create(getRootTask(), getBeans());
        localRootPath = ActivityStateUtil.getLocalRootPath(runningTask.getWorkState());
        localRootActivity = activityTree.getActivity(localRootPath);
        localRootActivity.setLocalRoot(true);
    } catch (CommonException e) {
        throw new TaskException("Couldn't initialize activity tree", FATAL_ERROR, PERMANENT_ERROR, e);
    }
    if (localRootActivity.isSkipped()) {
        LOGGER.trace("Local root activity is skipped, exiting");
        return TaskRunResult.createNotApplicableTaskRunResult();
    }
    logStart();
    try {
        if (isRootRun()) {
            setupTaskArchetypeIfNeeded(result);
            updateStateOnRootRunStart(result);
        }
        AbstractActivityRun<?, ?, ?> localRootRun = localRootActivity.createRun(this, result);
        ActivityRunResult runResult = localRootRun.run(result);
        if (isRootRun()) {
            updateStateOnRootRunEnd(runResult, result);
        }
        logEnd(localRootRun, runResult);
        return runResult.createTaskRunResult();
    } catch (ActivityRunException e) {
        // These should be only really unexpected ones. So we won't bother with e.g. updating the tree state.
        logException(e);
        throw e.toTaskException();
    } catch (Throwable t) {
        logException(t);
        throw t;
    }
}
Also used : TaskException(com.evolveum.midpoint.task.api.TaskException) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) ActivityRunResult(com.evolveum.midpoint.repo.common.activity.run.ActivityRunResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)9 CommonException (com.evolveum.midpoint.util.exception.CommonException)3 NotNull (org.jetbrains.annotations.NotNull)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 NullSynchronizationObjectFilterImpl (com.evolveum.midpoint.model.impl.sync.tasks.NullSynchronizationObjectFilterImpl)1 ResourceObjectClass (com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)1 Synchronizer (com.evolveum.midpoint.model.impl.sync.tasks.Synchronizer)1 ActivityRunResult (com.evolveum.midpoint.repo.common.activity.run.ActivityRunResult)1 ActivityState (com.evolveum.midpoint.repo.common.activity.run.state.ActivityState)1 ImportController (com.evolveum.midpoint.report.impl.controller.ImportController)1 ResourceObjectDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectDefinition)1 ResourceSchema (com.evolveum.midpoint.schema.processor.ResourceSchema)1 RunningTask (com.evolveum.midpoint.task.api.RunningTask)1 TaskException (com.evolveum.midpoint.task.api.TaskException)1 Experimental (com.evolveum.midpoint.util.annotation.Experimental)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)1 IOException (java.io.IOException)1