use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method getChangesFromSyncDeltas.
private List<Change> getChangesFromSyncDeltas(ObjectClass connIdObjClass, Collection<SyncDelta> connIdDeltas, PrismSchema schema, OperationResult parentResult) throws SchemaException, GenericFrameworkException {
List<Change> changeList = new ArrayList<Change>();
QName objectClass = connIdNameMapper.objectClassToQname(connIdObjClass, getSchemaNamespace(), legacySchema);
ObjectClassComplexTypeDefinition objClassDefinition = null;
if (objectClass != null) {
objClassDefinition = (ObjectClassComplexTypeDefinition) schema.findComplexTypeDefinition(objectClass);
}
Validate.notNull(connIdDeltas, "Sync result must not be null.");
for (SyncDelta icfDelta : connIdDeltas) {
ObjectClass deltaIcfObjClass = connIdObjClass;
QName deltaObjectClass = objectClass;
ObjectClassComplexTypeDefinition deltaObjClassDefinition = objClassDefinition;
if (objectClass == null) {
deltaIcfObjClass = icfDelta.getObjectClass();
deltaObjectClass = connIdNameMapper.objectClassToQname(deltaIcfObjClass, getSchemaNamespace(), legacySchema);
if (deltaIcfObjClass != null) {
deltaObjClassDefinition = (ObjectClassComplexTypeDefinition) schema.findComplexTypeDefinition(deltaObjectClass);
}
}
if (deltaObjClassDefinition == null) {
if (icfDelta.getDeltaType() == SyncDeltaType.DELETE) {
// tolerate this. E.g. LDAP changelogs do not have objectclass in delete deltas.
} else {
throw new SchemaException("Got delta with object class " + deltaObjectClass + " (" + deltaIcfObjClass + ") that has no definition in resource schema");
}
}
SyncDeltaType icfDeltaType = icfDelta.getDeltaType();
if (SyncDeltaType.DELETE.equals(icfDeltaType)) {
LOGGER.trace("START creating delta of type DELETE");
ObjectDelta<ShadowType> objectDelta = new ObjectDelta<ShadowType>(ShadowType.class, ChangeType.DELETE, prismContext);
Collection<ResourceAttribute<?>> identifiers = ConnIdUtil.convertToIdentifiers(icfDelta.getUid(), deltaObjClassDefinition, resourceSchema);
Change change = new Change(identifiers, objectDelta, getToken(icfDelta.getToken()));
change.setObjectClassDefinition(deltaObjClassDefinition);
changeList.add(change);
LOGGER.trace("END creating delta of type DELETE");
} else if (SyncDeltaType.CREATE.equals(icfDeltaType)) {
PrismObjectDefinition<ShadowType> objectDefinition = toShadowDefinition(deltaObjClassDefinition);
LOGGER.trace("Object definition: {}", objectDefinition);
LOGGER.trace("START creating delta of type CREATE");
PrismObject<ShadowType> currentShadow = connIdConvertor.convertToResourceObject(icfDelta.getObject(), objectDefinition, false, caseIgnoreAttributeNames, legacySchema);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Got current shadow: {}", currentShadow.debugDump());
}
Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getAllIdentifiers(currentShadow);
ObjectDelta<ShadowType> objectDelta = new ObjectDelta<ShadowType>(ShadowType.class, ChangeType.ADD, prismContext);
objectDelta.setObjectToAdd(currentShadow);
Change change = new Change(identifiers, objectDelta, getToken(icfDelta.getToken()));
change.setObjectClassDefinition(deltaObjClassDefinition);
changeList.add(change);
LOGGER.trace("END creating delta of type CREATE");
} else if (SyncDeltaType.CREATE_OR_UPDATE.equals(icfDeltaType) || SyncDeltaType.UPDATE.equals(icfDeltaType)) {
PrismObjectDefinition<ShadowType> objectDefinition = toShadowDefinition(deltaObjClassDefinition);
LOGGER.trace("Object definition: {}", objectDefinition);
LOGGER.trace("START creating delta of type {}", icfDeltaType);
PrismObject<ShadowType> currentShadow = connIdConvertor.convertToResourceObject(icfDelta.getObject(), objectDefinition, false, caseIgnoreAttributeNames, legacySchema);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Got current shadow: {}", currentShadow.debugDump());
}
Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getAllIdentifiers(currentShadow);
Change change = new Change(identifiers, currentShadow, getToken(icfDelta.getToken()));
change.setObjectClassDefinition(deltaObjClassDefinition);
changeList.add(change);
LOGGER.trace("END creating delta of type {}:\n{}", icfDeltaType, change.debugDump());
} else {
throw new GenericFrameworkException("Unexpected sync delta type " + icfDeltaType);
}
}
return changeList;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class AbstractManualConnectorInstance method addObject.
// TODO: operations to check ticket state
@Override
public AsynchronousOperationReturnValue<Collection<ResourceAttribute<?>>> addObject(PrismObject<? extends ShadowType> object, Collection<Operation> additionalOperations, StateReporter reporter, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException {
OperationResult result = parentResult.createSubresult(OPERATION_ADD);
String ticketIdentifier = null;
try {
ticketIdentifier = createTicketAdd(object, additionalOperations, result);
} catch (CommunicationException | GenericFrameworkException | SchemaException | ObjectAlreadyExistsException | ConfigurationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
result.recordInProgress();
result.setAsynchronousOperationReference(ticketIdentifier);
AsynchronousOperationReturnValue<Collection<ResourceAttribute<?>>> ret = new AsynchronousOperationReturnValue<>();
ret.setOperationResult(result);
return ret;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class AbstractManualConnectorInstance method modifyObject.
@Override
public AsynchronousOperationReturnValue<Collection<PropertyModificationOperation>> modifyObject(ObjectClassComplexTypeDefinition objectClass, Collection<? extends ResourceAttribute<?>> identifiers, Collection<Operation> changes, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, SecurityViolationException, ObjectAlreadyExistsException, ConfigurationException {
OperationResult result = parentResult.createSubresult(OPERATION_MODIFY);
String ticketIdentifier = null;
try {
ticketIdentifier = createTicketModify(objectClass, identifiers, changes, result);
} catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ObjectAlreadyExistsException | ConfigurationException | RuntimeException | Error e) {
result.recordFatalError(e);
throw e;
}
result.recordInProgress();
result.setAsynchronousOperationReference(ticketIdentifier);
AsynchronousOperationReturnValue<Collection<PropertyModificationOperation>> ret = new AsynchronousOperationReturnValue<>();
ret.setOperationResult(result);
return ret;
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ShadowCache method deleteShadow.
public void deleteShadow(PrismObject<ShadowType> shadow, ProvisioningOperationOptions options, OperationProvisioningScriptsType scripts, Task task, OperationResult parentResult) throws CommunicationException, GenericFrameworkException, ObjectNotFoundException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
Validate.notNull(shadow, "Object to delete must not be null.");
Validate.notNull(parentResult, "Operation result must not be null.");
InternalMonitor.recordShadowChangeOperation();
ProvisioningContext ctx = ctxFactory.create(shadow, task, parentResult);
try {
ctx.assertDefinition();
} catch (ObjectNotFoundException ex) {
// although the resource does not exists..
if (ProvisioningOperationOptions.isForce(options)) {
parentResult.muteLastSubresultError();
shadowManager.deleteShadow(ctx, shadow, null, parentResult);
parentResult.recordHandledError("Resource defined in shadow does not exists. Shadow was deleted from the repository.");
return;
} else {
throw ex;
}
}
applyAttributesDefinition(ctx, shadow);
LOGGER.trace("Deleting object {} from the resource {}.", shadow, ctx.getResource());
AsynchronousOperationResult asyncReturnValue = null;
if (shadow.asObjectable().getFailedOperationType() == null || (shadow.asObjectable().getFailedOperationType() != null && FailedOperationTypeType.ADD != shadow.asObjectable().getFailedOperationType())) {
try {
asyncReturnValue = resouceObjectConverter.deleteResourceObject(ctx, shadow, scripts, parentResult);
} catch (Exception ex) {
try {
handleError(ctx, ex, shadow, FailedOperation.DELETE, null, isDoDiscovery(ctx.getResource(), options), isCompensate(options), parentResult);
} catch (ObjectAlreadyExistsException e) {
parentResult.recordFatalError(e);
throw new SystemException(e.getMessage(), e);
}
return;
}
}
LOGGER.trace("Detele object with oid {} form repository.", shadow.getOid());
try {
shadowManager.deleteShadow(ctx, shadow, asyncReturnValue == null ? null : asyncReturnValue.getOperationResult(), parentResult);
} catch (ObjectNotFoundException ex) {
parentResult.recordFatalError("Can't delete object " + shadow + ". Reason: " + ex.getMessage(), ex);
throw new ObjectNotFoundException("An error occured while deleting resource object " + shadow + "whith identifiers " + shadow + ": " + ex.getMessage(), ex);
}
ObjectDelta<ShadowType> delta = ObjectDelta.createDeleteDelta(shadow.getCompileTimeClass(), shadow.getOid(), prismContext);
ResourceOperationDescription operationDescription = createSuccessOperationDescription(ctx, shadow, delta, parentResult);
if (asyncReturnValue != null && asyncReturnValue.isInProgress()) {
operationListener.notifyInProgress(operationDescription, task, parentResult);
} else {
operationListener.notifySuccess(operationDescription, task, parentResult);
}
LOGGER.trace("Object deleted from repository successfully.");
parentResult.computeStatus();
resourceManager.modifyResourceAvailabilityStatus(ctx.getResource().asPrismObject(), AvailabilityStatusType.UP, parentResult);
}
use of com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException in project midpoint by Evolveum.
the class ProvisioningServiceImpl method refreshShadow.
@Override
public void refreshShadow(PrismObject<ShadowType> shadow, ProvisioningOperationOptions options, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, SecurityViolationException, ExpressionEvaluationException {
Validate.notNull(shadow, "Shadow for refresh must not be null.");
OperationResult result = parentResult.createSubresult(ProvisioningServiceImpl.class.getName() + ".finishOperation");
LOGGER.debug("Refreshing shadow {}", shadow);
try {
getShadowCache(Mode.RECON).refreshShadow(shadow, task, result);
refreshShadowLegacy(shadow, options, task, result);
} catch (GenericFrameworkException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't refresh shadow: " + e.getClass().getSimpleName() + ": " + e.getMessage(), e);
throw new CommunicationException(e.getMessage(), e);
} catch (CommunicationException | SchemaException | ObjectNotFoundException | ConfigurationException | SecurityViolationException | ObjectAlreadyExistsException | ExpressionEvaluationException | RuntimeException | Error e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't refresh shadow: " + e.getClass().getSimpleName() + ": " + e.getMessage(), e);
throw e;
}
result.computeStatus();
result.cleanupResult();
LOGGER.debug("Finished refreshing shadow {}: ", shadow, result);
}
Aggregations