use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method createResourceConfigList.
private List<ResourceConfigurationDto> createResourceConfigList(ResourceType resource) {
OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, parentPage.getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resource.getOid()).build(), result, parentPage);
List<ResourceConfigurationDto> configs = new ArrayList<>();
if (resource.getSchemaHandling() == null) {
return configs;
}
List<ResourceObjectTypeDefinitionType> objectTypes = resource.getSchemaHandling().getObjectType();
if (objectTypes == null) {
return configs;
}
try {
for (ResourceObjectTypeDefinitionType objectType : objectTypes) {
ObjectSynchronizationType obejctSynchronization = null;
if (resource.getSynchronization() != null && resource.getSynchronization().getObjectSynchronization() != null) {
obejctSynchronization = getSynchronizationFor(objectType, resource.getSynchronization().getObjectSynchronization(), resource.asPrismObject());
}
List<TaskType> syncTask = new ArrayList<>();
if (obejctSynchronization != null) {
syncTask = getTaskFor(tasks, obejctSynchronization, resource.asPrismObject());
}
ResourceConfigurationDto resourceConfig = new ResourceConfigurationDto(objectType, obejctSynchronization != null, syncTask);
configs.add(resourceConfig);
}
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Could not determine resource configuration", ex);
}
return configs;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType in project midpoint by Evolveum.
the class TestSanityLegacy method checkOpenDjSchemaHandling.
private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType in project midpoint by Evolveum.
the class ActivationProcessor method processLifecycleFocus.
private <F extends FocusType> void processLifecycleFocus(LensContext<F> context, LensProjectionContext projCtx, XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException, SecurityViolationException {
LensFocusContext<F> focusContext = context.getFocusContext();
if (focusContext == null) {
LOGGER.trace("Skipping lifecycle evaluation because there is no focus");
return;
}
ResourceObjectLifecycleDefinitionType lifecycleDef = null;
ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType != null) {
lifecycleDef = resourceAccountDefType.getLifecycle();
}
ResourceBidirectionalMappingType lifecycleStateMappingType = null;
if (lifecycleDef != null) {
lifecycleStateMappingType = lifecycleDef.getLifecycleState();
}
if (lifecycleStateMappingType == null || lifecycleStateMappingType.getOutbound() == null) {
if (!projCtx.isAdd()) {
LOGGER.trace("Skipping lifecycle evaluation because this is not add operation (default expression)");
return;
}
PrismObject<F> focusNew = focusContext.getObjectNew();
if (focusNew == null) {
LOGGER.trace("Skipping lifecycle evaluation because there is no new focus (default expression)");
return;
}
PrismObject<ShadowType> projectionNew = projCtx.getObjectNew();
if (projectionNew == null) {
LOGGER.trace("Skipping lifecycle evaluation because there is no new projection (default expression)");
return;
}
String lifecycle = midpointFunctions.computeProjectionLifecycle(focusNew.asObjectable(), projectionNew.asObjectable(), projCtx.getResource());
LOGGER.trace("Computed projection lifecycle (default expression): {}", lifecycle);
if (lifecycle != null) {
PrismPropertyDefinition<String> propDef = projCtx.getObjectDefinition().findPropertyDefinition(SchemaConstants.PATH_LIFECYCLE_STATE);
PropertyDelta<String> lifeCycleDelta = propDef.createEmptyDelta(SchemaConstants.PATH_LIFECYCLE_STATE);
PrismPropertyValue<String> pval = new PrismPropertyValue<String>(lifecycle);
pval.setOriginType(OriginType.OUTBOUND);
lifeCycleDelta.setValuesToReplace(pval);
projCtx.swallowToSecondaryDelta(lifeCycleDelta);
}
} else {
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);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType in project midpoint by Evolveum.
the class ActivationProcessor method evaluateExistenceMapping.
private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context, final LensProjectionContext accCtx, final XMLGregorianCalendar now, final boolean current, Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
final String accCtxDesc = accCtx.toHumanReadableString();
final Boolean legal = accCtx.isLegal();
if (legal == null) {
throw new IllegalStateException("Null 'legal' for " + accCtxDesc);
}
ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return legal;
}
ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
if (activationType == null) {
return legal;
}
ResourceBidirectionalMappingType existenceType = activationType.getExistence();
if (existenceType == null) {
return legal;
}
List<MappingType> outbound = existenceType.getOutbound();
if (outbound == null || outbound.isEmpty()) {
// "default mapping"
return legal;
}
MappingEvaluatorParams<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>, ShadowType, F> params = new MappingEvaluatorParams<>();
params.setMappingTypes(outbound);
params.setMappingDesc("outbound existence mapping in projection " + accCtxDesc);
params.setNow(now);
params.setAPrioriTargetObject(accCtx.getObjectOld());
params.setEvaluateCurrent(current);
params.setTargetContext(accCtx);
params.setFixTarget(true);
params.setContext(context);
params.setInitializer(builder -> {
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSourceIdi = getLegalIdi(accCtx);
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> legalSource = new Source<>(legalSourceIdi, ExpressionConstants.VAR_LEGAL);
builder.defaultSource(legalSource);
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedIdi = getAssignedIdi(accCtx);
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> assignedSource = new Source<>(assignedIdi, ExpressionConstants.VAR_ASSIGNED);
builder.addSource(assignedSource);
ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSourceIdi = getFocusExistsIdi(context.getFocusContext());
Source<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> focusExistsSource = new Source<>(focusExistsSourceIdi, ExpressionConstants.VAR_FOCUS_EXISTS);
builder.addSource(focusExistsSource);
builder.addVariableDefinition(ExpressionConstants.VAR_FOCUS, context.getFocusContext().getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_USER, context.getFocusContext().getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_SHADOW, accCtx.getObjectDeltaObject());
builder.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, accCtx.getResource());
builder.originType(OriginType.OUTBOUND);
builder.originObject(accCtx.getResource());
return builder;
});
final MutableBoolean output = new MutableBoolean(false);
params.setProcessor((mappingOutputPath, outputStruct) -> {
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = outputStruct.getOutputTriple();
if (outputTriple == null) {
// The "default existence mapping"
output.setValue(legal);
return false;
}
Collection<PrismPropertyValue<Boolean>> nonNegativeValues = outputTriple.getNonNegativeValues();
// (e.g. because the condition is false). This should be fixed.
if (nonNegativeValues == null || nonNegativeValues.isEmpty()) {
throw new ExpressionEvaluationException("Activation existence expression resulted in null or empty value for projection " + accCtxDesc);
}
if (nonNegativeValues.size() > 1) {
throw new ExpressionEvaluationException("Activation existence expression resulted in too many values (" + nonNegativeValues.size() + ") for projection " + accCtxDesc);
}
output.setValue(nonNegativeValues.iterator().next().getValue());
return false;
});
PrismPropertyDefinitionImpl<Boolean> shadowExistsDef = new PrismPropertyDefinitionImpl<>(SHADOW_EXISTS_PROPERTY_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
shadowExistsDef.setMinOccurs(1);
shadowExistsDef.setMaxOccurs(1);
params.setTargetItemDefinition(shadowExistsDef);
mappingEvaluator.evaluateMappingSetProjection(params, task, result);
return (boolean) output.getValue();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectTypeDefinitionType in project midpoint by Evolveum.
the class ProjectionValuesProcessor method evaluateIterationCondition.
private <F extends ObjectType> boolean evaluateIterationCondition(LensContext<F> context, LensProjectionContext accountContext, int iteration, String iterationToken, boolean beforeIteration, Task task, OperationResult result) throws ExpressionEvaluationException, SchemaException, ObjectNotFoundException {
ResourceObjectTypeDefinitionType accDef = accountContext.getResourceObjectTypeDefinitionType();
if (accDef == null) {
return true;
}
IterationSpecificationType iterationType = accDef.getIteration();
ExpressionVariables variables = createExpressionVariables(context, accountContext);
return LensUtil.evaluateIterationCondition(context, accountContext, iterationType, iteration, iterationToken, beforeIteration, expressionFactory, variables, task, result);
}
Aggregations