Skip to content

Commit

Permalink
thresholds implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Dec 24, 2018
1 parent 41f4ec8 commit cce8e60
Show file tree
Hide file tree
Showing 53 changed files with 1,533 additions and 282 deletions.
Expand Up @@ -887,7 +887,7 @@ protected AssignmentInfoDto createDelegableAssignmentsPreviewDto(AssignmentType
return null;
}

private AssignmentInfoDto createAssignmentsPreviewDto(PrismObject<? extends FocusType> targetObject,
private AssignmentInfoDto createAssignmentsPreviewDto(PrismObject<? extends AssignmentHolderType> targetObject,
boolean isDirectlyAssigned, AssignmentType assignment,
Task task, OperationResult result) {
AssignmentInfoDto dto = new AssignmentInfoDto();
Expand Down Expand Up @@ -915,7 +915,7 @@ private AssignmentInfoDto createAssignmentsPreviewDto(PrismObject<? extends Focu
return dto;
}

private String getNameToDisplay(PrismObject<? extends FocusType> target) {
private String getNameToDisplay(PrismObject<? extends AssignmentHolderType> target) {
if (target.canRepresent(AbstractRoleType.class)) {
String n = PolyString.getOrig(((AbstractRoleType)target.asObjectable()).getDisplayName());
if (StringUtils.isNotBlank(n)) {
Expand Down
Expand Up @@ -109,9 +109,9 @@ public class TestIntegrationObjectWrapperFactory extends AbstractInitializedGuiI
private static final String USER_NEWMAN_EMPLOYEE_NUMBER = "N00001";
private static final String USER_NEWMAN_SHIP = "Nova";

private static final int BASIC_USERS_CONTAINERS = 8;
private static final int BASIC_SHADOW_CONTAINERS = 9;
private static final int BASIC_ORG_CONTAINERS = 14;
private static final int BASIC_USERS_CONTAINERS = 9;
private static final int BASIC_SHADOW_CONTAINERS = 10;
private static final int BASIC_ORG_CONTAINERS = 15;

private String userWallyOid;
private String accountWallyOid;
Expand Down
Expand Up @@ -283,6 +283,7 @@ public abstract class SchemaConstants {
NS_MODEL_EXTENSION, "freshnessInterval"); // unused? TODO consider
// removing
public static final ItemName MODEL_EXTENSION_DRY_RUN = new ItemName(NS_MODEL_EXTENSION, "dryRun");
public static final ItemName MODEL_EXTENSION_SIMULATE_BEFORE_EXECUTE = new ItemName(NS_MODEL_EXTENSION, "simulateBeforeExecute");
public static final ItemName SYNC_TOKEN_RETRY_UNHANDLED = new ItemName(NS_MODEL_EXTENSION, "retryLiveSyncErrors");
public static final ItemName MODEL_EXTENSION_FINISH_OPERATIONS_ONLY = new ItemName(NS_MODEL_EXTENSION, "finishOperationsOnly");
public static final ItemName MODEL_EXTENSION_KIND = new ItemName(NS_MODEL_EXTENSION, "kind");
Expand Down
Expand Up @@ -15,6 +15,7 @@
*/
package com.evolveum.midpoint.schema.internals;

import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

Expand All @@ -26,5 +27,5 @@ public interface InternalInspector {

<O extends ObjectType> void inspectRepositoryRead(Class<O> type, String oid);

<F extends FocusType> void inspectRoleEvaluation(F target, boolean fullEvaluation);
<F extends AssignmentHolderType> void inspectRoleEvaluation(F target, boolean fullEvaluation);
}
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

Expand Down Expand Up @@ -218,7 +219,7 @@ public synchronized <O extends Objectable> void afterObjectClone(PrismObject<O>
}
}

public static <F extends FocusType> void recordRoleEvaluation(F target, boolean fullEvaluation) {
public static <F extends AssignmentHolderType> void recordRoleEvaluation(F target, boolean fullEvaluation) {
long count = recordCountInternal(InternalCounters.ROLE_EVALUATION_COUNT);
if (isTrace(InternalCounters.ROLE_EVALUATION_COUNT)) {
traceOperation("roleEvaluation", () -> target.toString() , count, true);
Expand All @@ -228,7 +229,7 @@ public static <F extends FocusType> void recordRoleEvaluation(F target, boolean
}
}

public static <F extends FocusType> void recordRoleEvaluationSkip(F target, boolean fullEvaluation) {
public static <F extends AssignmentHolderType> void recordRoleEvaluationSkip(F target, boolean fullEvaluation) {
long count = recordCountInternal(InternalCounters.ROLE_EVALUATION_SKIP_COUNT);
if (isTrace(InternalCounters.ROLE_EVALUATION_SKIP_COUNT)) {
traceOperation("roleEvaluationSkip", () -> target.toString() , count, true);
Expand Down
Expand Up @@ -377,6 +377,7 @@ public static List<PolicyActionType> getAllActions(PolicyActionsType actions) {
addIgnoreNull(rv, actions.getCertification());
addIgnoreNull(rv, actions.getPrune());
addIgnoreNull(rv, actions.getRemediation());
addIgnoreNull(rv, actions.getStop());
return rv;
}

Expand Down
Expand Up @@ -377,6 +377,18 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="lensContext" type="tns:LensContextType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Model context descibing executed operation
</xsd:documentation>
<xsd:appinfo>
<a:since>4.0</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="policySituation" type="xsd:anyURI" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
Expand Down Expand Up @@ -17526,7 +17538,7 @@
<xsd:element name="policyActions" type="tns:PolicyActionsType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Action(s) that has to be takes as a reaction to this rule being
Action(s) that has to be taken as a reaction to this rule being
triggered.
</xsd:documentation>
<xsd:appinfo>
Expand Down
Expand Up @@ -1400,6 +1400,17 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="stop" type="tns:StopPolicyActionType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Stop action. This action stops the operation after n executions and results with the error.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>PolicyActionsType.stop</a:displayName>
<a:help>PolicyActionsType.stop.help</a:help>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>
Expand Down Expand Up @@ -1456,6 +1467,19 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="count" type="xsd:integer" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
<p>
Action is executed after reatching the limit
</p>
</xsd:documentation>
<xsd:appinfo>
<a:displayName>PolicyActionType.count</a:displayName>
<a:help>PolicyActionType.cunt.help</a:help>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>
Expand All @@ -1480,6 +1504,27 @@
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="StopPolicyActionType">
<xsd:annotation>
<xsd:documentation>
Stop action. This action stops the operation and results with the error.
</xsd:documentation>
<xsd:appinfo>
<a:container />
<a:since>4.0</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="tns:PolicyActionType">
<xsd:sequence>
<!-- Empty for now.
TODO: later add type of error and message -->
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

<xsd:complexType name="ApprovalPolicyActionType">
<xsd:annotation>
Expand Down
Expand Up @@ -67,6 +67,7 @@
</xsd:annotation>
</xsd:element>

<!-- TODO deprecated -->
<xsd:element name="dryRun" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -82,6 +83,21 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="simulateBeforeExecute" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Indicates if the reconciliation runs in default mode or firstly simulate and compute changes. If set to true,
it means that the reconciliation will not perform any action, but it will run projection in preview mode.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>Simulation before execution</a:displayName>
<a:displayOrder>804</a:displayOrder>
<a:minOccurs>0</a:minOccurs>
<a:maxOccurs>1</a:maxOccurs>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>

<xsd:element name="retryLiveSyncErrors" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Expand Down
Expand Up @@ -18,6 +18,7 @@
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.RelationRegistry;
import com.evolveum.midpoint.util.DebugDumpable;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentHolderType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;
import org.jetbrains.annotations.NotNull;
Expand All @@ -28,7 +29,7 @@
*/
public interface EvaluatedAssignmentTarget extends DebugDumpable {

PrismObject<? extends FocusType> getTarget();
PrismObject<? extends AssignmentHolderType> getTarget();

boolean isDirectlyAssigned();

Expand Down
Expand Up @@ -80,6 +80,7 @@
import com.evolveum.midpoint.model.impl.ModelCrudService;
import com.evolveum.midpoint.model.impl.ModelObjectResolver;
import com.evolveum.midpoint.model.impl.lens.AssignmentEvaluator;
import com.evolveum.midpoint.model.impl.lens.Clockwork;
import com.evolveum.midpoint.model.impl.lens.ContextFactory;
import com.evolveum.midpoint.model.impl.lens.LensContext;
import com.evolveum.midpoint.model.impl.lens.LensContextPlaceholder;
Expand Down Expand Up @@ -187,6 +188,7 @@ public class ModelInteractionServiceImpl implements ModelInteractionService {
@Autowired UserProfileService userProfileService;
@Autowired private ExpressionFactory expressionFactory;
@Autowired private OperationalDataManager metadataManager;
@Autowired private Clockwork clockwork;

private static final String OPERATION_GENERATE_VALUE = ModelInteractionService.class.getName() + ".generateValue";
private static final String OPERATION_VALIDATE_VALUE = ModelInteractionService.class.getName() + ".validateValue";
Expand Down Expand Up @@ -225,57 +227,23 @@ public <F extends ObjectType> ModelContext<F> previewChanges(
LensContext<F> context = null;

try {
RepositoryCache.enter();
//used cloned deltas instead of origin deltas, because some of the values should be lost later..
context = contextFactory.createContext(clonedDeltas, options, task, result);
context.setPreview(true);

// context.setOptions(options);
LOGGER.trace("Preview changes context:\n{}", context.debugDumpLazily());
context.setProgressListeners(listeners);

projector.projectAllWaves(context, "preview", task, result);
context.distributeResource();

if (hookRegistry != null) {
for (ChangeHook hook : hookRegistry.getAllChangeHooks()) {
hook.invokePreview(context, task, result);
}
}

schemaTransformer.applySchemasAndSecurity(context, null, task, result);
RepositoryCache.enter();
// used cloned deltas instead of origin deltas, because some of the
// values should be lost later..
context = contextFactory.createContext(clonedDeltas, options, task, result);
context = clockwork.previewChanges(context, listeners, task, result);

} catch (ConfigurationException | SecurityViolationException | ObjectNotFoundException | SchemaException |
CommunicationException | PolicyViolationException | RuntimeException | ObjectAlreadyExistsException |
ExpressionEvaluationException e) {
ModelImplUtils.recordFatalError(result, e);
throw e;

} catch (PreconditionViolationException e) {
ModelImplUtils.recordFatalError(result, e);
// TODO: Temporary fix for 3.6.1
// We do not want to propagate PreconditionViolationException to model API as that might break compatiblity
// ... and we do not really need that in 3.6.1
// TODO: expose PreconditionViolationException in 3.7
throw new SystemException(e);

schemaTransformer.applySchemasAndSecurity(context, null, task, result);
} finally {
LensUtil.reclaimSequences(context, cacheRepositoryService, task, result);

RepositoryCache.exit();
}

if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Preview changes output:\n{}", context.debugDump());
}

result.computeStatus();
result.cleanupResult();


return context;
}

@Override
@Override
public <F extends ObjectType> ModelContext<F> unwrapModelContext(LensContextType wrappedContext, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
return LensContext.fromLensContextType(wrappedContext, prismContext, provisioning, task, result);
}
Expand Down Expand Up @@ -1509,7 +1477,7 @@ private boolean determineDeputyValidity(PrismObject<UserType> potentialDeputy, L
// TODO some special mode for verification of the validity - we don't need complete calculation here!
EvaluatedAssignment<UserType> assignment = assignmentEvaluator
.evaluate(assignmentIdi, PlusMinusZero.ZERO, false, potentialDeputy.asObjectable(),
potentialDeputy.toString(), task, result);
potentialDeputy.toString(), false, task, result);
if (!assignment.isValid()) {
continue;
}
Expand Down
Expand Up @@ -37,6 +37,7 @@
import com.evolveum.midpoint.provisioning.api.ChangeNotificationDispatcher;
import com.evolveum.midpoint.provisioning.api.ProvisioningService;
import com.evolveum.midpoint.provisioning.api.ResourceObjectChangeListener;
import com.evolveum.midpoint.repo.common.CounterManager;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.result.OperationConstants;
Expand Down

0 comments on commit cce8e60

Please sign in to comment.