use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ShadowIntegrityCheckResultHandler method doFixIntent.
private void doFixIntent(ShadowCheckResult checkResult, PrismObject<ShadowType> fetchedShadow, PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, Task task, OperationResult result) {
PrismObject<ShadowType> fullShadow;
if (!checkFetch) {
fullShadow = fetchShadow(checkResult, shadow, resource, task, result);
} else {
fullShadow = fetchedShadow;
}
if (fullShadow == null) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Cannot fix missing intent, because the resource object couldn't be fetched"));
return;
}
ObjectSynchronizationType synchronizationPolicy;
try {
synchronizationPolicy = synchronizationService.determineSynchronizationPolicy(resource.asObjectable(), fullShadow, configuration, task, result);
} catch (SchemaException | ObjectNotFoundException | ExpressionEvaluationException | RuntimeException e) {
checkResult.recordError(Statistics.CANNOT_APPLY_FIX, new SystemException("Couldn't prepare fix for missing intent, because the synchronization policy couldn't be determined", e));
return;
}
if (synchronizationPolicy != null) {
if (synchronizationPolicy.getIntent() != null) {
PropertyDelta delta = PropertyDelta.createReplaceDelta(fullShadow.getDefinition(), ShadowType.F_INTENT, synchronizationPolicy.getIntent());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Intent fix delta (not executed now) = \n{}", delta.debugDump());
}
checkResult.addFixDelta(delta, Statistics.NO_INTENT_SPECIFIED);
} else {
LOGGER.info("Synchronization policy does not contain intent: {}", synchronizationPolicy);
}
} else {
LOGGER.info("Intent couldn't be fixed, because no synchronization policy was found");
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class MidpointFunctionsImpl method computeProjectionLifecycle.
@Override
public <F extends FocusType> String computeProjectionLifecycle(F focus, ShadowType shadow, ResourceType resource) {
if (focus == null || shadow == null) {
return null;
}
if (!(focus instanceof UserType)) {
return null;
}
if (shadow.getKind() != null && shadow.getKind() != ShadowKindType.ACCOUNT) {
return null;
}
ProtectedStringType passwordPs = FocusTypeUtil.getPasswordValue((UserType) focus);
if (passwordPs != null && passwordPs.canGetCleartext()) {
return null;
}
CredentialsCapabilityType credentialsCapabilityType = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
if (credentialsCapabilityType == null) {
return null;
}
PasswordCapabilityType passwordCapabilityType = credentialsCapabilityType.getPassword();
if (passwordCapabilityType == null) {
return null;
}
if (passwordCapabilityType.isEnabled() == Boolean.FALSE) {
return null;
}
return SchemaConstants.LIFECYCLE_PROPOSED;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ObjectMerger method computeProjectionDeltas.
private <O extends ObjectType> void computeProjectionDeltas(final ObjectDelta<O> leftLinkDelta, ObjectDelta<O> rightLinkDelta, final PrismObject<O> objectLeft, final PrismObject<O> objectRight, MergeConfigurationType mergeConfiguration, final String mergeConfigurationName, final Task task, final OperationResult result) throws SchemaException, ConfigurationException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException {
List<ShadowType> projectionsLeft = getProjections(objectLeft, task, result);
List<ShadowType> projectionsRight = getProjections(objectRight, task, result);
List<ShadowType> mergedProjections = new ArrayList<>();
List<ShadowType> matchedProjections = new ArrayList<>();
ProjectionMergeConfigurationType defaultProjectionMergeConfig = null;
for (ProjectionMergeConfigurationType projectionMergeConfig : mergeConfiguration.getProjection()) {
if (projectionMergeConfig.getProjectionDiscriminator() == null && projectionMergeConfig.getSituation() == null) {
defaultProjectionMergeConfig = projectionMergeConfig;
} else {
takeProjections(projectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft, projectionsLeft, projectionsRight, projectionMergeConfig);
takeProjections(projectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight, projectionsLeft, projectionsRight, projectionMergeConfig);
}
}
LOGGER.trace("Merged projections (before default): {}", mergedProjections);
LOGGER.trace("Matched projections (before default): {}", matchedProjections);
if (defaultProjectionMergeConfig != null) {
takeUnmatchedProjections(defaultProjectionMergeConfig.getLeft(), mergedProjections, matchedProjections, projectionsLeft);
takeUnmatchedProjections(defaultProjectionMergeConfig.getRight(), mergedProjections, matchedProjections, projectionsRight);
}
LOGGER.trace("Merged projections: {}", mergedProjections);
checkConflict(mergedProjections);
for (ShadowType mergedProjection : mergedProjections) {
PrismReferenceValue leftLinkRef = findLinkRef(objectLeft, mergedProjection);
if (leftLinkRef == null) {
PrismReferenceValue linkRefRight = findLinkRef(objectRight, mergedProjection);
LOGGER.trace("Moving projection right->left: {}", mergedProjection);
addUnlinkDelta(rightLinkDelta, linkRefRight);
addLinkDelta(leftLinkDelta, linkRefRight);
} else {
LOGGER.trace("Projection already at the left: {}", mergedProjection);
}
}
for (PrismReferenceValue leftLinkRef : getLinkRefs(objectLeft)) {
if (!hasProjection(mergedProjections, leftLinkRef)) {
LOGGER.trace("Removing left projection: {}", leftLinkRef);
addUnlinkDelta(leftLinkDelta, leftLinkRef);
} else {
LOGGER.trace("Left projection stays: {}", leftLinkRef);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ObjectMerger method takeProjections.
private void takeProjections(MergeStategyType strategy, List<ShadowType> mergedProjections, List<ShadowType> matchedProjections, List<ShadowType> candidateProjections, List<ShadowType> projectionsLeft, List<ShadowType> projectionsRight, ProjectionMergeConfigurationType projectionMergeConfig) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("TAKE: Evaluating situation {}, discriminator: {}", projectionMergeConfig.getSituation(), projectionMergeConfig.getProjectionDiscriminator());
}
for (ShadowType candidateProjection : candidateProjections) {
if (projectionMatches(candidateProjection, projectionsLeft, projectionsRight, projectionMergeConfig)) {
LOGGER.trace("Projection matches {}", candidateProjection);
matchedProjections.add(candidateProjection);
if (strategy == MergeStategyType.TAKE) {
mergedProjections.add(candidateProjection);
} else if (strategy == null || strategy == MergeStategyType.IGNORE) {
// Nothing to do here
} else {
throw new UnsupportedOperationException("Merge strategy " + strategy + " is not supported");
}
} else {
LOGGER.trace("Discriminator does NOT match {}", candidateProjection);
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType in project midpoint by Evolveum.
the class ObjectMerger method getProjections.
private <O extends ObjectType> List<ShadowType> getProjections(PrismObject<O> objectRight, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
if (!objectRight.canRepresent(FocusType.class)) {
return new ArrayList<>(0);
}
List<ObjectReferenceType> linkRefs = ((FocusType) objectRight.asObjectable()).getLinkRef();
List<ShadowType> projections = new ArrayList<>(linkRefs.size());
for (ObjectReferenceType linkRef : linkRefs) {
projections.add(getProjection(linkRef, task, result));
}
return projections;
}
Aggregations