Search in sources :

Example 6 with Visitor

use of com.evolveum.midpoint.prism.Visitor in project midpoint by Evolveum.

the class CryptoUtil method checkEncrypted.

// Checks that everything is encrypted
public static <T extends ObjectType> void checkEncrypted(final ObjectDelta<T> delta) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if (!(visitable instanceof PrismPropertyValue)) {
                return;
            }
            PrismPropertyValue<?> pval = (PrismPropertyValue<?>) visitable;
            checkEncrypted(pval);
        }
    };
    try {
        delta.accept(visitor);
    } catch (IllegalStateException e) {
        throw new IllegalStateException(e.getMessage() + " in delta " + delta, e);
    }
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor) Visitable(com.evolveum.midpoint.prism.Visitable) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 7 with Visitor

use of com.evolveum.midpoint.prism.Visitor in project midpoint by Evolveum.

the class CryptoUtil method checkEncrypted.

public static void checkEncrypted(Collection<? extends ItemDelta> modifications) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if (!(visitable instanceof PrismPropertyValue)) {
                return;
            }
            PrismPropertyValue<?> pval = (PrismPropertyValue<?>) visitable;
            checkEncrypted(pval);
        }
    };
    for (ItemDelta<?, ?> delta : modifications) {
        try {
            delta.accept(visitor);
        } catch (IllegalStateException e) {
            throw new IllegalStateException(e.getMessage() + " in modification " + delta, e);
        }
    }
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor) Visitable(com.evolveum.midpoint.prism.Visitable) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 8 with Visitor

use of com.evolveum.midpoint.prism.Visitor in project midpoint by Evolveum.

the class PrismAsserts method assertAllParsedNodes.

public static void assertAllParsedNodes(XNode xnode) {
    Visitor visitor = new Visitor() {

        @Override
        public void visit(Visitable visitable) {
            if ((visitable instanceof PrimitiveXNode<?>)) {
                assert ((PrimitiveXNode<?>) visitable).isParsed() : "Xnode " + visitable + " is not parsed";
            }
        }
    };
    xnode.accept(visitor);
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor) PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) Visitable(com.evolveum.midpoint.prism.Visitable)

Example 9 with Visitor

use of com.evolveum.midpoint.prism.Visitor in project midpoint by Evolveum.

the class PrismAsserts method assertOrigin.

public static void assertOrigin(ObjectDelta<?> objectDelta, final Objectable expectedOriginObject, final OriginType... expectedOriginTypes) {
    Visitor visitor = createOriginVisitor(objectDelta, expectedOriginObject, expectedOriginTypes);
    objectDelta.accept(visitor, false);
}
Also used : Visitor(com.evolveum.midpoint.prism.Visitor)

Example 10 with Visitor

use of com.evolveum.midpoint.prism.Visitor in project midpoint by Evolveum.

the class Utils method resolveReferences.

/**
	 * Resolves references contained in given PrismObject.
	 *
	 * @param object
	 * @param repository
	 * @param enforceReferentialIntegrity If true, missing reference causes fatal error when processing (if false, only warning is issued).
	 * @param forceFilterReevaluation If true, references are reevaluated even if OID is present. (Given that filter is present as well, of course.)
	 * @param prismContext
	 * @param result
	 */
public static <T extends ObjectType> void resolveReferences(PrismObject<T> object, RepositoryService repository, boolean enforceReferentialIntegrity, boolean forceFilterReevaluation, EvaluationTimeType resolutionTime, boolean throwExceptionOnFailure, PrismContext prismContext, OperationResult result) {
    Visitor visitor = visitable -> {
        if (!(visitable instanceof PrismReferenceValue)) {
            return;
        }
        resolveRef((PrismReferenceValue) visitable, repository, enforceReferentialIntegrity, forceFilterReevaluation, resolutionTime, prismContext, object.toString(), throwExceptionOnFailure, result);
    };
    object.accept(visitor);
}
Also used : EvaluationTimeType(com.evolveum.prism.xml.ns._public.types_3.EvaluationTimeType) StringUtils(org.apache.commons.lang.StringUtils) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) CryptoUtil(com.evolveum.midpoint.common.crypto.CryptoUtil) com.evolveum.midpoint.prism.query(com.evolveum.midpoint.prism.query) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Trace(com.evolveum.midpoint.util.logging.Trace) ExpressionConstants(com.evolveum.midpoint.schema.constants.ExpressionConstants) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) EncryptionException(com.evolveum.midpoint.prism.crypto.EncryptionException) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) ArrayList(java.util.ArrayList) RefinedResourceSchema(com.evolveum.midpoint.common.refinery.RefinedResourceSchema) Handler(com.evolveum.midpoint.util.Handler) ScriptExpression(com.evolveum.midpoint.model.common.expression.script.ScriptExpression) Visitor(com.evolveum.midpoint.prism.Visitor) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) RepositoryService(com.evolveum.midpoint.repo.api.RepositoryService) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) com.evolveum.midpoint.model.impl.lens(com.evolveum.midpoint.model.impl.lens) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) ModelExpressionThreadLocalHolder(com.evolveum.midpoint.model.impl.expr.ModelExpressionThreadLocalHolder) Task(com.evolveum.midpoint.task.api.Task) RefinedObjectClassDefinition(com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition) ExpressionEnvironment(com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment) QueryConvertor(com.evolveum.midpoint.prism.marshaller.QueryConvertor) ResourceShadowDiscriminator(com.evolveum.midpoint.schema.ResourceShadowDiscriminator) Nullable(org.jetbrains.annotations.Nullable) ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) List(java.util.List) ModelConstants(com.evolveum.midpoint.model.impl.ModelConstants) Protector(com.evolveum.midpoint.prism.crypto.Protector) SystemException(com.evolveum.midpoint.util.exception.SystemException) SearchFilterType(com.evolveum.prism.xml.ns._public.query_3.SearchFilterType) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) QName(javax.xml.namespace.QName) NotNull(org.jetbrains.annotations.NotNull) ObjectImporter(com.evolveum.midpoint.model.impl.importer.ObjectImporter) Validate(org.apache.commons.lang.Validate) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) Visitor(com.evolveum.midpoint.prism.Visitor)

Aggregations

Visitor (com.evolveum.midpoint.prism.Visitor)13 Visitable (com.evolveum.midpoint.prism.Visitable)9 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)4 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 Item (com.evolveum.midpoint.prism.Item)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 Collection (java.util.Collection)2 CryptoUtil (com.evolveum.midpoint.common.crypto.CryptoUtil)1 RefinedObjectClassDefinition (com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition)1 RefinedResourceSchema (com.evolveum.midpoint.common.refinery.RefinedResourceSchema)1 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 ScriptExpression (com.evolveum.midpoint.model.common.expression.script.ScriptExpression)1 ModelConstants (com.evolveum.midpoint.model.impl.ModelConstants)1 ExpressionEnvironment (com.evolveum.midpoint.model.impl.expr.ExpressionEnvironment)1