Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support-3.7' into support-3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 13, 2018
2 parents f8f8691 + b1896ed commit 03e7ade
Show file tree
Hide file tree
Showing 14 changed files with 802 additions and 92 deletions.
Expand Up @@ -179,9 +179,11 @@ public <F extends FocusType> void processActivationUserCurrent(LensContext<F> co
return;
}

boolean shadowShouldExist = evaluateExistenceMapping(context, projCtx, now, true, task, result);
LOGGER.trace("Evaluating intended existence of projection {} (legal={})", projCtxDesc, projCtx.isLegal());

boolean shadowShouldExist = evaluateExistenceMapping(context, projCtx, now, MappingTimeEval.CURRENT, task, result);

LOGGER.trace("Evaluated intended existence of projection {} to {}", projCtxDesc, shadowShouldExist);
LOGGER.trace("Evaluated intended existence of projection {} to {} (legal={})", projCtxDesc, shadowShouldExist, projCtx.isLegal());

// Let's reconcile the existence intent (shadowShouldExist) and the synchronization intent in the context

Expand Down Expand Up @@ -296,7 +298,7 @@ public <F extends FocusType> void processActivationUserCurrent(LensContext<F> co
evaluateActivationMapping(context, projCtx,
activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
capActivation, now, true, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
capActivation, now, MappingTimeEval.CURRENT, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
} else {
LOGGER.trace("Skipping activation administrative status processing because {} does not have activation administrative status capability", projCtx.getResource());
}
Expand All @@ -309,7 +311,7 @@ public <F extends FocusType> void processActivationUserCurrent(LensContext<F> co
} else {
evaluateActivationMapping(context, projCtx, activationType.getValidFrom(),
SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM,
null, now, true, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
null, now, MappingTimeEval.CURRENT, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}

ResourceBidirectionalMappingType validToMappingType = activationType.getValidTo();
Expand All @@ -320,14 +322,14 @@ public <F extends FocusType> void processActivationUserCurrent(LensContext<F> co
} else {
evaluateActivationMapping(context, projCtx, activationType.getValidTo(),
SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO,
null, now, true, ActivationType.F_VALID_TO.getLocalPart(), task, result);
null, now, MappingTimeEval.CURRENT, ActivationType.F_VALID_TO.getLocalPart(), task, result);
}

if (capLockoutStatus != null) {
evaluateActivationMapping(context, projCtx,
activationType.getLockoutStatus(),
SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS,
capActivation, now, true, ActivationType.F_LOCKOUT_STATUS.getLocalPart(), task, result);
capActivation, now, MappingTimeEval.CURRENT, ActivationType.F_LOCKOUT_STATUS.getLocalPart(), task, result);
} else {
LOGGER.trace("Skipping activation lockout status processing because {} does not have activation lockout status capability", projCtx.getResource());
}
Expand Down Expand Up @@ -417,7 +419,7 @@ public <F extends FocusType> void processActivationUserFuture(LensContext<F> con

accCtx.recompute();

evaluateExistenceMapping(context, accCtx, now, false, task, result);
evaluateExistenceMapping(context, accCtx, now, MappingTimeEval.FUTURE, task, result);

PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
if (focusNew == null) {
Expand Down Expand Up @@ -448,26 +450,26 @@ public <F extends FocusType> void processActivationUserFuture(LensContext<F> con

evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
capActivation, now, false, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
capActivation, now, MappingTimeEval.FUTURE, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
}

if (capValidFrom != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM,
null, now, false, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}

if (capValidTo != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO,
null, now, false, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}

}


private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context,
final LensProjectionContext projCtx, final XMLGregorianCalendar now, final boolean current,
final LensProjectionContext projCtx, final XMLGregorianCalendar now, final MappingTimeEval current,
Task task, final OperationResult result)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
final String projCtxDesc = projCtx.toHumanReadableString();
Expand All @@ -477,8 +479,6 @@ private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext
throw new IllegalStateException("Null 'legal' for "+projCtxDesc);
}

LOGGER.trace("Evaluating intended existence of projection {}; legal={}", projCtxDesc, legal);

ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return legal;
Expand Down Expand Up @@ -583,7 +583,7 @@ private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext
private <T, F extends FocusType> void evaluateActivationMapping(final LensContext<F> context,
final LensProjectionContext projCtx, ResourceBidirectionalMappingType bidirectionalMappingType,
final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
final ActivationCapabilityType capActivation, XMLGregorianCalendar now, final boolean current,
final ActivationCapabilityType capActivation, XMLGregorianCalendar now, final MappingTimeEval current,
String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {

MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> initializer =
Expand Down Expand Up @@ -647,7 +647,7 @@ private <T, F extends FocusType> void evaluateOutboundMapping(final LensContext<
final LensProjectionContext projCtx, ResourceBidirectionalMappingType bidirectionalMappingType,
final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
final MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> initializer,
XMLGregorianCalendar now, final boolean evaluateCurrent, String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
XMLGregorianCalendar now, final MappingTimeEval evaluateCurrent, String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {

if (bidirectionalMappingType == null) {
LOGGER.trace("No '{}' definition in projection {}, skipping", desc, projCtx.toHumanReadableString());
Expand Down Expand Up @@ -696,15 +696,15 @@ private <T, F extends FocusType> void evaluateOutboundMapping(final LensContext<
Map<ItemPath, MappingOutputStruct<PrismPropertyValue<T>>> outputTripleMap = mappingEvaluator.evaluateMappingSetProjection(params, task, result);

if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Mapping processing output after {}:\n{}", desc, DebugUtil.debugDump(outputTripleMap, 1));
LOGGER.trace("Mapping processing output after {} ({}):\n{}", desc, evaluateCurrent, DebugUtil.debugDump(outputTripleMap, 1));
}

if (projCtx.isDoReconciliation()) {
reconcileOutboundValue(context, projCtx, outputTripleMap, desc);
}

}

/**
* TODO: can we align this with ReconciliationProcessor?
*/
Expand Down Expand Up @@ -926,7 +926,7 @@ private <F extends FocusType> void processLifecycleFocus(LensContext<F> context,
LOGGER.trace("Computing projection lifecycle (mapping): {}", lifecycleStateMappingType);
evaluateActivationMapping(context, projCtx, lifecycleStateMappingType,
SchemaConstants.PATH_LIFECYCLE_STATE, SchemaConstants.PATH_LIFECYCLE_STATE,
null, now, true, ObjectType.F_LIFECYCLE_STATE.getLocalPart(), task, result);
null, now, MappingTimeEval.CURRENT, ObjectType.F_LIFECYCLE_STATE.getLocalPart(), task, result);
}

}
Expand Down
Expand Up @@ -156,7 +156,7 @@ public <T, F extends FocusType> void evaluateOutboundMapping(final LensContext<F
final LensProjectionContext projCtx, List<MappingType> outboundMappings,
final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
final MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> initializer, MappingOutputProcessor<PrismPropertyValue<T>> processor,
XMLGregorianCalendar now, final boolean evaluateCurrent, boolean evaluateWeak,
XMLGregorianCalendar now, final MappingTimeEval evaluateCurrent, boolean evaluateWeak,
String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {

String projCtxDesc = projCtx.toHumanReadableString();
Expand Down Expand Up @@ -245,11 +245,11 @@ public <V extends PrismValue, D extends ItemDefinition, T extends ObjectType, F
Boolean timeConstraintValid = mapping.evaluateTimeConstraintValid(task, result);

if (params.getEvaluateCurrent() != null) {
if (params.getEvaluateCurrent() && !timeConstraintValid) {
if (params.getEvaluateCurrent() == MappingTimeEval.CURRENT && !timeConstraintValid) {
LOGGER.trace("Mapping {} is non-current, but evulating current mappings, skipping {}", mappingName, params.getContext().getChannel());
continue;
}
if (!params.getEvaluateCurrent() && timeConstraintValid) {
if (params.getEvaluateCurrent() == MappingTimeEval.FUTURE && timeConstraintValid) {
LOGGER.trace("Mapping {} is current, but evulating non-current mappings, skipping {}", mappingName, params.getContext().getChannel());
continue;
}
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class MappingEvaluatorParams<V extends PrismValue, D extends ItemDefiniti
private ItemPath defaultTargetItemPath;
// Only needed if defaultTargetItemPath == null
private D targetItemDefinition;
private Boolean evaluateCurrent;
private MappingTimeEval evaluateCurrent;
private boolean evaluateWeak = true;
private LensContext<F> context;
private boolean hasFullTargetObject;
Expand Down Expand Up @@ -137,11 +137,11 @@ public void setSourceContext(ObjectDeltaObject<?> sourceContext) {
this.sourceContext = sourceContext;
}

public Boolean getEvaluateCurrent() {
public MappingTimeEval getEvaluateCurrent() {
return evaluateCurrent;
}

public void setEvaluateCurrent(Boolean evaluateCurrent) {
public void setEvaluateCurrent(MappingTimeEval evaluateCurrent) {
this.evaluateCurrent = evaluateCurrent;
}

Expand Down
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.model.impl.lens.projector;

/**
* @author semancik
*
*/
public enum MappingTimeEval {

CURRENT, FUTURE;

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -40,6 +40,7 @@
import com.evolveum.midpoint.model.impl.lens.projector.MappingEvaluator;
import com.evolveum.midpoint.model.impl.lens.projector.MappingInitializer;
import com.evolveum.midpoint.model.impl.lens.projector.MappingOutputProcessor;
import com.evolveum.midpoint.model.impl.lens.projector.MappingTimeEval;
import com.evolveum.midpoint.prism.ItemDefinition;
import com.evolveum.midpoint.prism.OriginType;
import com.evolveum.midpoint.prism.PrismContainerValue;
Expand Down Expand Up @@ -255,7 +256,7 @@ public ValuePolicyType resolve() {

mappingEvaluator.evaluateOutboundMapping(context, projCtx, outboundMappingTypes,
SchemaConstants.PATH_PASSWORD_VALUE, SchemaConstants.PATH_PASSWORD_VALUE, initializer, processor,
now, true, evaluateWeak, "password mapping", task, result);
now, MappingTimeEval.CURRENT, evaluateWeak, "password mapping", task, result);

}

Expand Down
Expand Up @@ -396,16 +396,25 @@ private void processAssignment(DeltaSetTriple<EvaluatedAssignmentImpl<F>> evalua
} else {
// No change in assignment
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Processing unchanged assignment {}", SchemaDebugUtil.prettyPrint(assignmentCVal));
LOGGER.trace("Processing unchanged assignment ({}) {}",
presentInCurrent ? "present" : "not present",
SchemaDebugUtil.prettyPrint(assignmentCVal));
}
EvaluatedAssignmentImpl<F> evaluatedAssignment = evaluateAssignment(createAssignmentIdiNoChange(assignmentCVal), PlusMinusZero.ZERO, false, context, source, assignmentEvaluator, assignmentPlacementDesc, task, result);
if (evaluatedAssignment == null) {
return;
}
// NOTE: unchanged may mean both:
// * was there before, is there now
// * was not there before, is not there now
evaluatedAssignment.setPresentInCurrentObject(presentInCurrent);
evaluatedAssignment.setPresentInOldObject(presentInOld);
evaluatedAssignment.setWasValid(evaluatedAssignment.isValid());
collectToZero(evaluatedAssignmentTriple, evaluatedAssignment, forceRecon);
if (presentInCurrent) {
collectToZero(evaluatedAssignmentTriple, evaluatedAssignment, forceRecon);
} else {
collectToMinus(evaluatedAssignmentTriple, evaluatedAssignment, forceRecon);
}
}
}
}
Expand Down
Expand Up @@ -58,6 +58,7 @@
import com.evolveum.midpoint.model.impl.lens.projector.MappingEvaluatorParams;
import com.evolveum.midpoint.model.impl.lens.projector.MappingInitializer;
import com.evolveum.midpoint.model.impl.lens.projector.MappingOutputProcessor;
import com.evolveum.midpoint.model.impl.lens.projector.MappingTimeEval;
import com.evolveum.midpoint.model.impl.lens.projector.credentials.CredentialsProcessor;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.ItemDefinition;
Expand Down Expand Up @@ -1438,7 +1439,7 @@ private <F extends FocusType> void processSpecialPropertyInbound(Collection<Mapp
params.setAPrioriTargetDelta(userPrimaryDelta);
params.setTargetContext(context.getFocusContext());
params.setDefaultTargetItemPath(targetPath);
params.setEvaluateCurrent(true);
params.setEvaluateCurrent(MappingTimeEval.CURRENT);
params.setContext(context);
params.setHasFullTargetObject(true);
mappingEvaluator.evaluateMappingSetProjection(params, task, opResult);
Expand Down

0 comments on commit 03e7ade

Please sign in to comment.