Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/support-4.4' into support-4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Apr 3, 2023
2 parents 0733fcb + 6a081ae commit 2ece42b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.PrismPropertyDefinition;
import com.evolveum.midpoint.prism.PrismPropertyValue;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
import com.evolveum.midpoint.repo.common.expression.Expression;
import com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext;
Expand Down Expand Up @@ -83,6 +84,9 @@ public void validate(IValidatable<T> validatable) {
}
VariablesMap variables = new VariablesMap();
Class typeClass = (valueToValidate == null ? String.class : valueToValidate.getClass());
if (valueToValidate instanceof Referencable && ((Referencable) valueToValidate).asReferenceValue().isEmpty()) {
valueToValidate = null;
}
variables.put(ExpressionConstants.VAR_INPUT, valueToValidate, typeClass);
variables.putObject(ExpressionConstants.VAR_OBJECT, (ObjectType)getObjectType(), ObjectType.class);
ExpressionEvaluationContext context = new ExpressionEvaluationContext(null, variables, contextDesc, task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class ModelObjectResolver implements ObjectResolver {
private static final Trace LOGGER = TraceManager.getTrace(ModelObjectResolver.class);

@Override
public <O extends ObjectType> O resolve(ObjectReferenceType ref, Class<O> expectedType, Collection<SelectorOptions<GetOperationOptions>> options,
public <O extends ObjectType> O resolve(Referencable ref, Class<O> expectedType, Collection<SelectorOptions<GetOperationOptions>> options,
String contextDescription, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
String oid = ref.getOid();
Class<?> typeClass = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collection;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.GetOperationOptions;
Expand All @@ -27,7 +28,6 @@
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FunctionLibraryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

import org.jetbrains.annotations.NotNull;
Expand All @@ -50,7 +50,7 @@ public DirectoryFileObjectResolver(File directory) {
}

@Override
public <T extends ObjectType> T resolve(ObjectReferenceType ref, Class<T> expectedType,
public <T extends ObjectType> T resolve(Referencable ref, Class<T> expectedType,
Collection<SelectorOptions<GetOperationOptions>> options, String contextDescription,
Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
return getObject(expectedType, ref.getOid(), options, task, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismReferenceValue;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.ResultHandler;
Expand All @@ -26,7 +27,6 @@
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

/**
Expand All @@ -47,7 +47,6 @@ public interface ObjectResolver {
*
* @param ref object reference to resolve
* @param contextDescription short description of the context of resolution, e.g. "executing expression FOO". Used in error messages.
* @param task
* @return resolved object
* @throws ObjectNotFoundException
* requested object does not exist
Expand All @@ -58,7 +57,7 @@ public interface ObjectResolver {
*
* TODO resolve module dependencies to allow task to be of type Task
*/
<O extends ObjectType> O resolve(ObjectReferenceType ref, Class<O> expectedType, Collection<SelectorOptions<GetOperationOptions>> options,
<O extends ObjectType> O resolve(Referencable ref, Class<O> expectedType, Collection<SelectorOptions<GetOperationOptions>> options,
String contextDescription, Task task, OperationResult result)
throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.beans.factory.annotation.Qualifier;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.Referencable;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.repo.api.RepositoryService;
import com.evolveum.midpoint.schema.GetOperationOptions;
Expand All @@ -22,7 +23,6 @@
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public <O extends ObjectType> SearchResultList<PrismObject<O>> searchObjects(Cla
}

@Override
public <O extends ObjectType> O resolve(ObjectReferenceType ref, Class<O> expectedType,
public <O extends ObjectType> O resolve(Referencable ref, Class<O> expectedType,
Collection<SelectorOptions<GetOperationOptions>> options, String contextDescription, Task task,
OperationResult result) {
// TODO Auto-generated method stub
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static TypedValue<?> convertVariableValue(TypedValue<?> originalTypedValu
TypedValue<?> convertedTypedValue = originalTypedValue.shallowClone();
convertedTypedValue.setPrismContext(prismContext);

if (convertedTypedValue.getValue() instanceof ObjectReferenceType) {
if (convertedTypedValue.getValue() instanceof Referencable) {
convertedTypedValue = resolveReference(convertedTypedValue,
variableName, objectResolver, contextDescription, objectVariableMode,
task, result);
Expand Down Expand Up @@ -356,7 +356,7 @@ private static TypedValue<?> resolveReference(TypedValue referenceTypedValue, St
CommunicationException, ConfigurationException, SecurityViolationException,
ExpressionEvaluationException {
TypedValue<?> resolvedTypedValue;
ObjectReferenceType reference = ((ObjectReferenceType) referenceTypedValue.getValue()).clone();
Referencable reference = ((Referencable) referenceTypedValue.getValue()).clone();
OperationResult subResult = new OperationResult("Resolve reference"); // TODO proper op result handling (for tracing)
try {
Collection<SelectorOptions<GetOperationOptions>> options = null;
Expand Down Expand Up @@ -397,7 +397,7 @@ static TypedValue<PrismObject<?>> resolveReference(TypedValue<?> refAndDef, Obje
Collection<SelectorOptions<GetOperationOptions>> options, String varDesc, String contextDescription,
Task task, OperationResult result)
throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
ObjectReferenceType ref = (ObjectReferenceType) refAndDef.getValue();
Referencable ref = (Referencable) refAndDef.getValue();
if (ref.getOid() == null) {
throw new SchemaException(
"Null OID in reference in variable " + varDesc + " in " + contextDescription);
Expand Down Expand Up @@ -1128,7 +1128,7 @@ public static <T, V extends PrismValue> V convertToPrismValue(T value, ItemDefin
}

if (definition instanceof PrismReferenceDefinition) {
return (V) ((ObjectReferenceType) value).asReferenceValue();
return (V) ((Referencable) value).asReferenceValue();

} else if (definition instanceof PrismContainerDefinition) {

Expand Down

0 comments on commit 2ece42b

Please sign in to comment.