use of com.evolveum.midpoint.schema.reporting.ConnIdOperation in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method modifyObjectDelta.
/**
* Modifies object by using new delta update operations.
*/
private AsynchronousOperationReturnValue<Collection<PropertyModificationOperation>> modifyObjectDelta(ResourceObjectIdentification identification, ObjectClass objClass, Uid uid, PrismObject<ShadowType> shadow, Collection<Operation> changes, ConnectorOperationOptions options, UcfExecutionContext reporter, OperationResult result) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException {
ResourceObjectDefinition objectClassDef = identification.getResourceObjectDefinition();
DeltaModificationConverter converter = new DeltaModificationConverter();
converter.setChanges(changes);
converter.setConnectorDescription(description);
converter.setConnectorType(connectorType);
converter.setConnIdNameMapper(connIdNameMapper);
converter.setObjectDefinition(objectClassDef);
converter.setProtector(protector);
converter.setResourceSchema(rawResourceSchema);
converter.setOptions(options);
try {
converter.convert();
} catch (SchemaException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
LOGGER.trace("converted attributesDelta:\n {}", converter.debugDumpLazily(1));
OperationResult connIdResult;
// May or may not cover all executed changes
@NotNull Set<AttributeDelta> knownExecutedChanges;
Set<AttributeDelta> attributesDelta = converter.getAttributesDelta();
if (!attributesDelta.isEmpty()) {
OperationOptions connIdOptions = createConnIdOptions(options, changes);
connIdResult = result.createSubresult(ConnectorFacade.class.getName() + ".updateDelta");
connIdResult.addParam("objectClass", objectClassDef.toString());
connIdResult.addParam("uid", uid.getUidValue());
connIdResult.addParam("attributesDelta", attributesDelta.toString());
connIdResult.addArbitraryObjectAsParam("options", connIdOptions);
connIdResult.addContext("connector", connIdConnectorFacade.getClass());
InternalMonitor.recordConnectorOperation("update");
InternalMonitor.recordConnectorModification("update");
ConnIdOperation operation = recordIcfOperationStart(reporter, ProvisioningOperation.ICF_UPDATE, objectClassDef, uid);
LOGGER.trace("Invoking ICF update(), objectclass={}, uid={}, operation id={}, attributes delta: {}", objClass, uid, getIdentifier(operation), lazy(() -> dumpAttributesDelta(attributesDelta)));
try {
knownExecutedChanges = emptyIfNull(connIdConnectorFacade.updateDelta(objClass, uid, attributesDelta, connIdOptions));
recordIcfOperationEnd(reporter, operation, null);
connIdResult.recordSuccess();
} catch (Throwable ex) {
recordIcfOperationEnd(reporter, operation, ex);
String desc = this.getHumanReadableName() + " while updating object identified by ConnId UID '" + uid.getUidValue() + "'";
Throwable midpointEx = processConnIdException(ex, desc, connIdResult);
result.computeStatus("Update failed");
// exception
if (midpointEx instanceof ObjectNotFoundException) {
throw (ObjectNotFoundException) midpointEx;
} else if (midpointEx instanceof CommunicationException) {
// in this situation this is not a critical error, becasue we know to handle it..so mute the error and sign it as expected
result.muteError();
connIdResult.muteError();
throw (CommunicationException) midpointEx;
} else if (midpointEx instanceof GenericFrameworkException) {
throw (GenericFrameworkException) midpointEx;
} else if (midpointEx instanceof SchemaException) {
throw (SchemaException) midpointEx;
} else if (midpointEx instanceof ObjectAlreadyExistsException) {
throw (ObjectAlreadyExistsException) midpointEx;
} else if (midpointEx instanceof RuntimeException) {
throw (RuntimeException) midpointEx;
} else if (midpointEx instanceof SecurityViolationException) {
throw (SecurityViolationException) midpointEx;
} else if (midpointEx instanceof PolicyViolationException) {
throw (PolicyViolationException) midpointEx;
} else if (midpointEx instanceof Error) {
throw (Error) midpointEx;
} else {
throw new SystemException("Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
}
}
} else {
knownExecutedChanges = emptySet();
}
result.computeStatus();
Collection<PropertyModificationOperation> knownExecutedOperations = convertToExecutedOperations(knownExecutedChanges, identification, objectClassDef);
return AsynchronousOperationReturnValue.wrap(knownExecutedOperations, result);
}
Aggregations