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();
}
}
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());
}
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;
}
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);
}
}
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;
}
}
Aggregations