use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class OrgMemberPanel method deleteManagerConfirmPerformed.
private void deleteManagerConfirmPerformed(FocusType manager, AjaxRequestTarget target) {
getPageBase().hideMainPopup(target);
OperationResult parentResult = new OperationResult("Remove manager");
Task task = getPageBase().createSimpleTask("Remove manager");
try {
ObjectDelta delta = ObjectDelta.createDeleteDelta(manager.asPrismObject().getCompileTimeClass(), manager.getOid(), getPageBase().getPrismContext());
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, parentResult);
parentResult.computeStatus();
} catch (SchemaException | ObjectAlreadyExistsException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException | PolicyViolationException | SecurityViolationException e) {
parentResult.recordFatalError("Failed to remove manager " + e.getMessage(), e);
LoggingUtils.logUnexpectedException(LOGGER, "Failed to remove manager", e);
getPageBase().showResult(parentResult);
}
target.add(getPageBase().getFeedbackPanel());
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class DeltaConvertor method createObjectDelta.
public static <T extends Objectable> ObjectDelta<T> createObjectDelta(ObjectModificationType objectModification, PrismObjectDefinition<T> objDef) throws SchemaException {
ObjectDelta<T> objectDelta = new ObjectDelta<T>(objDef.getCompileTimeClass(), ChangeType.MODIFY, objDef.getPrismContext());
objectDelta.setOid(objectModification.getOid());
for (ItemDeltaType propMod : objectModification.getItemDelta()) {
ItemDelta itemDelta = createItemDelta(propMod, objDef);
objectDelta.addModification(itemDelta);
}
return objectDelta;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class PageAccount method savePerformed.
private void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving account changes.");
OperationResult result = new OperationResult(OPERATION_SAVE_ACCOUNT);
try {
WebComponentUtil.revive(accountModel, getPrismContext());
ObjectWrapper wrapper = accountModel.getObject();
ObjectDelta<ShadowType> delta = wrapper.getObjectDelta();
if (delta == null) {
return;
}
if (delta.getPrismContext() == null) {
getPrismContext().adopt(delta);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
}
if (delta.isEmpty()) {
return;
}
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
Task task = createSimpleTask(OPERATION_SAVE_ACCOUNT);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
getModelService().executeChanges(deltas, null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't save account.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save account", ex);
}
if (!result.isSuccess()) {
showResult(result);
target.add(getFeedbackPanel());
} else {
showResult(result);
redirectBack();
}
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class LensProjectionContext method fromLensProjectionContextType.
public static LensProjectionContext fromLensProjectionContextType(LensProjectionContextType projectionContextType, LensContext lensContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
String objectTypeClassString = projectionContextType.getObjectTypeClass();
if (StringUtils.isEmpty(objectTypeClassString)) {
throw new SystemException("Object type class is undefined in LensProjectionContextType");
}
ResourceShadowDiscriminator resourceShadowDiscriminator = ResourceShadowDiscriminator.fromResourceShadowDiscriminatorType(projectionContextType.getResourceShadowDiscriminator());
LensProjectionContext projectionContext = new LensProjectionContext(lensContext, resourceShadowDiscriminator);
projectionContext.retrieveFromLensElementContextType(projectionContextType, task, result);
if (projectionContextType.getSyncDelta() != null) {
projectionContext.syncDelta = DeltaConvertor.createObjectDelta(projectionContextType.getSyncDelta(), lensContext.getPrismContext());
} else {
projectionContext.syncDelta = null;
}
ObjectDeltaType secondaryDeltaType = projectionContextType.getSecondaryDelta();
projectionContext.secondaryDelta = secondaryDeltaType != null ? (ObjectDelta) DeltaConvertor.createObjectDelta(secondaryDeltaType, lensContext.getPrismContext()) : null;
ObjectType object = projectionContextType.getObjectNew() != null ? projectionContextType.getObjectNew() : projectionContextType.getObjectOld();
projectionContext.fixProvisioningTypeInDelta(projectionContext.secondaryDelta, object, task, result);
projectionContext.wave = projectionContextType.getWave() != null ? projectionContextType.getWave() : 0;
projectionContext.fullShadow = projectionContextType.isFullShadow() != null ? projectionContextType.isFullShadow() : false;
projectionContext.isAssigned = projectionContextType.isIsAssigned() != null ? projectionContextType.isIsAssigned() : false;
projectionContext.isAssignedOld = projectionContextType.isIsAssignedOld() != null ? projectionContextType.isIsAssignedOld() : false;
projectionContext.isActive = projectionContextType.isIsActive() != null ? projectionContextType.isIsActive() : false;
projectionContext.isLegal = projectionContextType.isIsLegal();
projectionContext.isLegalOld = projectionContextType.isIsLegalOld();
projectionContext.isExists = projectionContextType.isIsExists() != null ? projectionContextType.isIsExists() : false;
projectionContext.synchronizationPolicyDecision = SynchronizationPolicyDecision.fromSynchronizationPolicyDecisionType(projectionContextType.getSynchronizationPolicyDecision());
projectionContext.doReconciliation = projectionContextType.isDoReconciliation() != null ? projectionContextType.isDoReconciliation() : false;
projectionContext.synchronizationSituationDetected = projectionContextType.getSynchronizationSituationDetected();
projectionContext.synchronizationSituationResolved = projectionContextType.getSynchronizationSituationResolved();
projectionContext.accountPasswordPolicy = projectionContextType.getAccountPasswordPolicy();
projectionContext.syncAbsoluteTrigger = projectionContextType.isSyncAbsoluteTrigger();
return projectionContext;
}
use of com.evolveum.midpoint.prism.delta.ObjectDelta in project midpoint by Evolveum.
the class LensProjectionContext method getExecutableDelta.
/**
* Returns delta suitable for execution. The primary and secondary deltas may not make complete sense all by themselves.
* E.g. they may both be MODIFY deltas even in case that the account should be created. The deltas begin to make sense
* only if combined with sync decision. This method provides the deltas all combined and ready for execution.
*/
@Override
public ObjectDelta<ShadowType> getExecutableDelta() throws SchemaException {
SynchronizationPolicyDecision policyDecision = getSynchronizationPolicyDecision();
ObjectDelta<ShadowType> origDelta = getFixedDelta();
if (policyDecision == SynchronizationPolicyDecision.ADD) {
// let's try to retrieve original (non-fixed) delta. Maybe it's ADD delta so we spare fixing it.
origDelta = getDelta();
if (origDelta == null || origDelta.isModify()) {
// We need to convert modify delta to ADD
ObjectDelta<ShadowType> addDelta = new ObjectDelta<ShadowType>(getObjectTypeClass(), ChangeType.ADD, getPrismContext());
RefinedObjectClassDefinition rObjectClassDef = getCompositeObjectClassDefinition();
if (rObjectClassDef == null) {
throw new IllegalStateException("Definition for account type " + getResourceShadowDiscriminator() + " not found in the context, but it should be there");
}
PrismObject<ShadowType> newAccount = (PrismObject<ShadowType>) rObjectClassDef.createBlankShadow();
addDelta.setObjectToAdd(newAccount);
if (origDelta != null) {
addDelta.merge(origDelta);
}
return addDelta;
}
} else if (policyDecision == SynchronizationPolicyDecision.KEEP) {
// Any delta is OK
} else if (policyDecision == SynchronizationPolicyDecision.DELETE) {
ObjectDelta<ShadowType> deleteDelta = new ObjectDelta<ShadowType>(getObjectTypeClass(), ChangeType.DELETE, getPrismContext());
String oid = getOid();
if (oid == null) {
throw new IllegalStateException("Internal error: account context OID is null during attempt to create delete secondary delta; context=" + this);
}
deleteDelta.setOid(oid);
return deleteDelta;
} else {
// This is either UNLINK or null, both are in fact the same as KEEP
// Any delta is OK
}
return origDelta;
}
Aggregations