use of com.evolveum.midpoint.model.impl.sync.SynchronizeAccountResultHandler in project midpoint by Evolveum.
the class ImportAccountsFromResourceTaskHandler method createHandler.
// shadowToImport - it is used to derive objectClass/intent/kind when importing a single shadow
private SynchronizeAccountResultHandler createHandler(ResourceType resource, PrismObject<ShadowType> shadowToImport, TaskRunResult runResult, Task coordinatorTask, OperationResult opResult) {
RefinedResourceSchema refinedSchema;
ObjectClassComplexTypeDefinition objectClass;
try {
refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, LayerType.MODEL, prismContext);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Refined schema:\n{}", refinedSchema.debugDump());
}
if (shadowToImport != null) {
objectClass = Utils.determineObjectClass(refinedSchema, shadowToImport);
} else {
objectClass = Utils.determineObjectClass(refinedSchema, coordinatorTask);
}
if (objectClass == null) {
LOGGER.error("Import: No objectclass specified and no default can be determined.");
opResult.recordFatalError("No objectclass specified and no default can be determined");
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
return null;
}
} catch (SchemaException e) {
LOGGER.error("Import: Schema error during processing account definition: {}", e.getMessage());
opResult.recordFatalError("Schema error during processing account definition: " + e.getMessage(), e);
runResult.setRunResultStatus(TaskRunResultStatus.PERMANENT_ERROR);
return null;
}
LOGGER.info("Start executing import from resource {}, importing object class {}", resource, objectClass.getTypeName());
SynchronizeAccountResultHandler handler = new SynchronizeAccountResultHandler(resource, objectClass, "import", coordinatorTask, changeNotificationDispatcher, taskManager);
handler.setSourceChannel(SchemaConstants.CHANGE_CHANNEL_IMPORT);
handler.setForceAdd(true);
handler.setStopOnError(false);
handler.setContextDesc("from " + resource);
handler.setLogObjectProgress(true);
return handler;
}
use of com.evolveum.midpoint.model.impl.sync.SynchronizeAccountResultHandler 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;
}
Aggregations