use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class ShadowCache method futurizeShadow.
private PrismObject<ShadowType> futurizeShadow(PrismObject<ShadowType> shadow, Collection<SelectorOptions<GetOperationOptions>> options, ResourceType resource) throws SchemaException {
PointInTimeType pit = GetOperationOptions.getPointInTimeType(SelectorOptions.findRootOptions(options));
if (pit != PointInTimeType.FUTURE) {
return shadow;
}
PrismObject<ShadowType> resultShadow = shadow;
ShadowType resultShadowType = resultShadow.asObjectable();
List<PendingOperationType> sortedOperations = sortOperations(resultShadowType.getPendingOperation());
boolean resourceReadIsCachingOnly = resourceReadIsCachingOnly(resource);
for (PendingOperationType pendingOperation : sortedOperations) {
OperationResultStatusType resultStatus = pendingOperation.getResultStatus();
if (resultStatus == OperationResultStatusType.FATAL_ERROR || resultStatus == OperationResultStatusType.NOT_APPLICABLE) {
continue;
}
if (resourceReadIsCachingOnly) {
// Re-applying them will mean additional risk of corrupting the data.
if (resultStatus != null && resultStatus != OperationResultStatusType.IN_PROGRESS && resultStatus != OperationResultStatusType.UNKNOWN) {
continue;
}
} else {
// We want to apply all the deltas, even those that are already completed. They might not be reflected on the resource yet.
// E.g. they may be not be present in the CSV export until the next export cycle is scheduled
}
ObjectDeltaType pendingDeltaType = pendingOperation.getDelta();
ObjectDelta<ShadowType> pendingDelta = DeltaConvertor.createObjectDelta(pendingDeltaType, prismContext);
if (pendingDelta.isAdd()) {
if (Boolean.FALSE.equals(resultShadowType.isExists())) {
resultShadow = pendingDelta.getObjectToAdd().clone();
resultShadow.setOid(shadow.getOid());
resultShadowType = resultShadow.asObjectable();
resultShadowType.setExists(true);
resultShadowType.setName(shadow.asObjectable().getName());
}
}
if (pendingDelta.isModify()) {
pendingDelta.applyTo(resultShadow);
}
if (pendingDelta.isDelete()) {
resultShadowType.setDead(true);
resultShadowType.setExists(false);
}
}
// }
return resultShadow;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class ShadowCache method extendShadow.
private PrismObject<ShadowType> extendShadow(PrismObject<ShadowType> shadow, OperationResult shadowResult, ResourceType resource, Collection<? extends ItemDelta> modifications) throws SchemaException {
ShadowType shadowType = shadow.asObjectable();
shadowType.setResult(shadowResult.createOperationResultType());
shadowType.setResource(resource);
if (modifications != null) {
ObjectDelta<? extends ObjectType> objectDelta = ObjectDelta.createModifyDelta(shadow.getOid(), modifications, shadowType.getClass(), prismContext);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Storing delta to shadow:\n{}", objectDelta.debugDump());
}
ContainerDelta<ShadowAssociationType> associationDelta = objectDelta.findContainerDelta(ShadowType.F_ASSOCIATION);
if (associationDelta != null) {
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToAdd());
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToReplace());
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToDelete());
}
ObjectDeltaType objectDeltaType = DeltaConvertor.toObjectDeltaType(objectDelta);
shadowType.setObjectChange(objectDeltaType);
}
return shadow;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class ShadowCacheProvisioner method mergeDeltas.
@SuppressWarnings({ "unchecked", "rawtypes" })
private ObjectDelta mergeDeltas(PrismObject<ShadowType> shadow, Collection<? extends ItemDelta> modifications) throws SchemaException {
ShadowType shadowType = shadow.asObjectable();
if (shadowType.getObjectChange() != null) {
ObjectDeltaType deltaType = shadowType.getObjectChange();
Collection<? extends ItemDelta> pendingModifications = DeltaConvertor.toModifications(deltaType.getItemDelta(), shadow.getDefinition());
// See e.g. MID-1709.
return ObjectDelta.summarize(ObjectDelta.createModifyDelta(shadow.getOid(), pendingModifications, ShadowType.class, getPrismContext()), ObjectDelta.createModifyDelta(shadow.getOid(), modifications, ShadowType.class, getPrismContext()));
}
return null;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class ShadowCacheReconciler method beforeModifyOnResource.
@Override
public Collection<? extends ItemDelta> beforeModifyOnResource(PrismObject<ShadowType> shadow, ProvisioningOperationOptions options, Collection<? extends ItemDelta> modifications) throws SchemaException {
ObjectDeltaType shadowDelta = shadow.asObjectable().getObjectChange();
//TODO: error handling
if (shadowDelta != null) {
modifications = DeltaConvertor.toModifications(shadowDelta.getItemDelta(), shadow.getDefinition());
}
// for the older versions
ObjectDelta<? extends ObjectType> objectDelta = ObjectDelta.createModifyDelta(shadow.getOid(), modifications, ShadowType.class, getPrismContext());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Storing delta to shadow:\n{}", objectDelta.debugDump());
}
ContainerDelta<ShadowAssociationType> associationDelta = objectDelta.findContainerDelta(ShadowType.F_ASSOCIATION);
if (associationDelta != null) {
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToAdd());
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToReplace());
normalizeAssociationDeltasBeforeSave(associationDelta.getValuesToDelete());
}
if (modifications == null) {
modifications = new ArrayList<ItemDelta>();
}
return modifications;
}
use of com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType in project midpoint by Evolveum.
the class ShadowManager method addPendingOperationAdd.
private void addPendingOperationAdd(PrismObject<ShadowType> repoShadow, AsynchronousOperationReturnValue<PrismObject<ShadowType>> addResult) throws SchemaException {
if (!addResult.isInProgress()) {
return;
}
PrismObject<ShadowType> resourceShadow = addResult.getReturnValue();
ShadowType repoShadowType = repoShadow.asObjectable();
ObjectDelta<ShadowType> addDelta = resourceShadow.createAddDelta();
ObjectDeltaType addDeltaType = DeltaConvertor.toObjectDeltaType(addDelta);
PendingOperationType pendingOperation = new PendingOperationType();
pendingOperation.setDelta(addDeltaType);
pendingOperation.setRequestTimestamp(clock.currentTimeXMLGregorianCalendar());
pendingOperation.setResultStatus(OperationResultStatusType.IN_PROGRESS);
pendingOperation.setAsynchronousOperationReference(addResult.getOperationResult().getAsynchronousOperationReference());
repoShadowType.getPendingOperation().add(pendingOperation);
repoShadowType.setExists(false);
}
Aggregations